Section 4 - Algorithms Flashcards

1
Q

What are the three techniques for computational thinking?

A

Decomposition, algorithmic thinking, abstraction

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

What is decomposition?

A

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

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 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
5
Q

What is an algorithm?

A

A set of instructions for solving a problem, that can be in the from of pseudocode or flow charts

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

Advantages of pseudocode?

A
  • Quick to write

- Easy to convert into any programming language

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

What is the oval for in pseudocode?

A

Beginning/end

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

What is the parallelogram for in pseudocode?

A

Inputs/outputs

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

What is the rectangle for in pseudocode?

A

General instructions, processes and calculations

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

What is the diamond for in pseudocode?

A

Decisions

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

What is the rectangle with lines for in pseudocode?

A

Sub routines - reference to other flow diagrams

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

What is the arrow for in pseudocode?

A

Connecting boxes and showing direction

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

What is a sequence?

A

A set of instructions in a specific order

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

What is selection?

A

A section of code that is only run if certain conditions are met

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

What is iteration?

A

Repeating steps or instructions in a loop until certain conditions are met

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 list
  2. If this is what you are looking for, you’ve found it, stop
  3. If not, compare the middle item with the desired number. If it’s larger than the middle, get rid of the first half. If it’s smaller than the middle, get rid of the second half.
  4. Keep repeating until you find the item that you are looking for
17
Q

Disadvantages of a binary search?

A
  • Must be in an ordered list
18
Q

Different types of search algorithms?

A
  • Binary search

- Linear search

19
Q

Disadvantages of linear search?

A
  • Very slow as every value must be checked
20
Q

Advantages of linear search?

A
  • Can be done on an unordered list

- Simpler than a binary search

21
Q

How does a linear search work?

A
  1. Look at the first item in the list
  2. If this is the right item, stop.
  3. If not, look at the next item in the list
  4. Repeat step 2-3 until you have checked every item
22
Q

Types of sort algorithms?

A
  • Merge sort
  • Bubble sort
  • Insert sort
23
Q

Advantages of the bubble sort?

A
  • Simple algorithm that can be easily implemented

- Does not use much memory as sorting is done using the original list

24
Q

Disadvantages of the bubble sort?

A
  • Inefficient

- Does not cope with larger lists

25
Q

How does a bubble sort work?

A
  1. Look at the first two items in the list
  2. If they are in the wrong order, swap them
  3. Move onto the next pair and repeat step 2
  4. Repeat these until you get to the end of the list, this is called one pass
  5. Repeat until there are no swaps
26
Q

How does a merge sort work?

A
  1. Split the list in half
  2. Keep splitting each sub-list until each sub-list only has one item
  3. Merge pairs of sub-lists so each one has twice as many items
  4. Sort the items into the right order when you merge one
  5. Repeat until they are all merged together in the right order
27
Q

Advantages of the merge sort?

A
  • Efficient and quick for large lists

- Very consistent running time regardless of how they are originally ordered

28
Q

Disadvantages of the merge sort?

A
  • Slower than other algorithms for small lists
  • Even if the list is sorted, it goes through the process
  • Uses more memory because it creates separate files
29
Q

How does an insertion sort work?

A
  1. Look at the second item in the list
  2. Compare it to all items before it and insert the number into the right place.
  3. Repeat for all the values until they are in the correct place
30
Q

Advantages of insertion sort?

A
  • Can be easily coded
  • Copes well with small lists
  • Needs no additional memory as done on the original list
  • Quick to add items to an already ordered list
  • Quick at checking that a list is already sorted
31
Q

Disadvantage of insertion sort?

A
  • Not good with bigger lists