Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(d) Consider the following algorithm to find the smallest item in a list of n distinct integers: 1. Pick an element, x, from the list

(d) Consider the following algorithm to find the smallest item in a list of n distinct integers: 1. Pick an element, x, from the list at random. 2. Go through every other element in the list. If an element is less than x put it in list 1, and if it's more than x, put it in list 2. (Note: Since all elements in the list are distinct, none will equal to x.) 3. If list 1 is empty, then return x, since it's the smallest element. If list 1 is NOT empty, go back to the first step, only using list 1. In terms of n, what is the best case run-time of this algorithm? In terms of n, what is the worst case run-time of this algorithm? Justify both answers in words.

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

More Books

Students also viewed these Databases questions