PYTHON
Problem 1: Given a list of integers (say list1), and two integers (say k, t). Define a function, named search(list1, k, t), that verifies whether kis at index i, and tis at index i+1 in the list for some i. If so, display the indexes. In ( ): Problem 2: Use 1000 numbers.txt to create a list, named list2. You define a function, that verifies whether k is at index i, and t is at index i+1 in the list, for some i. If so, display the indexes. In [ ]: Problem 3. You create a random list with 10000 integers. Each number in the list is randomly generated, not less than -10000 and not greater than 10000. And create a random integer as a search key, that not less than-10000 and not greater than 10000. Compute the number of key comparisons needed when you use Binary Search algorithm. Now you repeat the process 1000 times and compute the average number of key comparisons. You may use sorti) to put a list in order (before you use Binary Search on that list). >>> alist = [5,2,-6,0,1,0,4] >>> alist.sort() >>> print(alist) (-6, 0, 0, 1, 2, 4, 5] >>> In (: In 1:
Problem 1: Given a list of integers (say list1), and two integers (say k, t). Define a function, named search(list1, k,
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Problem 1: Given a list of integers (say list1), and two integers (say k, t). Define a function, named search(list1, k,
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!