Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following list of 2 0 elements sorted in ascending order: lis = [ 1 , 3 , 4 , 6 , 7 ,

Consider the following list of 20 elements sorted in ascending order:
lis =[1,3,4,6,7,9,10,11,12,14,16,17,20,26,29,30,31,32,34,40]
Suppose we searching for the value 45. How many elements will be checked if we use linear search? How many elements will be checked if we use binary search?
Assume we are using the versions of both taught in zybook sections 13.5 and 13.6, with no changes to improve performance.
a.
Linear Search: 20
Binary Search: 1
b.
Linear Search: 0
Binary Search: 0
No values checked, as 45 is not in the list.
c.
Linear Search: 5
Binary Search: 5
d.
Linear Search: 19
Binary Search: 4
e.
Linear Search: 10
Binary Search: 5
f.
Linear Search: 20
Binary Search: 5
g.
Linear Search: 20
Binary Search: 20

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Handbook Of Database Security Applications And Trends

Authors: Michael Gertz, Sushil Jajodia

1st Edition

1441943056, 978-1441943057

More Books

Students also viewed these Databases questions

Question

5. Have you stressed the topics relevance to your audience?

Answered: 1 week ago