Question: 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

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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!