3.1 Algorithms Flashcards

1
Q

What is an algorithm?

A

A set of instructions to complete a task

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

What is decomposition?

A

Breaking down a problem into sub problems until each sub problem can be solved seperately

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

What is abstraction

A

Picking out the important details to focus on first

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

What is Pseudo code and its benefits?

A

. Pseudo code is a way of writing code in plain english
. Pseudo code is easy to understand
. Pseudo code can easily be translated to real code

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

What are terminators in a flowchart and what shape does it represent?

A

. A start or an end
. An oval

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

What is an input/output in flowcharts and what shape does it represent?

A

. Where the flowchart is taking or outputting information
. A parallelogram

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

What is a decision block in flowcharts and what shape represents it?

A

. A decision is selection and leads to multiple paths
. A diamond

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

What shape represents a process?

A

A rectangle

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

What is this symbol <?

A

Smaller than

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

What is this symbol <=?

A

Smaller than or equal to

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

What is this symbol >?

A

Greater than

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

What is this symbol >=?

A

Greater than or equal to

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

What is this symbol =?

A

Equal to

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

What is this symbol <>?

A

Not equal to

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

What is this symbol +?

A

Add

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

What is this symbol -?

A

Subtract

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

What is this symbol *?

A

Asterix
Multiply

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

What is this symbol /?

A

Divide

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

What is this symbol ^?

A

Indices (it’s called a carrot)

20
Q

What is IF ELSE?

A

. A form of selection
. If a condition is met, this code will run if not this code will run

21
Q

What is USERINPUT?

A

What the User types in

22
Q

What is OUTPUT?

A

What the computer types on the screen

23
Q

What is FOR?

A

. Definite iteration
. Repeats code a certain amount of times

24
Q

What is WHILE?

A

. Indefinite iteration
. Repeats code until a condition is met
. Checks if the condition is met at the start

25
Q

What is REPEAT UNTIL?

A

. Indefinite iteration
. Repeats code until a condition is met
. Checks the condition after the code is executed

26
Q

What is nested iteration?

A

an iteration statement inside a body of another iteration statement

27
Q

What is INT_TO_STRING?

A

. Casting
. Used in Pseudo code
. Changing the data type from integer to string

28
Q

What is STRING_TO_INT

A

. Casting
. Used in Pseudo code
. Changing the data type of a string to an integer

29
Q

What is DIV?

A

. Integer division
. Only returns integer
. 10 DIV 3 = 3

30
Q

What is MOD?

A

. Remainder division
. Only gives remainder
. 10 MOD 3 = 1
. 0 MOD 5 = 5
. 6 MOD 50 = 6

31
Q

What is an integer?

A

A whole number

32
Q

What is a real/float?

A

A number with a fractional value

33
Q

What is a string?

A

A sequence of characters

34
Q

What is a character?

A

●One character is one letter or one digit or one special character
●Any press on the keyboard

35
Q

What is a Boolean

A

True or False

36
Q

What is a binary search and its Pros and Cons?

A

A binary search finds the midpoint of a list in ascending order and checks if the value it is looking for is in that half or not and then deletes half of the values

PRO: It is more efficient than a linear search
CON: It has to be in order (e.g
numerical or alphabetical)

37
Q

How is the middle number found in a binary search?

A

(Lowest position + highest position) DIV 2

38
Q

what is a linear search?

A

. Searches one at a time
. Works in any list
. It isn’t very efficient

39
Q

How to find out the maximum number of searches needed in a binary search?

A

. 2^n + 1
. You need to find the power of 2 that is closest to the amount of items in the list that is not above the amount of items in the list

40
Q

What is a bubble sort?

A

. It checks the first 2 numbers if the second one is smaller it swaps otherwise it doesn’t swap
. On the first pass the largest number is put at the end
. On the second pass the second largest number is put at the 2nd to last spot
. This repeats until it is sorted

41
Q

How to work out the maximum amount of passes in a bubble sort

A

(amount of items in the list) - 1

42
Q

How are 2 lists merged?

A

. Checks the first number from each list
. The smaller one is put first
. Checks the second number from the list that you put in the ordered list with the first from the other list
. Repeats until the lists are merged

43
Q

What is a merge sort?

A

. Splits a list in half until there is each item is separate from the others
. merges the items back together in order

44
Q

advantages and disadvantages of a merge sort?

A

. Faster on longer lists
. Slower in shorter lists
. Uses more memory

45
Q

What is the point of a merge sort or a bubble sort?

A

To put the items in order so you can do a binary search on it.