Objectives - PowerPoint PPT Presentation

About This Presentation
Title:

Objectives

Description:

Chapter 13 Searching Objectives Upon completion you will be able to: Design and implement sequential searches Discuss the relative merits of different sequential searches – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 24
Provided by: ValuedGa378
Category:

less

Transcript and Presenter's Notes

Title: Objectives


1
Chapter 13
Searching
Objectives
  • Upon completion you will be able to
  • Design and implement sequential searches
  • Discuss the relative merits of different
    sequential searches
  • Design and implement binary searches
  • Design and implement hash-list searches
  • Discuss the merits of different collision
    resolution algorithms

2
13-1 List Searches
  • In this section we study searches that work with
    arrays. The two basic searches for arrays are the
    sequential search and the binary search.
  • Sequential Search
  • Variations on Sequential Searches
  • Binary Search
  • Analyzing Search Algorithms

3
Searching
  • The process used to find the location of a target
    among a list of objects.

4
List searches
  • Sequential search
  • Variations of sequential search
  • Sentinel search
  • Probability search
  • Ordered list search
  • Binary search

5
Sequential search
  • The sequential search is used whenever the list
    is not ordered.

6
Successful search of an unordered list
7
Unsuccessful search in unordered list
8
Sequential search algorithm
9
Variations on sequential searches
  • Sentinel search
  • Probability search
  • The data in the array are arranged with the most
    probable search elements at the beginning of the
    array and the least probable at the end.
  • Ordered list search

10
Sentinel search algorithm
11
Probability search algorithm
12
Ordered list search algorithm
13
Binary search
  • The list must be sorted.
  • The list starts to become large.
  • Contains more than 16 elements.
  • mid ?(begin end) / 2?

14
Binary search example
15
Unsuccessful binary search example
Figure 2-5
16
(No Transcript)
17
(continued)
18
Analyzing search algorithms
  • The efficiency of the sequential search is O(n).
  • The efficiency of the binary search is
  • O(log n).

List size Iterations Iterations
List size binary sequential
16 4 16
50 6 50
256 8 256
1000 10 1000
10000 14 10000
100000 17 100000
1000000 20 1000000
19
13-2 Search Implementations
  • Having discussed the basic concepts of array
    searches, we write C implementations of the two
    most common.
  • Sequential Search in C
  • Binary Search In C

20
Sequential Search in C
21
(No Transcript)
22
Binary Search In C
23
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com