SlideShare a Scribd company logo
Standard Algorithms
Linear Search
 A linear search is a search through a list, comparing
 each item in the list with the search criteria

 A linear search returns the position of an item in a
 list, or an appropriate message if the item is not
 found.
Linear Search
Example 1:
Linear search for the number 6
Number 6 is in position 7

Example 2:
Linear search for the number 5
Number 5 is in position 2

Example 3:
Linear search for the number 10
Number 10 is not in the list
Linear Search
Algorithm:

Get search_item

REPEAT for all items in the list
  IF current_item = search_item THEN
        position = current_item_position
        EXIT LOOP
  END IF
END REPEAT

DISPLAY position
Counting Occurrences
Count occurrences of a particular item in a list

Example:
Count occurrences of the number 7
There are 3 occurrences
Counting Occurrences
Algorithm:

Get search_item
occurrences = 0

REPEAT for all items in the list
  IF current_item = search_item THEN
        occurrences = occurrences + 1
  END IF
END REPEAT

DISPLAY occurrences
Finding Maximum / Minimum
Find maximum or minimum number in a list

Example:
Find maximum number
The maximum is 13

Example:
Find minimum number
The minimum is 2
Finding Maximum / Minimum
Algorithm (Maximum)

maximum = 0

REPEAT for all items in the list
  IF current_item > maximum THEN
        maximum = current_item
  END IF
END REPEAT

DISPLAY maximum
Finding Maximum / Minimum
Algorithm (Minimum)

minimum = 999

REPEAT for all items in the list
  IF current_item < minimum THEN
         minimum = current_item
  END IF
END REPEAT

DISPLAY minimum

More Related Content

PPT
SD & D Standard Algorithms
PDF
Python list functions
PPTX
Data structure unit I part B
PDF
List Manipulation in FME
PPT
Searching algorithm
PPTX
Lists and loops
PPTX
Lists methods
SD & D Standard Algorithms
Python list functions
Data structure unit I part B
List Manipulation in FME
Searching algorithm
Lists and loops
Lists methods

What's hot (20)

PPTX
V19 join method-c
PPTX
Introduction to lists
PDF
Binary search algorithm
PPTX
Dictionaries
PPTX
poornima.coseq
PPTX
Searching linear &amp; binary search
PPTX
Data structure
PPTX
Rahat &amp; juhith
PPTX
Standard algorithms
PPTX
Binary search Algorithm
PPT
computer notes - Data Structures - 37
PPT
list procedures
PPTX
How to use Hlookup find an exact match
PPTX
366 it elective 4 (analysis of algoritm)
PPTX
Dsa – data structure and algorithms searching
PPTX
LINEAR SEARCH
DOCX
Ms excel formulas
PPTX
MS excel - match function
PPTX
Html web designing using lists
V19 join method-c
Introduction to lists
Binary search algorithm
Dictionaries
poornima.coseq
Searching linear &amp; binary search
Data structure
Rahat &amp; juhith
Standard algorithms
Binary search Algorithm
computer notes - Data Structures - 37
list procedures
How to use Hlookup find an exact match
366 it elective 4 (analysis of algoritm)
Dsa – data structure and algorithms searching
LINEAR SEARCH
Ms excel formulas
MS excel - match function
Html web designing using lists
Ad

Similar to Standard Algorithms (20)

PDF
searching
PPT
Introduction to Algorithm for computer engineering students
PDF
Linear search
PPTX
Searching & Algorithms IN DATA STRUCTURES
PDF
Searching Algorithm, Linear search algorithm and their time complexity
PDF
linear search and binary search
DOCX
Data Structures & Algorithms Coursework Assignment for Sem.docx
PPTX
Lecture_Oct26.pptx
PPT
CHAP 3 ALGORITHM for infomatique ingenieure .ppt
PPTX
Searching Techniques and Analysis
PPTX
SEARCHING
PPTX
Searching Algorithms - Foundations of Algorithms
PPTX
linear search o power point presentation
PPTX
linear search.pptxtttttttttttttttttttttt
PPTX
linear search.pptxtttttttttttttttttttttt
PPTX
data_structure_Chapter two_computer.pptx
PPTX
Chapter #3 (Searchinmmmg ALgorithm).pptx
PPT
Chapter 11 ds
PPTX
unit 2 First.pptx Searching - Linear and Binary Search
PPTX
Algorithm, Concepts in performance analysis
searching
Introduction to Algorithm for computer engineering students
Linear search
Searching & Algorithms IN DATA STRUCTURES
Searching Algorithm, Linear search algorithm and their time complexity
linear search and binary search
Data Structures & Algorithms Coursework Assignment for Sem.docx
Lecture_Oct26.pptx
CHAP 3 ALGORITHM for infomatique ingenieure .ppt
Searching Techniques and Analysis
SEARCHING
Searching Algorithms - Foundations of Algorithms
linear search o power point presentation
linear search.pptxtttttttttttttttttttttt
linear search.pptxtttttttttttttttttttttt
data_structure_Chapter two_computer.pptx
Chapter #3 (Searchinmmmg ALgorithm).pptx
Chapter 11 ds
unit 2 First.pptx Searching - Linear and Binary Search
Algorithm, Concepts in performance analysis
Ad

More from Forrester High School (20)

PPTX
Program Design
PPTX
Database Evaluation
PPTX
PPTX
Database Query Design
PPTX
Data Dictionary
PPTX
Compound Keys
PPTX
Entity Occurrence Diagrams
PPTX
Entity Relationship Diagrams
PPTX
Database Analysis
PPTX
Software Evaluation
PPTX
Software Testing
PPTX
Standard Algorithms
PPTX
File Handling
PPTX
Python Predefined Functions
PPTX
Python Substrings
PPTX
Variable Scope
PPTX
Sub-programs
PPTX
Records in Python
PPTX
Parallel arrays in python
Program Design
Database Evaluation
Database Query Design
Data Dictionary
Compound Keys
Entity Occurrence Diagrams
Entity Relationship Diagrams
Database Analysis
Software Evaluation
Software Testing
Standard Algorithms
File Handling
Python Predefined Functions
Python Substrings
Variable Scope
Sub-programs
Records in Python
Parallel arrays in python

Recently uploaded (20)

PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Pharma ospi slides which help in ospi learning
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Presentation on HIE in infants and its manifestations
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Microbial diseases, their pathogenesis and prophylaxis
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Complications of Minimal Access Surgery at WLH
Pharmacology of Heart Failure /Pharmacotherapy of CHF
VCE English Exam - Section C Student Revision Booklet
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Anesthesia in Laparoscopic Surgery in India
Pharma ospi slides which help in ospi learning
Microbial disease of the cardiovascular and lymphatic systems
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Chinmaya Tiranga quiz Grand Finale.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Module 4: Burden of Disease Tutorial Slides S2 2025
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Presentation on HIE in infants and its manifestations
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf

Standard Algorithms

  • 2. Linear Search  A linear search is a search through a list, comparing each item in the list with the search criteria  A linear search returns the position of an item in a list, or an appropriate message if the item is not found.
  • 3. Linear Search Example 1: Linear search for the number 6 Number 6 is in position 7 Example 2: Linear search for the number 5 Number 5 is in position 2 Example 3: Linear search for the number 10 Number 10 is not in the list
  • 4. Linear Search Algorithm: Get search_item REPEAT for all items in the list IF current_item = search_item THEN position = current_item_position EXIT LOOP END IF END REPEAT DISPLAY position
  • 5. Counting Occurrences Count occurrences of a particular item in a list Example: Count occurrences of the number 7 There are 3 occurrences
  • 6. Counting Occurrences Algorithm: Get search_item occurrences = 0 REPEAT for all items in the list IF current_item = search_item THEN occurrences = occurrences + 1 END IF END REPEAT DISPLAY occurrences
  • 7. Finding Maximum / Minimum Find maximum or minimum number in a list Example: Find maximum number The maximum is 13 Example: Find minimum number The minimum is 2
  • 8. Finding Maximum / Minimum Algorithm (Maximum) maximum = 0 REPEAT for all items in the list IF current_item > maximum THEN maximum = current_item END IF END REPEAT DISPLAY maximum
  • 9. Finding Maximum / Minimum Algorithm (Minimum) minimum = 999 REPEAT for all items in the list IF current_item < minimum THEN minimum = current_item END IF END REPEAT DISPLAY minimum