work.docx

# work.docx - The recursive pseudocode algorithm which looks...

• 3

This preview shows page 1 - 3 out of 3 pages.

The recursive pseudocode algorithm which looks for specific text within all textbooks located in a library a) The algorithm for binary search is given below: Algorithm: 1. binarySearch(in array[], int first, int last, int key) 2. mid = (first+ first)/2 //here first and last are index of first and last element of the array 3. if(key==array[mid]) 4. return index 5. else if(key<array[mid]) 6. return binarySearch(array, first, mid-1, key) //start seraching in the left subtree recursively 7. else 8. return binarySearch(array, mid+1, last, key)//start seraching in the right subtree recursively b) The recurrence relation for the above algorithm will be T(n) = T(n/2) + c T(n/2), because we are dividing the array into half and after the comparison, we are starting to look at the half side of the array. After solving this recurrence suing master theorem we will get the time complexity T(n) = O(log n)

Subscribe to view the full document.

The document explaining sort priorities, including: the list of character sort strings, numerical data searches, arrays, subarrays, normalization database link revisions, and Pivindex
You've reached the end of this preview.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern