3.1 - sort/searches Flashcards
what is a search algorithm used for?
finding a specific item of data within a data set
what is an effective search?
where the search will always find the solution/ target data
what is an efficient search?
a search that would find the solution quickly no matter its position in the data set
describe the concept of a linear search in terms of finding a piece of paper in a stack of paper
- work from top of stack to bottom
- check each paper along the way
state the pros and cons for linear search
pros - easier to code/implement
- list does not need to be sorted - little memory used to store data - good for small/medium sized lists
cons -> inefficient/slow on a long list
what is the phrase used to describe binary search? —— and ——
divide-and-conquer algorithm
describe the concept of a binary search in terms of finding a certain page in a book
- split book in two
- see whether page required is before/after split
- repeat on that side of the data set
describe the pros and cons of binary search
pros -> Faster than linear search on a large dataset
cons -> dataset must be sorted before starting
- more complicated to code
what does a sort algorithm do?
arranged a dataset in a particular order
pros and cons of bubble sort
Pros:
- Easy to code/write
- Does not use much memory
Cons:
- Poor for efficiency (very slow with large list)
pros and cons of merge sort
Pros:
- Faster sorting algorithm
- can easily sort longer lists of data
Cons:
- Can be slower for small lists.
- Needs additional memory.
- complicated to code
what kind of sort is merge sort?
- describe how it works
divide and conquer algorithm
- break large list into half, then pairs
- then sort out small pairs
- merge them together to one large list
how can you measure the efficiency of an algorithm?
- time it takes to run
- amount of space it uses on a computer
define a trace table
a technique used to analyse the output of an algorithm on paper
compare a binary and linear search
binary search - list has to be ordered
- more efficient
linear- search any array of data type (not ordered)