section 4 algorithms Flashcards

1
Q

what is decomposition

A

breaking a complex problem down into smaller problems and solving each one individually

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

what is abstraction

A

picking out the important bits of information from the problem, ignoring the specific details that don’t matter

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

what is algorithmic thinking

A

a logical way of getting from the problem to the solution. If the steps you take to solve a problem follow an algorithm then they can be reused and adapted to solve similar problems in the future

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

what is pseudocode

A

not an actual programming language but is should follow a similar structure and read like one
it’s quick to write and can be easily converted

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

how do you use a binary search

A

1) find the middle item
2) if not the right item compare it with the middle item
3) if it comes before the middle item get rid of the second part and vise verses
4) you’ll be left with half the list and you repeat until you find the item

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

how do you use linear search

A

1) look at first item
2) if not the right item look at the next one in the list
3) continue until you find the item

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

linear Vs binary search

A
linear is simpler
binary is more efficient
linear can be used on any list
linear is mostly used on small lists
binary is mostly used on large lists
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how does bubble sort work

A

1) look at first two items
2) if they are in the wrong order swap them
3) repeat until you get to the end of the list(pass)
4) repeat until there are no swaps in a pass

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

advantages of bubble sort

A

simple
efficient way to check if the list is ordered
not much memory

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

disadvantages of bubble sort

A

inefficient way to sort a list

does not cope with large lists

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

how does merge sort work

A

1) split list in half
2) keep splitting until each sub list contains one item
3) merge pairs of sub lists and each time order it
4) repeat until you’ve merged all the sub lists

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

advantages of merge sort

A

more efficient than bubble and insertion

consistent running time

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

disadvantages of merge sort

A

slower on small lists
more memory
has to go through merging even if ordered

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

how does insertion sort work

A

1) look at second item
2) compare with items before and insert the number into the right place
3) repeat until last number has been inserted

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

advantages of insertion sort

A

intuitive way and can be easily coded
copes well with small lists
doesn’t require additional memory
quick at cheeking if in order

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

disadvantages of insertion sort

A

doesn’t cope with long lists