0% found this document useful (0 votes)
2 views1 page

Efficient Algorithms for Sorted Arrays

Uploaded by

Thùy Nguyễn
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Efficient Algorithms for Sorted Arrays

Uploaded by

Thùy Nguyễn
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Practices

1) Describe an algorithm with time complexity O(n log n) that takes a sorted array A and
integer x, and determines whether there exist two elements in A whose sum is exactly x.
If so, it returns TRUE otherwise returns FALSE.

2) Assume that A is a sorted array with distinct integer numbers like this:
A = [ − 3, 1, 4, 5, 7, 10, 12, 15]
Write a pseudo-code for a procedure that returns i such that A [ i ] = i. It returns -1 if
there is no such element. The time complexity of the algorithm should be 𝑶(𝐥𝐨𝐠 𝒏)

You might also like