Topic 1: Computational thinking Flashcards

1
Q

Decomposition

A

breaking down problems and solutions into smaller parts

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

Abstraction

A

the process of removing or hiding unnecessary details (so you can focus on the important poins)

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

Algorithms

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

Reason for decomposing problems

A

to reduce the size of the problem

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

Subprogram

A

block of code that performs a specific task

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

Pre-existing subprograms in python

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

Subprograms are useful to:

A
  • break down a complex program into less complicated parts
  • make program logic clearer
  • make it easier to maintain code
  • code can be used as many times as needed, avoiding repetition
  • be stored in libraries and reuse them in other programs
  • enable a team of programmers to work together at the same time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

2 ways subprograms speeds up program development

A

1) the programmer can use pre-existing subprograms so that they can use them to perform common tasks
2) a group of programmers can work in different subprograms because different subprograms can be allocated to different programmers.

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

Algorithms : flowcharts

A

Be able to draw flowcharts

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

Algorithms: selection

A

used to choose between two or more options

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

Selection in flowcharts

A

Diamond symbol; has 2 output arrows, one for yes and the other for no.

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

Selection in python

A

If… elif… else… statement

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

Algorithms : 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
14
Q

2 types of repetition

A

Condition-controlled repetition
Count-controlled repetition

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

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

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

Condition controlled in python

A

while statement

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

Count- controlled in python

A

for…in range() statement

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

Reason why loops do not need dedicated symbol in flowcharts

A

In a selection symbol (rhombus), you can have an arrow pointing at the begining of the choice, therefore that creates autmatically a loop

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

Reason why loops do not need dedicated symbol in flowcharts

A

In a selection symbol (Diamond), you can have an arrow pointing at the begining of the choice, therefore that creates autmatically a loop

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

Algorithms: iteration

A

Repeating a set of instructions for every item in a data list.

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

2 features in a flowchart that indicate iteration is used

A
  • A data list
  • A backward pointing arrow to a selection symbol
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Arrays

A

data structure that can store multiple elements from the SAME DATA TYPE

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

2D arrays

A

[[…],[…],[…]]

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

Record

A
  • a collection of data objects
  • can be of DIFFERENT DATA TYPES
26
Q

How are elements called in a record

A

a field

27
Q

Arithmetic operators

A

used to perform calculations

28
Q

Relational operators

A

used to compare different items of data

29
Q

Examples of arithmetic operators:

A

+, -, *, /, %, // (returns integer part of division), **(exponentiation powers of)

30
Q

Examples of relational operators:

A

==, !=, <, <=, >, >=

31
Q

Difference between (%) and (//)

A

%(Modulus) returns the remainder after the division, whereas //(integer division) returns the integer part after division

32
Q

AND operator

A

Overall statement is true if ALL individual statements are true

33
Q

OR operator

A

Overall statement is true if ANY OF THE individual statements are true

34
Q

NOT operator

A

used to reverse the logical state

35
Q

TRACE TABLES

A

Page 12,13 R.Guide

36
Q

Types of errors that can be found in algorithms

A

Syntax error
Runtime error
Logic error

37
Q

Logic error

A
  • Hardest to detect
  • will produce an incorrect or unexpected result
38
Q

Linear search

A

it is sequential starting at the begining and moves through item by item

39
Q

Problem of linear search

A

Uses raw computing power
It is not an efficient method
- search starts at the begining
- until item found
- or reaches the end

40
Q

Describe in words an algorithm for carrying out a linear search (6 marks)

A

1) If the length of list is 0, stop
2) Start at the beginning of the list.
3) Compare the list item with the search criterion.
4) If they are the same, then stop.
5) If they are not the same, then move to the next item.
6) Repeat steps 3 to 5 until the end of the list is reached

41
Q

Binary search

A

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

42
Q

Describe the stages of applying binary search to find 17:
3,5,9,14,17,21,27,31,35,37,39,40,42

A

Step 1: The median is 27 but is higher than search item
Step 2: The sub-list to the left is used: 3,5,9,14,17,21
Step 3: The median is 9 but is too low. The sub-list 14,17,21 is used.
Step 4: The median is 17 which is the search item.

43
Q

Binary search requirement

A

needs to be sorted: alphabetically or numerically

44
Q

Bubble sort ———

A

Page 17 in revision guide

45
Q

Merge sort

A

is an algorithm that breaks a list into its components and then builds it up again IN the correct ORDER

46
Q

Describe how data is sorted into ascending order using the merge sort algorithm

A

The list is divided into two repeatedly
- until each list has only one item.
The lists are then progressively merged
- with the items in ascending order.

47
Q

Merge sort vs Bubble sort

A

For large numbers of items, a merge sort is far more efficient than a bubble sort as the problem is broken down into smaller and smaller problems, which are easier to solve

48
Q

Choose Linear search when:

A
  • unsorted list
  • a short list
  • a list that is not going to be searched very often
49
Q

Choose Binary search when:

A
  • a long list
  • a list that will be searched often
50
Q

Advantages of linear search:

A
  • Linear search algorithms are simple
51
Q

Advantages of Binary search:

A
  • Divide and conquer (breaks the list into smaller lists and performs the same operation on each).
  • Binary searches execute quickly
52
Q

Disadvantages of linear search:

A
  • Brute force (tries out every possibility until a solution is found or all possibilities are exhausted
53
Q

Disadvantages of binary search:

A
  • Initial list must be sorted
  • Binary search algorithms are complex and user recursion (that is, where a function calls itself).
54
Q

Choose bubble sort for:

A
  • a list with a smaller number of items
55
Q

Choose Merge sort for:

A
  • a long list
56
Q

Advantages of bubble sort:

A
  • A simple algorithm to code
  • No extra storage used to make copies of data.
57
Q

Advantages of merge sort:

A
  • Divide and conquer approach
  • Longer lists add only a little bit more execution time
58
Q

Disadvantages of bubble sort

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

Disadvantages of merge sort:

A
  • uses additional memory for copies of lists.
  • The splitting phase must happen, even for very short lists
  • Complex algorithm, usually involving recursion.
60
Q

Trace tables vs Truth tables

A

Truth tables are used for AND, OR, NOT whereas trace tables are used for showing how a program works.