Brute Force Algorithms
Brute force algorithms use pure computational power to try every possible option.
They are easier to code that other algorithms but it is slow and inefficient.
They are easier to code that other algorithms but it is slow and inefficient.
Brute force padlock activity
You will be given a combination padlock.
Your job is to crack the code! Password security check --> click HERE |
Online bubble sort activity
Test your understanding of the how the bubble sort works.
|
Linear search
We use computers to search for data all the time. The linear search is the simplest search algorithm. Linear means 'in a line'. The algorithm is given the search term and then, starting at the beginning, it compares the search term to the first item in the set of data. If the search term and the item match, the item has been found. If not, the algorithm looks at the next item in the data set, and so on, until the item is found or the end of the data set is reached.
A linear search can be efficient with a very small set of data but imagine searching through thousands or hundreds of thousands of items and what you are searching for being at the very end. Watch the Craig n Dave video and take notes into your book. |
|
One of the advantages of a linear search is that it is easy to code. A disadvantage is that it is slow and inefficient with a large set of data.
Merge sort - a divide and conquer algorithm
Watch the video and take notes.
The diagram below explains how the merge sort works.
Click on it for some interactive practice.
Binary search - a divide and conquer algorithm - ONLY WORKS ON SORTED DATA
Watch the video and take some notes.
Binary search
A much faster, more efficient search is the binary search. However, to perform a binary search the data must be sorted. Either alphabetically, if text, or low to high or high to low if numerical data. A binary search is much faster when using a large set of data.
Each time, the list is split in half and then the search starts again.
In the example above, 14 is the mid-point and 47 is the search value. Because 14 is less than 47 all the values from 14 and below are discarded. The new list is 23, 45, 47, 53. 45 is taken as the mid-point because the left-hand value is always taken if there is not a clear mid-point. 45 is less than 47 to 45 and all values lower than it in the list are discarded. Our new list is 47, 53. 47 is the new mid-point and the search value is found. |
|
Searching and sorting knowledge check
Cyber Security Task
Download a copy of the Powerpoint below. Watch the video on slide 2 and make notes in your book. Then add the notes to the Powerpoint. Add a relevant picture. Then repeat for all of the other slides.
|
Typing test for speed and accuracy |