Chapter 9
Chapter 9
CHAPTER 9
LIST
PROCESSING :SEARCHI
NG AND SORTING
PROPRIETARY MATERIAL © 2018 The McGraw Hill Education, Inc. All rights reserved. No part of this PowerPoint slide may be displayed, reproduced
or distributed in any form or by any means, without the prior written permission of the publisher, or used beyond the limited distribution to teachers
and educators permitted by McGraw Hill for their individual course preparation. If you are a student using this PowerPoint slide, you are using it
without permission.
Introduction to Searching Techniques
Searching is a technique of finding an element from
a given list of elements.
Element is 1 N
present in the
list
Element is not N N N
present in the
List
Sorted List – Analysis of Sequential
Search
Expected number of comparisons required for
unsuccessful search can be reduced if the list is
sorted.
Example:
List1[] = 10 15 20 25 50 60 70 80
Element to be searched = 30
Search should terminate here
Element is 1 N
present in the
list
Element is not 1 N
present in the
List
The Binary Search
Iteration 1:
Search the smallest element from list[0] to list[N-1].
Interchange list[0] with smallest element.
Result: list[0] is sorted.
Iteration 2:
Search the smallest element from list[1] to list[N-1].
Interchange list[1] with smallest element.
Result: list[0],list[1] is sorted.
Iteration N-1:
Search the smallest element from list[N-1] to list[N-1].
Interchange list[N-1] with smallest element.
Result: list[0]…………list[N-1].
Insertion Sort
Insertion sort is based on the principle of
inserting the elements at its correct place in a
previously sorted list.
It always maintains a sorted sublist in the lower
portion of the list.
Each new element is inserted back into the
previous sub list.
Quick Sort
Quick sort in one of the fastest internal sorting
algorithms. The quick sort algorithm is based on three
main strategies.