Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Big theta please explain 3. Recall that for integers a1, an and an integer z, Lin a,a1,... an) returns the index of z earSearch if

Big theta please explain
image text in transcribed
image text in transcribed
3. Recall that for integers a1, an and an integer z, Lin a,a1,... an) returns the index of z earSearch if z is one of the elements of the list a1,... an or returns 0 if ze is not part of the list. Linearsearch has a runtime of e(1) in the best case, and e(n) in the worst case. Recall that for a sorted list of integers a1, an and an integer z, B (z,a1, an) also returns the index of z if z is one of the elements of the list or returns 0 if z is not part of the list. Binarysearch has a runtime of e(log(n)) in all cases (a) Consider the following two search algorithms: procedure Searchl an) 1. return LinearSearch(r,a1, procedure Searc a1,...,an) 1. 81,..., sn martSort a1 an) 2. return BinarySearch(a, s1,...,sn) Assume that SmartSort has a runtime of e(nlog(n)) in all cases.) i. Use e notation to describe the runtimes of Searchl and Search2 in the best case. Which algorithm is more efficient in the best case? Justify your answers. ii. Use e notation to describe the runtimes of Searchl and Search in the worst case. Which algorithm is more efficient in the worst case? Justify your answers. (b) Suppose that n is even, and instead of searching for one z value, you wanted to search for n/2 values n/2 Consider these two algorithms that each take as input a list of integers a1, ...,an and another list of integers zi, and return an array Location, of length n/2, where Locationli] is the index of zi in the list a1 an, and Locationli) is 0 if zj is not found in the list a1,...,an

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

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

Compare a companys strategic plan with a football teams game plan.

Answered: 1 week ago

Question

2. How do they influence my actions?

Answered: 1 week ago

Question

5. If yes, then why?

Answered: 1 week ago