Algorithms Flashcards
How many comparisons are required in the first pass of a bubble sort with (n) items
(n - 1) passes.
Name the three types of bin packing
First fit
First fit decreasing
Full bin
State the order of the bubble sort
Quadratic
If an sort has quadratic order, and takes 5 seconds to complete when it has 20 items, how long will it take when it has 30 items?
11.25 seconds
If the size of a problem is increased by some factor “k”, then an algorithm of linear order will take approximately…
“k” times as long to complete
If the size of a problem is increased by some factor “k”, then an algorithm of quadratic order will take approximately…
“k^2” times as long to complete
If the size of a problem is increased by some factor “k”, then an algorithm of cubic order will take approximate…
“k^3” times as long to complete
When two numbers compared in a bubble sort are equal, should you swap them or leave them?
Leave them
What is the rule for choosing the pivot value in the quick sort?
((n + 1) / 2) th value (rounding up)
Where should you put values equal to the pivot in the quick sort?
Values equal to the pivot can go to either side of the pivot - it is probably best to just leave them on their original side
What is a “walk” in graph theory?
A walk is a route through a graph along edges from one vertex to the next
What is a “path” in graph theory?
A path is a walk in which no vertex is visited more than once
What is a “trail” in graph theory?
A trail is a walk in which no edge is visited more than once
What is a “cycle” in graph theory?
A cycle is a walk in which the end vertex is the same as the start vertex and no other vertex is visited more than once
What is a “Hamiltonian cycle” in graph theory?
A Hamiltonian cycle is a cycle that includes every vertex