algorithms Flashcards
What is an algorithm?
An algorithm is a sequence of steps which can be followed to complete a task.
Explain the term decomposition?
Decomposition is when a problem is broken down into multiple smaller problems, so that each smaller problem accomplishes an identifiable task.
What is abstraction?
It is the process of removing unnecessary detail from a problem.
What is a linear search?
A linear search will check each item in the array from the start until it has found the item.
Describe a binary search?
In a binary search the item in the middle will be checked first.
If that isn’t the item, it it will decide if the item is smaller or greater.
Finally, it will discard half of the items and check the middle item again until is has been found.
It only works on data that is sorted in an order.
What is sorting data?
It is when data is put into an order.
Usually numerical or alphabetical, ascending or descending.
What is a bubble sort algorithm?
Each item in the list is compared to the one next to it. If the item is greater then they swap places.
After one full pass the largest item will be at the end of the list.
This is repeated until the whole list is in order.
Pro and con of bubble sort algorithms.
They are not very efficient for sorting items of data.
Easier to write and are still effective when number of items isn’t too large.
What is a merge sort algorithm?
It divides the unsorted list into sublists, with each one containing one element.
Continually merge two sublists together to make one sublist until there is only one sorted list left.
pro and con of merge sort algorithms.
Merge sort algorithms are much more efficient.
However they require more memory to store the sublists.