Question: How many passes are made through the While loop? The following pseudocode used to perform a binary search of the names Arnold, Draper, Gomez, Johnson,

How many passes are made through the While loop?


The following pseudocode used to perform a binary search of the names "Arnold", "Draper", "Gomez", "Johnson", "Smith", "Wong" (stored in Array), for the name "Gomez". (Assume the array and all the variables have already been declared with their appropriate data types.)

Set N = 5 Set Key

Set N = 5 Set Key "Gomez" Set Low Set High = N Set Index Int (N/2) Set Found While (Found == 0) AND (Low Array[Index] Then Set Low = Index + 1 Set Index = Int((High + Low)/2) End If If Key < Array[Index] Then Set High = Index - 1 Set Index = Int((High + Low)/2) End If End While

Step by Step Solution

3.48 Rating (164 Votes )

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