Iteration (Ch2) (M2) Flashcards

1
Q

What is iteration?

A

Iteration is the act of repeating a process until there is a desired result

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

When is iteration needed?

A

Iteration is needed when producing an algorithm because it means that you don’t have to write the same thing out lots of times - it makes code more efficient

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

What is definite iteration?

A

Definite iteration is where the number of iterations is known before the execution

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

What are the two examples of definite iteration?

A

Examples of definite iteration: FOR, IF

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

What do IF statements allow you to do?

A

IF statements allow you to check if a condition is true or false, and carry out different actions depending on the outcome.

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

What do nested IF statements allow you to do?

A

Nested IF statements allow you to check more conditions once you’ve established that the previous condition is true.

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

How are IF-ELSE-IF statements different from nested IF statements?

A

IF-ELSE-IF statements are different from nested IF statements as they only check more conditions if the previous condition is false.

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

What is a nested IF statement?

A

A nested IF statement is one IF statement inside of another one

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

What do FOR loops do?

A

FOR loops will repeat the code inside them a fixed number of times.

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

The number of times that a FOR loop repeats depends on what?

A

The number of times that the code repeats will depend on:

An intitial value, end value and the step count.

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

What is stepping used for in loops?

A

Stepping is used to move through a loop by different amounts

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

What is indefinite iteration?

A

Indefinite iteration is where the number of iterations isn’t known before the execution

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

Where are while loops controlled by a condition?

A

While loops are controlled by a condition at the start of the loop.

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

If the condition is false, what happens to the code inside of a while loop?

A

If the condition is false, the code inside a while loop is never run

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

If the condition is true, what happens to the code inside of a while loop?

A

If the condition is true, the code inside a while loop is always run

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

Where is the condition controlled in a DO UNTIL loop?

A

DO UNTIL loops are controlled by a condition at the end of the loop

17
Q

What is the difference between a WHILE and DO UNTIL loop?

A

The difference between a WHILE and DO … UNTIL loop is:

A DO … UNTIL loop does the comparison at the end of the block, but a WHILE loop does it at the start of the block.

18
Q

How many times at least, does a DO UNTIL loop run?

A

DO UNTIL loops always run the code inside them at least once

19
Q

If the condition is never true, what happens to the DO UNTIL loop?

A

If the condition is never true, the loop is infinite

20
Q

DO UNTIL loops continue until what?

A

DO UNTIL loops continue until the conditon is true

21
Q

What is a nested loop?

A

A nested loop is when at least one loop exists inside another loop

22
Q

What is a dry run?

A

A dry run is where the program is run on paper and is carefully analysed to fix any errors.

23
Q

What is a trace table?

A

A trace table is a table which shows the values of each variable, input and output and how they change. This is made while a dry run is being worked through.

24
Q

Trace tables make sure there are no type of what error?

A

Trace tables make sure there are no logic errors

25
Q

What do the columns and rows of a trace table usually represent?

A

The columns of a trace table usually represent variables. Each row of a trace table represents the values that the variables take at a particular point in the algorithm.

26
Q

If not variables, what can the columns of a trace table represent?

A

The columns of a trace table might not always be variables - they could be any information that the programmer is interested in.

27
Q

When testing a larger program, what will a tester often use?

A

When testing a larger program, the tester will often use debugging tools.

28
Q

What is a syntax?

A

A syntax is a set of rules

29
Q

What are syntax errors usually pointed out by?

A

Syntax errors are usually pointed out by the IDE

30
Q

What happens to programs with syntax errors?

A

Programs with syntax errors will not run

31
Q

Give one example of a syntax error

A

Examples of syntax errors include:

Wirteline instead of writeline
Missing bracket or speech mark
Forgetting to end an IF statement

32
Q

What is a logic error?

A

A logic error is a mistake in the code that causes it to perform in an unexpected way.

33
Q

What happens to programs with logic errors? Why is this a problem?

A

Programs with logic errors will still run. This makes logic errors hard to spot and makes them sometimes go unnoticed

34
Q

Give one example of a logic error

A

Examples of logic errors include:

Using and instead of or
Using > instead of >=
Forgetting to add VAT if calculating a total cost that should include VAT