H - Standard Algorithms

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Higher

Computing
Standard
Algorithms
The purpose of the Find Minimum algorithm are to look through a list of items and find the minimum

FIND MIN
value or position. It uses a variable to hold the current minimum value or position.

If a value is found that is lower than the current lowest value or position, then that new item is set to the
new lowest value or position.

Min Value

SQA RL Python
The purpose of the Find Minimum algorithm are to look through a list of items and find the minimum

FIND MIN
value or position. It uses a variable to hold the current minimum value or position.

If a value is found that is lower than the current lowest value or position, then that new item is set to the
new lowest value or position.

Min Position

SQA RL Python
The purpose of the Find Maximum algorithm are to look through a list of items and find the

FIND MAX
maximum value or position. It uses a variable to hold the current maximum value or position.

If a value is found that is higher than the current lowest value or position then that new item is
set to the new highest value or position.

Max Value

SQA RL Python
The purpose of the Find Maximum algorithm are to look through a list of items and find the

FIND MAX
maximum value or position. It uses a variable to hold the current maximum value or position.

If a value is found that is higher than the current lowest value or position then that new item is
set to the new highest value or position.

Max Position

SQA RL Python
LINEAR The Linear Search algorithm looks through a list of items and finds if a value is in the list. It checks
every item in the list and compares it to the search item. After the algorithm has traversed the

SEARCH
entire list then it will usually display an output message. You have to bear in mind that a match
MAY NOT be found.

Basic Search

SQA RL Python
LINEAR The Linear Search algorithm looks through a list of items and finds if a value is in the list. It checks
every item in the list and compares it to the search item. After the algorithm has traversed the

SEARCH
entire list then it will usually display an output message. You have to bear in mind that a match
MAY NOT be found.

With Found Flag

SQA RL Python
A further improvement would be to utilise a conditional loop and a found flag. This will allow the algorithm to stop

LINEAR SEARCH traversing through the loop when a match has been found.

The condition will to be continue the loop until either an item has been found or there are still items in the list.
Using a Conditional Loop Meaning for more efficient code due to less operations required…unless the search item is at the end of the list.

SQA RL Python
COUNT
The counting occurrences algorithm looks through a list of items and counts the number of times (occurrences)
that a match is found. It again checks every item in the list and increments a counter when a match is found.

OCCURENCE It is important to only output the amount of matches after the entire list has been traversed. The algorithm is just a
basic linear search but using a variable to keep a running total when a particular condition is met.

SQA RL Python

You might also like