Give the recursive binary search algorithm.

What will be an ideal response?


The recursive binary search is sent an array and indices first and last that specify limits of the subarray. The function tests the condition first>last to determine whether the key is not present in the array. If true, report this and quit.

If the key may be present, a ‘middle’ index is computed, and the equality of the element at the middle is compared to the key. If equal, report this fact and quit.

If the key still may be present, determine if the key is in the upper or lower half of the array and recursively call the search on that half array.

Computer Science & Information Technology

You might also like to view...

Which of the following statements is false?

a. Java makes concurrency available to you through the language and APIs. b. Concurrency is a subset of parallelism. c. Today’s multi-core computers have multiple processors that can perform tasks in parallel. d. Java programs can have multiple threads of execution, where each thread has its own method-call stack and program counter, allowing it to execute concurrently with other threads. This capability is called multithreading.

Computer Science & Information Technology

If a thread is not finished running, perhaps because it had to wait or it was preempted, it is typically restarted on the same processor that previously ran it. What is this known as?

A. multitasking B. preemptive multitasking C. processor affinity D. cooperative multitasking

Computer Science & Information Technology

Which function would change george jungle to George Jungle?

A. PROPER B. UPPER C. LOWER D. TRANSPOSE

Computer Science & Information Technology

Convert the decimal fraction ½ to binary.

a. 0.012 b. 0.12 c. 1.02 d. .1102

Computer Science & Information Technology