Algorithms Flashcards

You may prefer our related Brainscape-certified 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 parts 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

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

What are algorithms?

A

Sets of instructions for solving a problem

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

What are the advantages of pseudo-code?

A

1) quick to write

2) can be easily converted into any programming language

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

How can algorithms be shown?

A

1) pseudo-code

2) flowcharts

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

What box is used to show the beginning and the end of an algorithm?

A

Boxes with rounded corners

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

What box is used to show anything that’s put into or taken out of the algorithm?

A

Parallelogram boxes

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

What box is used to show general instructions, processes and calculations?

A

Rectangular boxes

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

What box is used to show decisions, often a ‘yes’ or ‘no’ question?

A

Diamond boxes

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

What are subroutine boxes references to?

A

Other flowcharts

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

What do the arrows in flowcharts show?

A

The direction you should follow

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

What can flowcharts show?

A

1) sequences
2) selections
3) iterations

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

What type of lists are binary searches used for?

A

Ordered lists

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

How does a binary search algorithm work?

A

1) find the middle item in the ordered list
2) if this is the item you’re looking for, then stop the search - you’ve found it
3) if not, compare the item you’re looking for to the middle item. If it comes before the middle item, get rid of the second half of the list. If it comes after the middle item, get rid of the first half of the list
4) you’ll be left with a list that is half the size of the original list. Repeat steps 1 to 3 on the smaller list to get an even smaller one. Keep going until you find the item you’re looking for

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

What type of lists are linear searches used for?

A

1) ordered lists

2) unordered lists

17
Q

How does a linear search work?

A

A linear search checks each item of the list in turn to see if it’s the correct one. It stops when it either finds the item it’s looking for, or has checked every item

18
Q

What is the bubble sort algorithm used for?

A

To sort an unordered list of items

19
Q

How does a bubble sort algorithm work?

A

1) look at the first two items in the list
2) if they’re in the right order, you don’t have to do anything. If they’re in the wrong order, swap them
3) move on to the next pair of items (the 2nd and 3rd entries) and repeat step 2
4) repeat step 3 until you get to the end of the list - this is called one pass. The last item will now be in the correct place, so don’t include it in the pass
5) repeat steps 1 to 4 until there are no swaps in a pass

20
Q

What are the advantages of the bubble sort algorithm?

A

1) it’s a simple algorithm that can be easily implemented on a computer
2) it’s an efficient way to check if a list is already in order
3) doesn’t use much memory as all the sorting is done using the original list

21
Q

What are the disadvantages of the bubble sort algorithm?

A

1) it’s an inefficient way to sort a list

2) due to being inefficient, the bubble sort algorithm is pretty slow for very large lists of items

22
Q

How does the merge sort algorithm work?

A

1) split the list in half (the smaller lists are called sub-lists) - the second sub-list should start at the middle item
2) keep repeating step 1 on each sub-list until all the lists only contain one item
3) merge pairs of sub-lists so that each sub-list has twice as many items. Each time you merge sub-lists, sort the items into the right order
4) repeat step 3 until you’ve merged all the sub-lists together

23
Q

What are the advantages of the merge sort algorithm?

A

1) it’s much more efficient and quicker than the bubble sort algorithm for large lists, and has a similar running time for short lists
2) it has a very consistent running time regardless of how ordered the items in the original list are

24
Q

What are the disadvantages of the merge sort algorithm?

A

1) even if the list is already sorted it still goes through the whole splitting and merging process, so a bubble sort may be quicker in some cases
2) it uses more memory than the bubble sort because it has to create additional lists