Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using python 3 Question 2: Consider the following code segment: for i in range (12): do_this_function(i) Part a) Re-write the code segement using a while-loop

using python 3

image text in transcribedimage text in transcribed

Question 2: Consider the following code segment: for i in range (12): do_this_function(i) Part a) Re-write the code segement using a while-loop in place of the for- loop. Assume that the function do_this_function has been defined. Part b) In what way is the behavior of while-loop version you wrote in part a) the same as the for-loop version provided above and in what way is its behavior different? You may hand this in as a code and comments in a cell of a .ipynb file or as hand written text. Question 5: Consider the binary search algorithm. Part a) Explain why binary search doesn't work on unsorted lists. Part of your goal in this explanation is to convince me that you understand how binary search does work for sorted lists. Part b) Given that binary search doesn't work in some cases where linear search does work, explain what it is about binary search that is better than linear search. Part of your goal in this explanation is to convince me that you understand how linear search works. You may hand this in as comments in a cell of a .ipynb file, as typewritten text using some other common text format, or as hand written text

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

Step: 3

blur-text-image

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

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions