decision 1 Flashcards

1
Q

what are the steps of a bubble sort pass ?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

steps of bubble sort

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

disadvantages of bubble sort

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how to find out the number of comparisons in bubble sort

A

(n-1)+(n-2)+(n-3)+….+3+2

or

n(n-1)/2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

steps of shuttle sort

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

advantages of shuttle sort

A

same amount of swaps but less comparisons than bubble sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the efficiency of an algorithm

A

the order is determined by the algorithm, commonly a quadratic function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is the first fit algorithm

A

place each object in turn in the first available space in which it will fit, commonly lings in bins or cut off from logs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is a node ?

A

is a vertices which connects two arcs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is a complete graph ?

A

a graph where each node is connected by precisely one arc to very other node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is a bipartite graph ?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is an eulerian graph ?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is a semi eulerian graph

A

a not closedgraph which contains every arcs exactly once

has exactly 2 odd nodes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Steps of primms algorithm

A
  • choose node
  • choose shortest arc off said node
  • choose next hottest arc ( don’t create a loop)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Number of arcs used in primms algorithm

A

N - 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does primms algorithm create

A

Creates a minimum spanning tree

17
Q

Steps of kruskal algorithm

A
  • choose shortest arc
  • choose next shortest arc
    ( don’t create a cycle)
18
Q

Steps of dijkstra

A
  • label first node 1 weight 0
  • add temporary label of possible weight
  • choose smallest temporary label and label node 2 with said weight
  • readjust temporary labels
  • repeat the step
19
Q

Other name for a route inspection algorithm

A

Chinese postman

20
Q

Steps of Chinese postman

A
  • find odd nodes
  • pair odd nodes
  • choose shortest pairs without causing a loop
  • add the two arcs to the network
  • fin the weight of the minimum spanning tree
21
Q

Steps is lower bound algorithm

A
  • choose node
  • consider the arcs and choose the 2 shortest arcs , calculate their weight
  • remove said node and find the minimum spanning tree ( kruskal )
  • sum the weight of the minimum spanning tree add the two removed arcs
22
Q

What is a planar graph ?

A

Graph with no crossing lines connecting nodes

23
Q

What is a tree ?

A

A non connected graph with no cycles

24
Q

Regions + nodes =

A

Arcs + 2

25
Q

Arcs + 2 =

A

Regions + nodes

26
Q

What is a tour improvement

A

An algorithm to make the shortest route going it e same nodes

27
Q

Steps of tour improvement algorithm

A
  • let I = 1
  • if d(vi, vi+2) + d(vi+1, vi+3 ) < d(vi+ vi+1) + d(vi+2, vi+3) then swap vi+1 and vi+2
  • replace I with I+1
  • if I < n repeat then steps
28
Q

What is a Hamiltonian cycle

A

A tour which contains every node precisely once

29
Q

Why does the traveling sales person find ?

A

A Hamiltonian cycle of minimum weight

30
Q

What is eulers relationship ?

A

R + n = a+ 2

31
Q

What is a drawback of dijkstra ?

A

It cannot be used if any of the weights are negative. For example they might gain a profit going down that route