Rutgers University PYTHON: Unit Four Assignment Two. MySearches.py
Unit Four Assignment Two ###### Read , 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 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]
Escuela, estudio y materia
- Institución
- PYTHON: MySearches.py
- Grado
- PYTHON: MySearches.py
Información del documento
- Subido en
- 23 de marzo de 2023
- Número de páginas
- 2
- Escrito en
- 2022/2023
- Tipo
- Examen
- Contiene
- Preguntas y respuestas
Temas
-
python unit four assignment two mysearchespy