Given a sorted array of n comparable items A, and a search value key, return the position (array index) of key in A if it is present, or -1 if it is not present. If key is present in A, your algorithm must run in order O(log k) time, where k is the location of key in A. Otherwise, if key is not present, your algorithm must run in O(log n) time.
Algorithm Means,
A computer can solve a problem using an algorithm, which is a well-defined technique. A sequence of clear instructions is another approach to define an algorithm. The word "unambiguous" implies that there is no opportunity for subjective interpretation. When you request your computer to perform the very same algorithm, computer will do it in the same way every time, with the same outcome.
Array :
Arrays are indeed a foundational data structure that may be used in a variety of ways. Arrays are used to store information of the same kind in memory regions that are close together. Arrays, in particular, allow us to form "groups" and "clusters" containing variables without having to give each one a distinct name, but yet enabling everyone to sequentially index into the array's elements.
Now, Let us discuss about above question with more detail in step - 2 with program.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps