Topic 1 - Computational Thinking Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What does decomposition mean?

A

Breaking down into smaller parts.

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

What does abstraction mean?

A

The process of removing or hiding unnecessary details so that you can focus solely on the important points.

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

What’s an algorithm for?

A

It provides the precise instructions needed to solve a problem

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

What’s an algorithm?

A

A step-by-step procedure for solving a problem or carrying out a task.

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

What is a subprogram?

A

A self-contained block of code that performs a specific task within a larger program.

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

What subprograms are commonly used in high-level programming languages?

A
  • print()
  • len()
  • random.randint()
  • math.floor()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does abstraction allow?

A

Allows a programmer to specify what a subprogram must do without worrying about how it will work.

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

What are the uses of subprograms (6)?

A
  • breaking down a complex problem
  • make program logic clearer
  • make it easier to maintain code
  • enable code to be used as many times as needed within a program
  • enable code used for common tasks to be stored in libraries and reused in other programs
  • working together on a project
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can algorithms be displayed before being translated into program code?

A

As flowcharts.

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

How is a terminal presented in a flowchart?

A

An oval.

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

How is a decision/ selection presented in a flowchart?

A

A diamond.

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

How is a process presented in a flowchart?

A

A rectangle.

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

How is an input/ output presented in a flowchart?

A

A parallelogram.

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

How is subprogram presented in a flowchart?

A

A rectangle with margins on both sides.

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

What does a terminal do in a flowchart?

A

It shows the start and end of an algorithm.

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

What does a decision/ selection do in a flowchart?

A

Shows yes/no or true/false decisions where there are two possible outcomes.

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

What does a process do in a flowchart?

A

Shows data processing, e.g. a calculation.

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

What does an input/output do in a flowchart?

A

Shows when data is input into or output by the algorithm.

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

What does a subprogram do in a flowchart?

A

Shows a function or procedure that has its own flowchart.

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

What does a line do in a flowchart?

A

Shows that flow of the program.

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

What are the four programming constructs?

A
  • sequence
  • selection
  • repetition
  • iteration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What are programming constructs for?

A

To control the flow of a program.

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

What is selection used for?

A

To choose between two or more options.

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

How can selection be presented in python?

A
  • if
  • elif
  • else
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What is repetition?

A

The process of repeating a set of instructions until there is a desired outcome.

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

What is condition-controlled repetition?

A

When the number of times a loop is executed is not known before the loop is started.

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

What is count-controlled repetition?

A

When the number of times a loop is executed is known before the loop is started.

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

How is repetition represented in python?

A

while
for… in range()

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

What is iteration?

A

The process of repeating a set of instructions for each item in a data structure.

30
Q

What does the use of iteration require?

A

A data structure, for example a string, a one-dimensional data structure or a two-dimensional data structure.

31
Q

How is iteration presented in python?

A

for… in
for… in range()
while

32
Q

What are variables and constants used for in algorithms and programming?

A

To store values.

33
Q

What’s the difference between a variable and a constant?

A

A variable can change while a program is running.
A constant must not change while the program is running.

34
Q

How are variables named?

A

In camel case, where the first word is lower case.

35
Q

How are constants named?

A

In all upper case.

36
Q

What are identifiers?

A

Used in variables or constants to describe the information that’s being stored.

37
Q

What are assignments?

A

Variables and constants are given values using an assignment statement.

38
Q

What is an array?

A

A data structure that can store multiple data items, called elements, which are all of the same data type under the same identifier.

39
Q

How does an array improve a program?

A

It increases the efficiency because if they were not used a separate variable would have to be used, for each element.

40
Q

What is an element?

A

An item of data at a particular index.

41
Q

What is a record?

A

A collection of data objects. The objects can be of different data types.

42
Q

What are arithmetic operators used for?

A

To perform calculations in algorithms and programs.

43
Q

What are relational operators used for?

A

To compare different items of data.

44
Q

What are logical or boolean operators used for?

A

To combine statements or operands, which can be evaluated as true or false.

45
Q

What is a dry run?

A

A method used to investigate the functioning of an algorithm.

46
Q

What is a trace table used for?

A

To write down the values of each variable, input and output and how they change as the program is running.

47
Q

What is an error?

A

A bug in a program that prevents it from executing or causes it to produce an inaccurate or unexpected result.

48
Q

What’s a syntax error?

A

When the rules of the programming language aren’t followed

49
Q

What’s a runtime error?

A

They occur during program execution when the processor is asked to perform an impossible operation.

50
Q

What’s a logic error?

A

When there is a flaw in the design of a program, which doesn’t prevent it from running but causes it to produce an incorrect or unexpected result.

51
Q

How do you find a logic error?

A

check that:
- variables have been initialised correctly
- the right operator(s) have been used in expressions
- assignment statements are the right way around

52
Q

What do standard search algorithms include?

A

Linear and binary searches.

53
Q

What do standard search algorithms include?

A

Linear and binary searches.

54
Q

What is a linear search?

A

Sequential.

55
Q

What is a linear search an example of?

A

A brute force algorithm. It doesn’t use any specialist techniques, only raw computing power.

56
Q

What does a binary search do?

A

It compares the search item with the median item in a list, repeatedly splitting the list in half until the item is found or there are no more items left to search.

57
Q

What is required for a binary search to take place?

A

For the list to be sorted into ascending order, either numerically or alphabetically.

58
Q

How does a binary search work?

A

1) Selects the median
2) Compare it with the search item
3) If the search item is lower, discard the median and the higher items
4) If the search item is higher, discard the median and the lower items
5) Recalculate the new median
6) Repeat this process until the search item is found in the list

59
Q

What does the bubble sort algorithm do?

A

Compares adjacent data items and orders them. Several passes may be needed to sort the whole list.

60
Q

What does the merge sort algorithm do?

A

Breaks the list into its component parts and then builds it up again with them in the correct order.

61
Q

What factors does choosing an algorithm depend on?

A
  • type of data
  • whether it’s sorted already
  • the time available
  • if the program will be used again
62
Q

When would you choose a linear search algorithm?

A
  • An unsorted list
  • A short list
  • A list that is not going to be searched very often
63
Q

When would you choose a binary search algorithm?

A
  • A long list
  • A list that will be searched often
64
Q

What’s the advantage and disadvantage of linear search algorithms?

A

adv - simple
dis - brute force - tries out every possibility until a solution is found or all possibilities are exhausted

65
Q

What are the advantages of a binary search algorithm?

A
  • divide and conquer
  • execute quickly
66
Q

What are the disadvantages of a binary search algorithm?

A
  • initial list must be sorted
  • binary search algorithms are complex and use recursion
67
Q

When would you choose a bubble sort or a merge sort?

A

Bubble sort: a list with a smaller number of items.
Merge sort: a long list.

68
Q

What are the advantages of a bubble sort?

A
  • simple algorithm to code
  • no extra storage used to make copies of the data
69
Q

What are the disadvantage of a bubble sort?

A
  • brute force
  • longer lists use much more time to sort
70
Q

What are the advantages of a merge sort?

A
  • divide and conquer approach
  • longer lists add only a little bit more execution time
71
Q

What are the disadvantages of a merge sort?

A
  • uses additional memory for copies of lists
  • the splitting phase must happen, even for very short lists
  • complex algorithms, usually involving recursion