Searching Lesson Plan - 6. Contents  Evocation  Objective  Introduction  Sequential Search  Algorithm  Variations on sequential search  Mind map.

Slides:



Advertisements
Similar presentations
Lesson 8 Searching and Sorting Arrays 1CS 1 Lesson 8 -- John Cole.
Advertisements

Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Chapter 9: Searching, Sorting, and Algorithm Analysis
 Sort: arrange values into an order  Alphabetical  Ascending numeric  Descending numeric  Does come before or after “%”?  Two algorithms considered.
Copyright © 2012 Pearson Education, Inc. Chapter 8: Searching and Sorting Arrays.
Lesson Plan - 2: Bubble Sort, Quick Sort
Objectives Learn how to implement the sequential search algorithm Explore how to sort an array using the selection sort algorithm Learn how to implement.
Algorithm Efficiency and Sorting
Programming Logic and Design Fourth Edition, Comprehensive
Searching and Sorting Arrays
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 9 Searching.
CS 106 Introduction to Computer Science I 10 / 16 / 2006 Instructor: Michael Eckmann.
Describing algorithms in pseudo code To describe algorithms we need a language which is: – less formal than programming languages (implementation details.
Chapter 8 ARRAYS Continued
Searching Chapter 2.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 8: Searching and Sorting Arrays.
Chapter 16: Searching, Sorting, and the vector Type.
Copyright © 2012 Pearson Education, Inc. Chapter 8: Searching and Sorting Arrays.
Computer Science: A Structured Programming Approach Using C1 8-5 Sorting One of the most common applications in computer science is sorting—the process.
Lecture 5 Searching and Sorting Richard Gesick. The focus Searching - examining the contents of the array to see if an element exists within the array.
CHAPTER 09 Compiled by: Dr. Mohammad Omar Alhawarat Sorting & Searching.
Chapter 10 Strings, Searches, Sorts, and Modifications Midterm Review By Ben Razon AP Computer Science Period 3.
Data Structures & Algorithms CHAPTER 4 Searching Ms. Manal Al-Asmari.
SEARCHING UNIT II. Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances.
Chapter 8 Searching and Sorting Arrays Csc 125 Introduction to C++ Fall 2005.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 9 Searching Arrays.
Starting Out with C++, 3 rd Edition 1 Searching an Arrays.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 8: Searching and Sorting Arrays.
COMP102 Lab 121 COMP 102 Programming Fundamentals I Presented by : Timture Choi.
Chapter Searching and Sorting Arrays 8. Introduction to Search Algorithms 8.1.
CS 162 Intro to Programming II Searching 1. Data is stored in various structures – Typically it is organized on the type of data – Optimized for retrieval.
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Searching Course Lecture Slides 28 May 2010 “ Some things Man was never.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington ArraySet and Binary Search.
CSC 211 Data Structures Lecture 13
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Modified for use by MSU Dept. of Computer Science.
CHAPTER 8 SEARCHING CSEB324 DATA STRUCTURES & ALGORITHM.
Review 1 Arrays & Strings Array Array Elements Accessing array elements Declaring an array Initializing an array Two-dimensional Array Array of Structure.
Chapter 9 slide 1 Introduction to Search Algorithms Search: locate an item in a list (array, vector, table, etc.) of information Two algorithms (methods):
Searching Chapter 13 Objectives Upon completion you will be able to:
Searching & Sorting Programming 2. Searching Searching is the process of determining if a target item is present in a list of items, and locating it A.
Objectives At the end of the class, students are expected to be able to do the following: Understand the searching technique concept and the purpose of.
UNIT-III SORTING Lesson Plan-1 Insertion Sort, Selection Sort.
1 Searching and Sorting Searching algorithms with simple arrays Sorting algorithms with simple arrays –Selection Sort –Insertion Sort –Bubble Sort –Quick.
Chapter 9 Sorting. The efficiency of data handling can often be increased if the data are sorted according to some criteria of order. The first step is.
Searching and Sorting Searching: Sequential, Binary Sorting: Selection, Insertion, Shell.
Data Structures and Algorithms Searching Algorithms M. B. Fayek CUFE 2006.
Course Code #IDCGRF001-A 5.1: Searching and sorting concepts Programming Techniques.
CS212: DATASTRUCTURES Lecture 3: Searching 1. Lecture Contents  searching  Sequential search algorithm.  Binary search algorithm. 2.
1. Searching The basic characteristics of any searching algorithm is that searching should be efficient, it should have less number of computations involved.
Shell Sort. Invented by Donald Shell in 1959, the shell sort is the most efficient of the O(n²) class of sorting algorithms. Of course, the shell sort.
1 Applied Arrays Lists and Strings Chapter 12 2 Applying What You Learn Searching through arrays efficiently Sorting arrays Using character arrays as.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
 Introduction to Search Algorithms  Linear Search  Binary Search 9-2.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 8: Searching and Sorting Arrays.
329 3/30/98 CSE 143 Searching and Sorting [Sections 12.4, ]
Chapter 16: Searching, Sorting, and the vector Type.
Searching and Sorting Arrays
Lecture 14 Searching and Sorting Richard Gesick.
Introduction to Search Algorithms
Lesson Objectives Aims Understand the following “standard algorithms”:
Sorting Data are arranged according to their values.
Sorting Data are arranged according to their values.
Lecture 11 Searching and Sorting Richard Gesick.
Searching and Sorting Arrays
Standard Version of Starting Out with C++, 4th Edition
Searching and Sorting Arrays
Searching and Sorting Arrays
Principles of Computing – UFCFA3-30-1
Module 8 – Searching & Sorting Algorithms
Presentation transcript:

Searching Lesson Plan - 6

Contents  Evocation  Objective  Introduction  Sequential Search  Algorithm  Variations on sequential search  Mind map  Summary

ANNEXURE-I Evocation

Evocation

Objective  To learn the basics of sequential search algorithm  To understand about the variations on sequential search

ANNEXURE-II Introduction -Sequential Search  Searching is the process used to find location of target among a list of objects Example: Table of Employee Record  Two basic searches for arrays are sequential search and binary search  Sequential search is used to locate items in any array  Binary search requires an ordered list

Sequential Search  Sequential search is used whenever list is not ordered  Start searching for the target at the beginning of list and continue until it finds the target or hits at the end of list  Search algorithm requires four parameters List we are searching Index to last element in list Target Address where the found element’s index location is to be stored

Successful Search of Unordered List

Unsuccessful Search of Unordered List

Sequential Search Algorithm

ANNEXURE-III Yoga Breathing Mudra

Yoga Breathing Mudra Enhances effortless breathing while gently balances five chakras Place your fingers in this position Thumb, middle, little finger gently pressed together (palm to palm) Both index fingers move behind the middle finger (don’t strain) Right ring finger in front of left (increases inhale in 80% of people) Left ring finger in front of right (increase exhale in 80% of people) Whenever you inhale or exhale change the position of your ring finger Now allow yourself to breathe into your abdomen first with the breath flowing like a wave opening up your chest Allow your shoulders to remain relaxed. As you exhale, smile

Optical illusion Is the center square of stars standing still or moving?

Logo identification

Hidden Picture Puzzles

Variations on Sequential Search  Three useful variations in sequential search algorithm are Sentinel search Probability search Ordered list search Sentinel Search  Knuth states, when inner loop of program test two or more conditions, we should try to reduce testing to just one condition  Target is put in list by adding extra element at end of array and place the target in sentinel  Optimize the loop and determine after loop completes whether actual data found or sentinel

Variations on Sequential Search Probability Search  Data in array are arranged with most probable search elements at beginning of array and least probable at end  If probability ordering is correct over time, in each search exchange located element with element immediately before in array Ordered list search  Search ordered list sequentially, it is not necessary to search to end of list to determine the target is not in the list  Stop the target become less than or equal to current element we are testing

Sentinel Search Algorithm int find(int* a, int l, int v) { a[l] = v; // add sentinel value for (i = 0; ; i++) if (a[i] == v) { if (i == l) // sentinel value, not real result return -1; return i; }

Probability Search INPUT: list[] : reference of interger array last : index of last item target: target to be found ref_locn: reference to the location of target OUT: If target is found location of target is stored in ref_locn found = 1 is returned target is moved up in priority Else last is stored in ref_locn found = 0 is returned

Ordered List Search Algorithm OrderedListSearch(list, last, target, locn) if (target less than last element in list) find first element less than or equal to target set locn to index of element else set locn to last end if if (target in list) set found to true else set found to false end if return found end OrderedListSearch

Search Algorithm Advantages Easy algorithm to understand Array can be any order Easy to implement Can be used on very small data sets Not practical for searching large collections Disadvantage Inefficient (slow) for array of N elements, examine N/2 elements on average for value in array, N elements for value not in array

ANNEXURE-IV Mind Map Sequential Search Successful Search of Unordered list Unsuccessful Search of Unordered list Algorithm Variations of Sequential Search Sentinel Search Probability Search Ordered List Search

ANNEXURE-V Summary Searching is the process used to find location of target among a list of objects There are two basic methods for searching arrays: sequential search and binary search Sequential search is normally used when list is not sorted Starts at beginning of list and searches until it finds data or hits end of list

Summary In sentinel search, condition will end the search is reduced to only one by inserting target at end of list In probability search, list is sorted with most probable elements at beginning of list and least probable at end In order list search, it is not necessary to search to end of list to determine the target is not in the list