D1 Flashcards
What is a bubble sort?
Comparing adjacent items in a list
Explain how to do a quick sort?
Split list in half, keeping order write numbers below and above, then repeat
Use (n+1)/2 and round up
Explain how to do a binary search?
1) Split ordered list in half ((n+1)/2 and round up)
2a) If T=m search is complete
2b) If Tm discard useless half and repeat until T is found
How do you find the maximum iterations needed for a binary search?
Use log2^n and round up
How do you find the lower bound for bin packing?
Sum of heights/bin heights and round up?
Explain first fit bin packing and advantage and disadvantage?
- take items in given order, starting with 1 bin go along list putting all items into first available bin
Advantage: quick
Disadvantage: unlikely to lead to a good solution
Explain first fit decreasing bin packing and advantage and disadvantage?
Same as first fit but order items largest to smallest first
A: good solution/easy to do
D: not optimal solution
Explain full bin packing and advantage and disadvantage?
Use observation to find combinations to fill a bun + pack these first
A: often good/optimal solution
D: difficult + takes a long time
When is the solution optimal for bin packing?
When no. of bins used = lower bound
What is a graph?
Vertices connects by edges
What is a weighted graph?
When the graph has numbers on each edge
What does Euclide algorithm find?
HCF
What is a subgraph?
Part of a graph (same vertices and edges)
What is a path?
Finite sequence of edges, no repeated vertices
What is a walk?
Sequence of edges, can return to vertices once only