2.1 algorithms Flashcards

(10 cards)

1
Q

pros+cons of bubble sort

A

-efficient for small datasets
-easy to implement
~inefficient on large sets

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

pros+cons of insertion sort

A

-efficient on sorted sets
-easy to implement
~inefficient on randomly arranged datasets

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

pros+cons of merge

A

-efficient
~complex to implement

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

pros+cons of linear

A

-easy to implement
~inefficient
~slow

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

pros+cons of binary

A

-efficient
~needs to be ordered

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

how to perform a binary search

A

-order list
-add positions starting from 0
-find midpoint (highest-lowest)
-if target found, end and state this
-if lower than target, <= mid discarded
-if higher than target >= mid discarded
-explain the above steps
-repeat until found

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

how to perform linear search

A

-add positions from 0
-compare to target and state if found end program and state
-if not found increment position by 1
-repeat until found

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

insertion sort

A

-2 lists
-1 unordered, 1 ordered

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

merge sort

A

-divided 8,4,2,1
-2 ordered
-4 ordered
-8 ordered

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

bubble sort

A

-compares the adjacent values

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