3.1 Fundamentals of algorithms Flashcards

1
Q

Define algorithm

A

An algorithm is a sequence of steps that can be followed to complete a task.

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

Define decomposition

A

Decomposition means breaking a problem into a number of sub-problems, so that each sub-problem accomplishes an identifiable task, which might itself be further subdivided.

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

Define abstraction

A

Abstraction is the process of removing unnecessary detail from a problem.

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

What command boxes are used in flowcharts?

A
  • Start/Stop
  • Input/Output
  • Processes
  • Decision
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What shape is a start/stop command box?

A

Rectangle with rounded corners

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

What shape is an input/output command box?

A

Parallelogram

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

What shape is a process command box?

A

Rectangle

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

What shape is a decision command box?

A

Diamond

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

When is the start/stop command box used?

A

The beginning and the end of the algorithm

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

When is the input/output command box used?

A

When anything is put into or taken out of the algorithm

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

When is the process command box used?

A

When there are general instructions, processes and calculations

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

When is the decision command box used?

A

When there are decisions (often a yes or no question)

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

Define sequence

A

A set of instructions in order

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

Define iteration

A

Involves repeating actions

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

Define selection

A

Involves a choice

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

How does a binary search 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 as you have found the item
3- If not, compare the item your looking for to the middle item. If it comes before the middle item, get rid of the second half of the list (and vice versa)
4- You’ll be left with a list that is half the size of the original list. Repeat steps 1 to 3 on this smaller list to get an even smaller one. Keep going until you find the item you’re looking for.

17
Q

What is the positive of binary search?

18
Q

What is the negative of binary search?

A
  • Data must be sorted
19
Q

How does a linear search work?

A

1- Look at the first item in the unordered list
2- If this is the item you’re looking for, then stop the search as you have found the item
3- If not, then look at the next item in the list
4- Repeat steps 2 to 3 until you find the item that you’re looking for or you’ve checked every item

20
Q

What is the positive of linear search?

A
  • Can be performed on unsorted data
21
Q

What is the negative of linear search?

A
  • Inefficient
22
Q

How does bubble sort work?

A

1- Look at the first 2 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 (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 next pass
5- Repeat steps 1 to 4 until there are no swaps in a pass.

23
Q

What is the positive of bubble sort?

A
  • Doesn’t use a lot of memory as all the sorting is done using the original list
24
Q

What is the negative of bubble sort?

A
  • Inefficient on large sets of data
25
What methods of searching algorithms are there?
- Binary search - Linear search
26
What methods of sorting algorithms are there?
- Merge sort - Bubble sort
27
How does merge sort work?
1- Split the list in half (creating sub-lists) 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 have merged all the sub-lists together
28
What is the positive of merge sort?
- Very efficient on large amounts of data
29
What is the negative of bubble sort?
- Takes up a lot of memory as it has to create additional lists