Implement a program that contains the following functions. Users are required to
ID: 3537462 • Letter: I
Question
Implement a program that contains the following functions. Users are required to input the n integers from the console.
(1) Given a list of n integers, find the largest integer in the list and print out the position.
(2) Given a list of n integers, find the first and last occurrences of the largest integer in the list.
(3) Given a list of n distinct integers, determine the position of an integer in the list using a linear search. (Users can input an integer from the console, and the function can print the position of this integer)
(4) Given an ordered list of n distinct integers, determine the position of an integer in the list using a binary search.(Users can input an integer from the console, and the function can print the position of this integer)
Explanation / Answer
(4) using binary search:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.