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

Given array values with the following order {6, 8, 17, 23, 30, 45, 80, 87, 93} a

ID: 3581586 • Letter: G

Question

Given array values with the following order {6, 8, 17, 23, 30, 45, 80, 87, 93} and a key value of 93, which of the following statements is true about finding the key?

linear search uses 9 comparisons and binary search uses 4 comparisons

linear search uses 8 comparisons and binary search uses 4 comparisons

linear search uses 8 comparisons and binary search uses 3 comparisons

linear search uses 9 comparisons and binary search uses 3 comparisons

neither search method will find the key

linear search uses 9 comparisons and binary search uses 4 comparisons

linear search uses 8 comparisons and binary search uses 4 comparisons

linear search uses 8 comparisons and binary search uses 3 comparisons

linear search uses 9 comparisons and binary search uses 3 comparisons

neither search method will find the key

Explanation / Answer

Answer is :

linear search uses 9 comparisons and binary search uses 4 comparisons

for linear search starts search element from inital index. if not matches it move to next index untill it find the element so it take 9 comparison.

binary searches by pivot element means middle element . it take 4 comparisons

first the pivot element of 6 - 93 is 23

next the pivot element of 30 - 93 is 80

next the pivot element of 87 - 93 is 87

next the pivot element of 93 - 93 is 93

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