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
SET position TO 0
RECEIVE search_item FROM KEYBOARD
FOR EACH number FROM number_list DO
IF number = search_item THEN
SET position TO number_index
EXIT LOOP
END IF
END FOR EACH
IF position = 0 THEN
SEND “Number not found in list” TO DISPLAY
ELSE
SEND position TO DISPLAY
END IF
Counting Occurrences
Count occurrences of a particular item in a list
Example:
Count occurrences of the number 7
There are 3 occurrences
Counting Occurrences
RECEIVE search_item FROM KEYBOARD
SET occurrences TO 0
FOR EACH number FROM number_list DO
IF number = search_item THEN
SET occurrences TO occurrences + 1
END IF
END FOR EACH
SEND occurrences TO DISPLAY
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
SET maximum TO 0
FOR EACH number FROM number_list DO
IF number > maximum THEN
SET maximum TO number
END IF
END FOR EACH
SEND maximum TO DISPLAY
Finding Minimum
SET minimum TO 999
FOR EACH number FROM number_list DO
IF number < minimum THEN
SET minimum TO number
END IF
END FOR EACH
SEND minimum TO DISPLAY
Finding Minimum
SET minimum TO 999
FOR EACH number FROM number_list DO
IF number < minimum THEN
SET minimum TO number
END IF
END FOR EACH
SEND minimum TO DISPLAY

More Related Content

PDF
Standard Algorithms
PDF
Python list functions
PPT
Data Structure lec#2
PPTX
V19 join method-c
PDF
List Manipulation in FME
PPTX
Binary search Algorithm
PPTX
Bootcamp sql fundamentals bootcamp_part4
PPT
SD & D Implementation
Standard Algorithms
Python list functions
Data Structure lec#2
V19 join method-c
List Manipulation in FME
Binary search Algorithm
Bootcamp sql fundamentals bootcamp_part4
SD & D Implementation

Viewers also liked (13)

PPT
SD & D Maintenance
PPT
SD & D Variable Scope
PPT
String Handling
PPT
SD & D Design
PPT
SD & D Documentation
PPT
SD & D Testing
PPT
SD & D analysis
PPT
SD & D modularity
PPT
CASE Statements
PPT
SDD The Processor
PPT
Technical Implementation: Software
PPT
Virtual machines, emulators and mobile devices
PPT
SD & D Types of programming language
SD & D Maintenance
SD & D Variable Scope
String Handling
SD & D Design
SD & D Documentation
SD & D Testing
SD & D analysis
SD & D modularity
CASE Statements
SDD The Processor
Technical Implementation: Software
Virtual machines, emulators and mobile devices
SD & D Types of programming language
Ad

Similar to SD & D Standard Algorithms (20)

PPTX
Standard Algorithms
PPT
Chap10
PPT
1 D Arrays in C++
PPT
Searching in c language
PPT
Chapter 14
PPT
Searching Sorting
PDF
Searching
PDF
Linked lists
PPTX
Searching techniques
PPT
1 class linear and Binary search (3).ppt
PPT
Data Structures- Part3 arrays and searching algorithms
PPTX
Standard algorithms
PPTX
ADST university of Sussex foundation class
PDF
Searching and sorting by B kirron Reddi
PDF
Unit v data structure-converted
PPTX
Searching linear &amp; binary search
PPTX
Sorting and searching arrays binary search algorithm
PPTX
Dsa – data structure and algorithms searching
PPTX
Data Structures and Algorithms
PPTX
LIST IN PYTHON-PART 4[SEARCHING IN LIST]
Standard Algorithms
Chap10
1 D Arrays in C++
Searching in c language
Chapter 14
Searching Sorting
Searching
Linked lists
Searching techniques
1 class linear and Binary search (3).ppt
Data Structures- Part3 arrays and searching algorithms
Standard algorithms
ADST university of Sussex foundation class
Searching and sorting by B kirron Reddi
Unit v data structure-converted
Searching linear &amp; binary search
Sorting and searching arrays binary search algorithm
Dsa – data structure and algorithms searching
Data Structures and Algorithms
LIST IN PYTHON-PART 4[SEARCHING IN LIST]
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
File Handling
PPTX
Python Predefined Functions
PPTX
Python Substrings
PPTX
Variable Scope
PPTX
Sub-programs
PPTX
Records in Python
PPTX
Parallel arrays in python
PPT
SDD Predefined Functions
Program Design
Database Evaluation
Database Query Design
Data Dictionary
Compound Keys
Entity Occurrence Diagrams
Entity Relationship Diagrams
Database Analysis
Software Evaluation
Software Testing
File Handling
Python Predefined Functions
Python Substrings
Variable Scope
Sub-programs
Records in Python
Parallel arrays in python
SDD Predefined Functions

Recently uploaded (20)

PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
master seminar digital applications in india
PPTX
Institutional Correction lecture only . . .
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Lesson notes of climatology university.
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Pharma ospi slides which help in ospi learning
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Complications of Minimal Access Surgery at WLH
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Pre independence Education in Inndia.pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Computing-Curriculum for Schools in Ghana
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Cell Types and Its function , kingdom of life
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Abdominal Access Techniques with Prof. Dr. R K Mishra
master seminar digital applications in india
Institutional Correction lecture only . . .
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Lesson notes of climatology university.
Renaissance Architecture: A Journey from Faith to Humanism
Pharma ospi slides which help in ospi learning
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
RMMM.pdf make it easy to upload and study
Complications of Minimal Access Surgery at WLH
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Pre independence Education in Inndia.pdf
Basic Mud Logging Guide for educational purpose
O5-L3 Freight Transport Ops (International) V1.pdf
Computing-Curriculum for Schools in Ghana
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
human mycosis Human fungal infections are called human mycosis..pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Cell Types and Its function , kingdom of life

SD & D 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 SET position TO 0 RECEIVE search_item FROM KEYBOARD FOR EACH number FROM number_list DO IF number = search_item THEN SET position TO number_index EXIT LOOP END IF END FOR EACH IF position = 0 THEN SEND “Number not found in list” TO DISPLAY ELSE SEND position TO DISPLAY END IF
  • 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 RECEIVE search_item FROM KEYBOARD SET occurrences TO 0 FOR EACH number FROM number_list DO IF number = search_item THEN SET occurrences TO occurrences + 1 END IF END FOR EACH SEND occurrences TO DISPLAY
  • 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 SET maximum TO 0 FOR EACH number FROM number_list DO IF number > maximum THEN SET maximum TO number END IF END FOR EACH SEND maximum TO DISPLAY
  • 9. Finding Minimum SET minimum TO 999 FOR EACH number FROM number_list DO IF number < minimum THEN SET minimum TO number END IF END FOR EACH SEND minimum TO DISPLAY
  • 10. Finding Minimum SET minimum TO 999 FOR EACH number FROM number_list DO IF number < minimum THEN SET minimum TO number END IF END FOR EACH SEND minimum TO DISPLAY