Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python language Exercises Problem 1 Write a program that uses a function called binary_Isearch() that takes a list and a search key and returns the

python language image text in transcribed

Exercises Problem 1 Write a program that uses a function called binary_Isearch() that takes a list and a search key and returns the index of the search key. If it does not exist, return-1. This function must use iteration. The following is the main part of your program. Your task is to create the function. #create the function here import random, time #I mean create the function here ... really # main largeList = range (5000, 20000) largeList largeList[:: 3] largeMixedList = random sample (largeList, len (largeList)) # Do NOT print the list here # choose a number between 5000 and 20000 key = 9872 # or use a random generator to get a number timel = time. perf_counter() # or time.time() res = binary_Isearch (largeMixedList, key) # calling the function here time2 = time. perf_counter() if res == -1: print("The search key", key, "could not be found in the list.") else: print("The search key", key, "was found at position", res) print("It took", time2-timel) QATAR Problem 2 Write a program that uses a function called binary_Rsearch() that takes a list and a search key and returns the index of the search key. If it does not exist, return-1. This function must use recursion. Your task is to create the function. Use the main section in the previous problem. Problem 3 Write a program that uses a function called linear_search() that takes a list and a search key and returns the index of the search key. If it does not exist, return-1. This function must use linear search. Your task is to create the function. Use the main section in the previous

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

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

5. Develop the succession planning review.

Answered: 1 week ago