English, asked by naguakka90, 8 months ago

given an array arr={5,6,77,88,99} and key =88 how many iterations are done until the element is found​

Answers

Answered by poojan
9

As you haven't mentioned the searching technique used, here we are presenting the answers for two main searches.

1. With Binary Search - 2 Iterations ( As the elements are in sorted order.)

2. With Linear Search - 4 Iterations

Explanation:

1. Binary Search - 2 Iterations:

In Binary Search, as the elements are in sorted order, getting through the middle element on first iteration, we find 77. As the key 88>77, we should move towards the right part to 77on next iteration, in which we get immediately 88. On comparing the key 88 to the element we have got in the iteration 88, they are matched. So, on Iteration 2, the element is found.

2. Linear Search - 4 Iterations:

In Linear search, we go through every element in the array from the starting index, till we find the element we are searching for. This method is ideal for a search in an unsorted array.

1st iteration : 5 < 88  

2nd iteration : 6 < 88

3rd iteration : 77 < 88

4th iteration : 88 = 88 (Key found)

Learn more :

1. What would be the level-order traversal of the BST formed by inserting the following keys in sequence 41 53 18 72 63 38 71 79 47 54

https://brainly.in/question/15216617

2. How many edges of this binary tree violate the min-heap property? In other words, for how many edges of the tree, the parent value is greater than the value of the child?

https://brainly.in/question/16224499

Similar questions