Note that your final mark will not be saved in the system.
Fundamentals of Algorithms GapFill
You must fill all the gaps before clicking ‘Check Answers!’
An algorithm is . Two key terms are used to define algorithms; is the process of breaking down a problem into identifiable tasks and abstraction is a way to to solve the problem.
There are many different types of algorithm, including searching and sorting algorithms. The following is an implementation of a linear search algorithm:
numbers ← [4,8,7,1,2]
found ←
toFind ←
index ← 0
WHILE found = False AND index LEN(numbers)
IF numbers[index]=toFind THEN
found ← True
PRINT('That number is in the list')
ELSE
index ←
ENDIF
ENDWHILE
IF found=False THEN
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 search algorithm can be used instead. This algorithm checks the 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 .
Sorting algorithms can be used to rearrange the order of elements in a list. There are a number of sorting algorithms which include the sort splits the list into single elements and combines them into larger and larger sorted lists; and the sort, which goes along the list to check every pair of elements and swaps elements that are in the wrong order. For sets of data the merge sort is much more efficient than the bubble sort.