Our site uses cookies. Some of the cookies we use are essential for parts of the site to operate and have already been set. You may delete and block all cookies from this site, but parts of the site will not work. To find out more about cookies on this website, see our Cookie Policy
Accept
© eRevision.uk and ZigZag Education 2025
This test is run by .
Note that your final mark will not be saved in the system.

Algorithms (2.1) GapFill

Target Level
4-5
Running Total
0
0%
Attempt
1 of 3

You must fill all the gaps before clicking ‘Check Answers!’

An algorithm is  a computer program that is used to solve a problemthe language used to create a computer programa series of steps that is used to solve a problema problem that can be solved by a computer program. There are many different types of algorithm, including searching and sorting algorithms. The following is an implementation of a linear search algorithm in pseudocode:

array numbers[5]
numbers[0] = 4
numbers[1] = 8
numbers[2] = 7
numbers[3] = 1
numbers[4] = 2
found = 
                
                
                 1TrueFalse0
x = 0
toFind = 
                
                
                 inputintfloatoutput("What number are you looking for?")
while NOT found AND numbers.length 
                
                
                 !=>==< x
    if numbers[x] 
                
                
                 !=<==> toFind then
        found = True
else
x = x + 1
    endif
endwhile
if found == True then
    print("That number is in the list")
                
                
                 elseif toFind == numbers[x]elseif x == 0elseelseif toFind == x
    print("That number is not in the list")
endif

The linear search algorithm checks every element in a list in the order that they appear until the element that is being searched for is found, or it reaches the end of the list. If the list is twice as long, searching using this technique will, on average, require twice as much time. To speed up searching, the  insertionmergebubblebinary search algorithm can be used instead. This algorithm checks the  firsthighestlastmiddle element of the list, and if the element being checked is not the same element that is being searched for, that element is discarded along with every element that comes before or after it in the list (depending on whether the element being checked is lower or higher than the element being searched for). This type of search can be significantly faster than a linear search, but can only be used if the list  has an even number of elementshas an odd number of elementsis sortedis unsorted.

Sorting algorithms can be used to rearrange the order of elements in a list. There are a number of sorting algorithms, including: the  mergebubbleinsertionbinary sort, which starts with a single element list and adds new elements one at a time to the correct place in the list; the  bubbleinsertionmergebinary sort, which splits the list into single elements and combines them into larger and larger sorted lists; and the  mergebinarybubbleinsertion sort, which goes along the list to check every pair of elements and swaps elements that are in the wrong order.

This is your 1st attempt! You get 3 marks for each one you get right. Good luck!

Pass Mark
72%