Presentation is loading. Please wait.

Presentation is loading. Please wait.

Given value and sorted array, find index.

Similar presentations


Presentation on theme: "Given value and sorted array, find index."— Presentation transcript:

1 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 16. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low midpoint high

2 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 16. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low high midpoint

3 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 16. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low high midpoint

4 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 16. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low high midpoint

5 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 16. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low high midpoint

6 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 16. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low midpoint high

7 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 16. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low high midpoint

8 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 16. 6 7 12 15 6 16 22 24 30 33 40 6 44 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low high midpoint Found it!

9 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 50. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low midpoint high

10 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 50. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 midpoint low high

11 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 50. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low high midpoint

12 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 50. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low high midpoint

13 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 50. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low high midpoint

14 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 50. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low midpoint high

15 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 50. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 low high midpoint

16 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 50. 6 7 12 15 6 16 22 24 30 33 40 44 6 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 high low midpoint

17 Given value and sorted array, find index.
Binary search. Given value and sorted array, find index. Example: Binary search for 50. 6 7 12 15 6 16 22 24 30 33 40 6 44 47 51 53 57 1 2 3 4 5 6 7 8 9 10 11 12 13 14 high low midpoint NOT Found!


Download ppt "Given value and sorted array, find index."

Similar presentations


Ads by Google