Programming > QUESTIONS & ANSWERS > Rutgers University PYTHON: Unit Four Assignment Two. MySearches.py (All)
Unit Four Assignment Two ###### Read rands.txt, covert from strings to integers and then sort of the data. Have a list of sorted integers with a Len of 10,000 ###### Create a library called mySearc... hes.py thats has two functions bsearch & lsearch ###### bsearch is a function how many lookups were performed during the search before it returns its value ###### lsearch is a function that accepts an integer and a list, conducts a linear search thru the list and returns the index of the number in the list if the number is found and a -1 if the number is not found. ###### ....The function reports how many lookups were performed during the search before it returns its value def bsearch (x,nums): item = 0 low = 0 high = len(nums)-1 c = 0 while low <= high: #while loop for a range to search mid = (low + high)//2 #midpoint for guess item = nums[mid] [Show More]
Last updated: 1 year ago
Preview 1 out of 2 pages
Connected school, study & course
About the document
Uploaded On
Mar 24, 2023
Number of pages
2
Written in
This document has been written for:
Uploaded
Mar 24, 2023
Downloads
0
Views
67
In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Browsegrades · High quality services·