iGCSE Computer Science
  • Introduction
  • Past Papers
    • Set of 2019
    • Set of 2021
  • Pre-Exam Notes
    • Paper 1
    • Paper 2
  • Data Representation
    • 1.1 Number Systems
    • 1.2 Text, Sound & Images
    • 1.3 Data Storage & File Compression
  • Data Transmission
    • 2.1 Types & Methods of Data Transmission
    • 2.2 Methods of Error Detection
    • 2.3 Symmetric & Asymmetric Encryption
  • Hardware
    • 3.1 Computer Architecture
    • 3.2 Input & Output Devices
    • 3.3 Data Storage
    • 3.4 Network Hardware
  • Software
    • 4.1 Types of Software & Interrupts
    • 4.2 Types of Programming Languages, Translators & IDEs
  • The Internet & Its Uses
    • 5.1 The Internet & The World Wide Web
    • 5.2 Digital Currency
    • 5.3 Cyber Security
  • Automated & Emerging Technologies
    • 6.1 Automated Systems
    • 6.2 Robotics
    • 6.3 Artificial Intelligence
  • Databases (P2)
    • 9.1 Databases
  • Boolean Logic (P2)
    • 10.1 Logic Gates
  • Miscellaneous (P2)
    • Flowchart Symbols
    • Standard Methods of Solution
    • Validation & Verification
    • Identifying Errors
Powered by GitBook
On this page
  • Linear Search
  • Bubble Sort

Was this helpful?

  1. Miscellaneous (P2)

Standard Methods of Solution


Linear Search

This is a standard algorithm which is used to find element in an unordered list. The list is search sequentially and systematically one element at a time. It can be very time consuming.

OUTPUT “Enter a value to find”
INPUT Number
Found ← FALSE
Index ←1

REPEAT
  IF Number = Mylist[Index] 
          THEN
      Found ← TRUE
  ELSE
      Counter ← Counter + 1
  ENDIF
UNTIL Found =TRUE OR Counter > LENGTH(Mylist) 

IF Found = TRUE 
    THEN
        OUTPUT Number, “ found at position “, Counter
ELSE
    OUTPUT Number, “ not found”
ENDIF

Bubble Sort

This sorts items into order from the smallest to the largest by comparing element and swapping them around. It is very time consuming and not efficient. Below is an example of it.

Mylist ← [5, 9, 4, 2, 6, 7, 1, 2, 4, 3]

FirstElement ← 1
LastElement ← LENGTH(Mylist)

REPEAT
  Swap ← FALSE
  
  For Index ← FirstElement TO LastElement - 1
    IF Mylist[Index] > Mylist[Index + 1] 
      THEN
    Temp ← Mylist[Index]
      Mylist[Index] ← Mylist[Index + 1]
      Mylist[Index + 1] ← Temp
      Swap ← TRUE
    ENDIF
  
  NEXT Index
  LastElement ← LastElement - 1
UNTIL Swap = FALSE OR LastElement = 1

OUTPUT “Your sorted list is:”, Mylist

PreviousFlowchart SymbolsNextValidation & Verification

Last updated 7 months ago

Was this helpful?

COPYRIGHT -> SAVEMYEXAMS