Chapter 3 Network Algorithms : MST Kruskal And Prim Flashcards

1
Q

Why are kruskal and prims bith greedy and optimal

A

Greedy = dies everythign at once, no consideration to what may happen later, no strategy

However optimal both will ALWAYS GIVE THE BEST SOLUTION

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

How to do KRUSKAL algorithm

Remember ti record!

A

Need ti go for the SMALLEST WEIGTH EACH TIME, and shade it if it DOESNT CREATE A CYCLE

repeat and cross out the ones that do

Omce graoh becomes connected, your done !

HOWEVER YOU MUST RECORD EACH EDGE YOU CHOSE FIRST !

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

For keuskal how to record

A

Each time you pick you must record the weight

And also recird the ones you DONT pick by crossing them out

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

Remember a cycle can take a long route, be careful

Also what edges should you have when done

A

After done should have one less edge remember , thatdwhat trees have

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

How to do prims
Remember order

Remember state weight + rewrite diagram

A

1) PICK ANY POINT (but they will prob tel, you)
2) now pick the least arc going out, shade , record

3) now from thr same point, AND THE POINT YOU CINNECTED TO, check again for the
smaleest arc possible, that WONT CONNECT A CYCLE
- write this down

Keep on doing this and you’ll have your tree ready

4)
THE ORDER IS PARAMOUTN, without it examiner won’t know it’s prims

MST= x , redraw diagram

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

How can you tell if itd prims vs Kruskal

A

Prims kinda ‘prims’ all over from one point, whereas as Kruskal is just random

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

A MUCH easier way to think about prims

A

Instead of oh look at next corner

Just look at the next possible connection which doesn’t make a cycle, and out of them what’s the smallest

This way you don’t have to think too much

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

How to do PRIMS usinf incidence table?

A

1) pick a point , say A , to start from . Mark 1 on top and then DELETE THE WHOLE ROW
- deleting rows means you don’t create CYCLES
2) look down colomn and look for the SMALLEST WEIGHT
- identify, CIRCILE IT
- now record the connection (AD6) for example in the recording
3) now put a 2 abive the one you just connected to, and then DELETE ITS WHOLE ROW

Now look at both A and the colomn connected to, and find the smallest

Keep repeating until ALL ROWS ARE DELEGED

Mimics prims, find smallest weigth, delete row to avoid cycles, then look at both connectors to find the smallest new connection repeat

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

Remember when drawing your final MST, make it eesdied to see as possible

A

So don’t over,ps them, curve them if needed

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

What complexity is Kruskal and prims?

A

O (n2)

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

For Kruskal, do you have to show ALL that you crossed out or what

A

Only until you reach your FINAL ONE

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