algorithms Flashcards
what are the three types of computational thinking and describe them
abstraction- ignoring the specific details deemed irrelevant to the task and only focusing on the important information involved
decomposition- the process of breaking a large problem down into a much smaller one, solving each one, one step at a time
algorithmic- solving the problem in a logical manner whilst taking the appropiate steps.
state the two searching algorithms
binary
linear
describe a linear search
the algorithm goes through each number on the list, determining whether or not its the number its looking for, untill it reaches the correct number
describe a binary search
the algorithm finds the midpoint of an ordered list. if the midpoint is not equal to the number its looking for, it discards one half of the list, dependant on whether or not the number its looking for is smaller or larger than the midpoint. this process of midpoint and discard continues until it has found the desired number
state the three types of algorithmic sorting
merge
bubble
insertion
describe how a merge sort works
the algorithm keeps halfing the list until it reaches singular values. once this has happened, it begins joining them up again, but this time comparing each value to determine its place in the list
describe how a bubble sort works
groups each value into pairs, comparing them and swapping them if necessary. Highest number always end up on the end of the list
describe how an insertion sort works
takes the second value of the list and then compares it to the last, determining whether or not to swap them. process continues until the list is completed. End up with two sections of the list: sorted and unsorted on the right
what is pseudocode
an informal coding language that cannot be used to code
give the flow diagram symbol for each of the following
- start/stop
- decision
- input/output
- process
- oval
- diamond
- parallelogram
- rectangle
pseudocode for a linear search
for item in dataset if item == target then return true endif endfor return false
pros of a binary search
-it’s more efficient than linear
cons of a binary search
-data set has to be ordered prior to programme running