Opening book details…
Can I read Design and Analysis of Algorithms Guide on EtoBox?
Design and Analysis of Algorithms Guide by Oppo House is a document available to read on EtoBox.
What is Design and Analysis of Algorithms Guide about?
Here is the pseudocode for an algorithm to find the position of a pole with height H in a sorted array of pole heights: ``` Function FindPosition(poleHeights[], H, n) low = 0 high = n-1 while low <= high mid = (low+high)/2 if poleHeights[mid] == H return mid else if poleHeights[mid] < H low = mid + 1 else high = mid - 1 return -1 ``` This implements a binary search algorithm to find the position in logarithmic time O(logn). Binary search works by
- Author
- Oppo House
- Language
- EN