Standard Algorithms Flashcards Preview

CfE Higher Computing > Standard Algorithms > Flashcards

Flashcards in Standard Algorithms Deck (9)
Loading flashcards...

What are the four standard algorithms required at Higher?

Count Occurrence
Linear Search
Finding Minimum
Finding Maximum
(Input Validation)


Describe how a count occurrence works?

It uses a fixed loop to count how many times a certain value is repeated


Write a Linear Search Algorithm in pseudocode

Set up array
Set up value to look for
Set found to false
Loop until array is finished or found = true:
Compare current value of array to value
If they are the same:
Set found to true
Set location as position in array
Drop out of loop


Write a Count Occurrence Standard Algorithm in Python

array = [1, 4, 6, 8, 7, 4, 3, 4]
value = 4
count = 0
for i in range(8):
if array[i] = value
count = count + 1


Write a Finding Minimum Standard Algorithm in Python

array = [2, 3, 5, 4, 1, 8, 2]
minimum = array[0]
for i in range(7):
if array[i] < minimum:
minimum = array[i]


What changes would you have to make to a finding minimum algorithm to make it a finding maximum?

minimum variable name = maximum variable name
< would be swapped for >


Does a finding the maximum use a fixed loop or a conditional loop?

Fixed loop


How would you set up a record storing athlete as name, age, club, race, PB

RECORD athlete IS{STRING name, INTEGER age, STRING club, INTEGER race, REAL pb}


Is count occurrence a procedure or a function?

It is a function since it returns a VALUE (number of times a value repeats in the array)