decision 1 Flashcards
what are the steps of a bubble sort pass ?
- compare 1st and 2nd numbers and swap if 2nd is smaller
- compare second and 3rd ,swap if 3rd is smaller
- continue through the whole list and corner of the last value
steps of bubble sort
- if there is one number stop
- complete a pass comparing and swapping necessary
- if NO swaps have occurred stop
- otherwise ignore last element and follow though another pass
disadvantages of bubble sort
a lot more comparisons, a whole pass must occur without a swap to stop the process therefore there a plenty of excess and unnecessary swaps
how to find out the number of comparisons in bubble sort
(n-1)+(n-2)+(n-3)+….+3+2
or
n(n-1)/2
steps of shuttle sort
- corner off first 2 , then compare 1st and 2nd and swap if necessary
-then compare 2nd and 3rd swap if necessary. if swap occurs then compare 1st and 2nd. - compare 3rd and 4th and swap if necessary, if swap occurs continue.
if swap doesn’t occur move one to next pass
advantages of shuttle sort
same amount of swaps but less comparisons than bubble sort
what is the efficiency of an algorithm
the order is determined by the algorithm, commonly a quadratic function.
what is the first fit algorithm
place each object in turn in the first available space in which it will fit, commonly lings in bins or cut off from logs
what is a node ?
is a vertices which connects two arcs
what is a complete graph ?
a graph where each node is connected by precisely one arc to very other node
what is a bipartite graph ?
these graphs have two sets of nodes of which arcs only connect nodes from one set to the other and none connect them in the set.
what is an eulerian graph ?
is a connected graph which has a closed trail containing every arc exactly once. ie can be formed with one line without lifting a pen
eulerian graphs must have nodes of all even order
what is a semi eulerian graph
a not closedgraph which contains every arcs exactly once
has exactly 2 odd nodes
Steps of primms algorithm
- choose node
- choose shortest arc off said node
- choose next hottest arc ( don’t create a loop)
Number of arcs used in primms algorithm
N - 1