Question

What is the maximum number of comparisons made when searching a 60 element array with Binary Search? 60 30 5 6 Question 3 (3
A selection sort algorithm is used to sort an array containing the following values into ascending order. Give the order of t
0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:

QUESTION ANSWER EXPLANATION
1. 5

The maximum number of comparisons in array of 60 elements with binary search requires log2(60)
= 5.9 => 5 comparisons.
NOTE: Binary search reduces the search space to its half in each iteration. Hence, For an array of 60 elements, maximum 5 comparisons will be required.

2. 30

The average number of comparisons in linear search will be equal to (n/2) = (60/2) = 30 comparisons

NOTE: n is the array size.

3. Pass 1 for Selection Sort: [6, 4, 7, 2, 3, 5]
Pass 2 for Selection Sort: [2, 4, 7, 6, 3, 5]
Pass 3 for Selection Sort: [2, 3, 7, 6, 4, 5]
Pass 4 for Selection Sort: [2, 3, 4, 6, 7, 5]
Pass 5 for Selection Sort: [2, 3, 4, 5, 7, 6]
Final Sorted Array: [2, 3, 4, 5, 6, 7]

SAMPLE CODE:

def selectionSort(l): for i in range (len(1)-1): print(Pass,i+1,for Selection Sort:,1) index=i for j in range (i+1, len(L

Add a comment
Know the answer?
Add Answer to:
What is the maximum number of comparisons made when searching a 60 element array with Binary...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT