Question: 1 . Write in pseudo code a binary search algorithm that works over an array. Use the iterative method. Comment to explain the algorithm. 2

1. Write in pseudo code a binary search algorithm that works over an array. Use the iterative method. Comment to explain the algorithm.
2. Write in the programming language of your choice a binary search algorithm that works over an array. Comment to explain the algorithm.
3. Use the attached file numbers.txt Download numbers.txtand use your algorithm to answer the below questions. You will have to implement an operation counter to answer these. Submit your code that answers these.
a. What is the position of 51216352 in the array? How many operations did it take to find?
b. What is the position of 198313119 in the array? How many operations did it take to find?
c. What is the position of 196614208 in the array? How many operations did it take to find?
d. What is the worst case time complexity? Evaluate line by line, create a time complexity function and then define its Big O value.
e. What would the worst case time complexity be if we have 4000 entries instead of 2000?
f. What do you think the average case time complexity is for binary search? Explain your reasoning.
4. Evaluate the time complexity of the following code snippets. Evaluate line by line, create a time complexity function and then define its Big O value.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!