Standard Methods of Solution


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.

COPYRIGHT -> SAVEMYEXAMS

Last updated