Recitation8 - Recitation8 Sunday Name Linear Search Binary Search The list to be searched L = 1 3 4 6 8 9 11 The value to be found X = 4 1 3 4 6 8 9 11

# Recitation8 - Recitation8 Sunday Name Linear Search Binary...

• 3

This preview shows page 1 - 3 out of 3 pages.

Recitation8 Name:_______________________________ Sunday, November 02, 2014 Linear Search Binary Search The list to be searched: L = 1 3 4 6 8 9 11. The value to be found: X = 4. 1 3 4 6 8 9 11 Compare X to 6. X is smaller. Repeat with L = 1 3 4. 1 3 4 Compare X to 3. X is bigger. Repeat with L = 4. 4 Compare X to 4. They are equal. We're done, we found X.
Recitation8 Name:_______________________________ Sunday, November 02, 2014 Bubble Sort Let us take the array of numbers "5 1 4 2 8", and sort the array from lowest number to greatest number using bubble sort. In each step, elements written in bold are being compared. Three passes will be required. First Pass: ( 5 1 4 2 8 ) ( 1 5 4 2 8 ) Here algorithm compares the first two elements and swaps since 5 > 1.