Question: Pseudocode: function binary_search(A, n, T) is L := 0 R := n 1 while L R do m := floor((L + R) / 2) if

Pseudocode:

function binary_search(A, n, T) is

L := 0

R := n 1

while L R do

m := floor((L + R) / 2)

if A[m] < T then

L := m + 1

else if A[m] > T then

R := m 1

else:

return m

return unsuccessful

Implement the C++ Binary Search algorithm in your compiler and then use it to compare searching times with the find function of the STL. To perform the test, cretae an array or vector of at least 100,000 elements. Which algorithm is faster and by how much? Put your analysis in comments at the end of your program.

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 Programming Questions!