{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
Chapter 11 Sorting and Searching
Background image of page 1

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

View Full Document Right Arrow Icon
Topics Searching Linear Binary Sorting Selection Sort Bubble Sort
Background image of page 2
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.
Background image of page 3

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

View Full Document Right Arrow Icon
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.
Background image of page 4
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.
Background image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}