1 - Fundamentals of Algorithms Flashcards

(39 cards)

1
Q

What is an algorithm?

A

A set of instructions that describes how to solve a problem

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

Name two methods can be used to design algorithms

A

Pseudo-code and flowcharts

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

When designing algorithms with pseudo-code or flowcharts, what is the main focus?

A

The logic of the steps rather than the programming language

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

Why is the focus on logic rather than programming language in algorithm design?

A

Because programmers should be able to translate an algorithm into any programming language

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

What does it mean for an algorithm to be language independent?

A

It means the algorithm can be translated into any programming language, such as from Python to C++

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

What is decomposition?

A

Breaking a problem down into smaller, more manageable chunks

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

Which method of computational thinking is being primarily used here?

num ← USERINPUT
FOR number ← 1 TO 10
OUTPUT number * num
ENDFOR

A

Decomposition (using a loop to make it smaller and more manageable)

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

What is abstraction in programming?

A

The process of removing unnecessary detail from a problem to focus on the important parts

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

Why is abstraction useful?

A

It makes solving a problem easier by focusing only on relevant information

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

What is algorithmic thinking?

A

A logical way of solving problems by breaking them into clear, step-by-step instructions (algorithms)

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

What is pseudo-code?

A

A simple way of describing a set of instructions that resembles a programming language

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

What does the symbol ← mean in pseudo-code?

A

It means assignment — storing a value in a variable.

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

What is a variable in pseudo-code?

A

A named space in memory where data, such as user input, can be stored (e.g. num)

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

How are outputs shown in pseudo-code?

A

Using the word OUTPUT followed by the data to be shown (e.g. OUTPUT number * 10)

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

How would this pseudo-code appear in python?:

OUTPUT number * 10

A

print(number * 10)

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

What does an arrow represent in a flowchart?

A

The flow of control or direction from one step to another

17
Q

What does a rectangle represent in a flowchart?

18
Q

What does a rectangle with double vertical lines represent in a flowchart?

A

A subroutine or function that is defined elsewhere

19
Q

What does a parallelogram represent in a flowchart?

20
Q

What does a diamond represent in a flowchart?

A

A decision point

21
Q

What does an oval represent in a flowchart?

A

The start or end of a flowchart

22
Q

What are inputs in a program?

A

Data entered into a program by the user or system, usually stored in variables

23
Q

Why are outputs used in a program?

A

To communicate with the user (eg. display results or show further instructions)

24
Q

What is a variable in programming?

A

A named location in memory used to store inputted data for use in the program

25
How does a program ask for a user’s name and store it in pseudo-code?
OUTPUT "Please enter your name:" name ← INPUT
26
What is concatenation in programming?
The process of joining strings together
27
What is this an example of?: OUTPUT "Hello" + name
Concatenation
28
What is a trace table?
A table used to record the changing values of variables as an algorithm runs
29
What are two examples of standard sorting algorithms?
Bubble sort and merge sort
30
What are two examples of searching algorithms?
Linear search and binary search
31
What is a linear search?
A search that checks each item in a list one by one until it finds the target or reaches the end
32
When is linear search typically used?
When the list is small or unsorted
33
What is a binary search?
A search that repeatedly divides a sorted list in half to find the target item
34
What is the key requirement for using binary search?
The data must be sorted in order
35
Why is binary search more efficient than linear search?
Because it eliminates half of the remaining data with each comparison
36
What is bubble sort?
A sorting algorithm that repeatedly compares and swaps adjacent items if they are in the wrong order
37
How does bubble sort work in each pass?
It moves the largest unsorted item to its correct position at the end
38
What makes merge sort more efficient than bubble sort?
It reduces the number of comparisons needed by sorting sublists and combining them efficiently
39
What is merge sort?
A divide-and-conquer sorting algorithm that splits the list into halves, sorts each half, and merges them back together