Fundamentals of Algorithms Flashcards

(50 cards)

1
Q

Algorithm

A

An algorithm is a series of steps that are carried out in order to complete a task

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

What is computational thinking?

A

Computational thinking is a systematic approach to solving problems

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

Abstraction

A

The process of ignoring the unnecessary detail in a problem to make it easier to understand.

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

Decomposition

A

The process of breaking large problems into smaller, more manageable sub-problems.

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

How is decomposition most commonly represented?

A

In a structure chart

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

What are the 4 stages in the program development life cycle?

A

-Analysis
- Design
- Coding
- Testing

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

Computer System

A

The combination of physical components that make up a computer

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

Flowchart

A

A visual representation of an algorithm. Shows the flow of data and instructions.

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

What does the oval represent in a standard flowchart?

A

The start or end of an algorithm

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

What does a parallelogram mean in a flowchart?

A

An input or output

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

What does a rectangle represent in a flowchart?

A

A process

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

What does a diamond represent in a flowchart?

A

A decision

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

Pseudocode

A

A text-based method of representing algorithms - a simplified form of programming code.

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

What are the 3 basic programming constructs?

A
  • Sequence
  • Iteration
  • Selection
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Sequence

A

The order in which steps need to happen

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

Selection

A

Allows the program to follow different paths based on certain conditions
eg) IF statements

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

Nested Selections Statement

A

Where one or more IF statements are within another selection statement

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

How many options can you choose between if you have an IF…THEN…ELSE statement?

A

Two options

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

Which selection statement allows you to choose how many options there are to choose from?

A

IF… ELSE IF

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

Iteration

A

Allows parts of the program to repeat until a condition is satisfied
eg) Loops

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

Definite iteration

A

A group of steps are executed a specific number of times

22
Q

Indefinite iteration

A

The section of code will repeat until a condition is satisfied.
The number of repeats can differ with different inputs.

23
Q

What type of iteration is a FOR…ENDFOR loop?

A

Definite iteration

24
Q

What type of iteration is a REPEAT…UNTIL loop?

A

Indefinite iteration

25
What type of iteration is a WHILE…ENDWHILE loop?
Indefinite iteration
26
Condition Controlled
Another term for indefinite iteration - where there isn’t a set number of loop repeats
27
Where in the loop is the condition tested in a REPEAT…UNTIL loop?
The condition is tested at the end of the loop
28
How many times will a REPEAT…UNTIL loop run for?
At least once, but an indefinite number of times
29
Where in the loop is the condition tested in a WHILE…ENDWHILE loop?
At the start of the loop
30
How many times will a WHILE…ENDWHILE loop run?
An indefinite number of times, zero or more
31
Linear Search
An algorithm that involves checking each item in a list (or sequence of data) one at a time to see if it’s the right item
32
Give the algorithm for a linear search
1) Take a list of data and the search item 2) Repeat steps a-c, starting from the first item in the list, until you find the search item or reach the end of the list a) Compare the item at the current position to the search item b) If the item at the current position is equal to the search item, then stop searching c) Otherwise, go to the next item in the list
33
Search item
The item that you’re trying to find (searching for) in a data set
34
Best-Case Scenario
When you find the search item in the least possible amount of steps
35
Worst-Case Scenario
When you find the search item in the greatest possible number of steps
36
Binary Search
An algorithm that searches a sorted list for a value by repeatedly splitting the list in half
37
What would be the worst-case scenario in a linear search?
When the item you’re looking for is the last one in the list, or not in the list at all
38
What is the only type of list that a binary search will work on?
An ordered list, from smallest to largest
39
Which is more efficient: a binary search or a linear search?
A binary search
40
Why is a binary search so efficient?
With each comparison, a binary search eliminates half of the data
41
Bubble Sort
A sorting algorithm that works by repeatedly going through a list of data, comparing adjacent items and swapping them (where needed) to put them in the correct order
42
What does a single pass of a bubble sort always achieve?
Putting the greatest value at the end of the list, as it will always be greater than the value it’s being compared to
43
Merge Sort
A sorting algorithm that sorts data into an organised list by splitting the list into smaller sections and organising each section.
44
Explain the algorithm for the first pass of a merge sort
- The full list of data is split into individual groups of one - These groups are merged into groups of two - Within pairs, items are compared - If the items are in the wrong order, they will be swapped
45
Explain the algorithm for a full merge sort
- List is split into individual items - Items are grouped in pairs - Items in pairs are compared and, where necessary, swapped - Pairs join onto another pair, forming a larger group - These groups are then organised/ordered - This process repeats until the whole list is put in order
46
What are the benefits of a merge sort?
It’s fast and efficient
47
What are the advantages of a bubble sort?
- Requires less space in memory than a merge sort - Relatively simple to implement
48
What are the negatives of a merge sort?
- Requires additional space in memory - More complex to implement
49
What are the disadvantages to using a bubble sort?
It’s slow and inefficient
50
Why does a Merge Sort take up more space in memory than a Bubble Sort?
It creates additional lists