Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Quiz Q1: If a binary search was used on the list in the accompanying figure

ID: 3717017 • Letter: J

Question

Java Quiz

Q1: If a binary search was used on the list in the accompanying figure, which element would the search element be compared to first?

A. 4

B. 35

C. 44

D. 98

Q2: If the list in the accompanying figure was to be searched using a sequential search on an unordered list, how many key comparisons would be made to find the number 44?

A. 1

B. 3

C. 5

D. 6

Q3: If the list in the accompanying figure were to be searched using a sequential search on an ordered list, how many key comparisons would be made to find the number 44?

A. 1

B. 3

C. 5

D. 6

Q4: If the list in the accompanying figure was to be searched for the number 44 using a binary search, how many key comparisons would have to be made?

A. 1

B. 3

C. 5

D. 7

0 1 2 3 4 5 6 7 List: 4 18 29 35 44 59 65 98

Explanation / Answer

1.C because in binary search the search begin with the element n/2 where n is the no.of elements.

2.for an unordered list the number of comparisons may vary as the list is ordered list it takes 5 comparisions as in ordered table

3.5 comparisions need to be made in order to search 44 as the sequential search begins with 0th element and as the number 44 is in 5th element.

4.only 1 comparision is needed to find the key 44 as n/2 is 5th element which is 44 itself so 1 is enough

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote