Complexities Flashcards

1
Q

Counter

A

N complexity , especially if variable is the counter ( how many you want, x , 1 to x , Proportinsl to counter thus n complexity )

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

First fit / first fit decreasing
How to get there

A

N sqaured

  • count the comparisons needed each pass
  • using worse case scenario (which is Esch weight saturated as Box Esch time)
  • comparisons go 1,2 ,3 ,4

Hence triangle number = n2

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

Why is triangle numbers n2 complexity

A

1,2,3 is the sum of N
We know this is 1/2n (n+1)
However might be n-1 , hsve tk chekc the order of triangle numbers and compare

Alternatively find nth term, increase by 1 each time divide by 2 and sqaure, Compare etc..

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

Quick sort
Worse case

A

N2 , 1/n (n-1)
Worse case already / reverse ordered

Count final number of comparisons total and see this is one behind the 1/n (n+1) formula , therefore n-1

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

Bubble sort
Why

A

Again n2 , 1/n (n-1)

Worse case is if comoleltey unordered
Ad compariojs are always 1 less than sublist, 5,4,3,2,1 = triangle , and adjust

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

DIJKSRRA prims and Kruskal complexity

Function of?

A

N 2

Kruskal prims as a function of the number of edges

And DIJKSRRA as a function of nodded

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