Answered step by step
Verified Expert Solution
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
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 textStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started