{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ch11 - Chapter 11 Sorting and Searching Topics Searching...

This preview shows pages 1–6. Sign up to view the full content.

Chapter 11 Sorting and Searching

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Topics Searching Linear Binary Sorting Selection Sort Bubble Sort
Searching Searching an array or other data structure has two possible outcomes: Successful search (value found) Unsuccessful search (value not found) It is possible for one searching algorithm to perform very well for successful searches, and very poorly for unsuccessful searches.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Searching We will examine two searching algorithms: A linear search searches the array from the first index position to the last in a linear progression. This search is also known as a sequential search . If the values in an array are arranged in ascending or descending order, we can do a a binary search . The idea behind the binary search is to divide the array elements in half each time, until the particular element is located.
Linear Search In a linear search, if the number of entries in the array is N , there will be N comparisons for an unsuccessful search.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}