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 DocumentRight 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 DocumentRight 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
In a linear search, if the number of entries in the array is N , there will be N comparisons for an unsuccessful search. For a successful search, there will be a
Background image of page 5

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

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

This note was uploaded on 08/18/2011 for the course COMPUTER S CSC113 taught by Professor Shah during the Spring '09 term at King Saud University.

Page1 / 12

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

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online