Más contenido relacionado Más de ecomputernotes (20) Computer notes - Binary Search1. Class No.33 Data Structures http://ecomputernotes.com 4. Case 1: val == a[mid] val = 10 low = 0, high = 8 5 7 9 10 13 17 19 1 27 a: low high Binary Search http://ecomputernotes.com 1 2 3 4 5 6 7 0 8 mid mid = (0 + 8) / 2 = 4 10 5. Case 2: val > a[mid] val = 19 low = 0, high = 8 mid = (0 + 8) / 2 = 4 Binary Search -- Example 2 5 7 9 10 1 a: mid low high http://ecomputernotes.com 13 17 19 27 1 2 3 4 5 6 7 0 8 new low new low = mid+1 = 5 13 17 19 27 6. Case 3: val < a[mid] val = 7 low = 0, high = 8 mid = (0 + 8) / 2 = 4 Binary Search -- Example 3 10 13 17 19 27 a: mid low high http://ecomputernotes.com 5 7 9 1 1 2 3 4 5 6 7 0 8 new high new high = mid-1 = 3 5 7 9 1 7. val = 7 Binary Search -- Example 3 (cont) 5 7 9 10 13 17 19 1 27 1 2 3 4 5 6 7 0 8 a: 5 7 9 10 13 17 19 1 27 1 2 3 4 5 6 7 0 8 a: 5 7 9 10 13 17 19 1 27 1 2 3 4 5 6 7 0 8 a: Notas del editor End of Lecture 38 Start lecture 39 End of lecture 39, Start of lecture 40.