Part 3, Selection Flashcards

1
Q

what is a Boolean comparison

A

a Boolean comparison compares two values and reports/returns back either true or false

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

name three Boolean comparisons

A
  1. is equal to
  2. is less than
  3. is greater than
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is a compound condition

A

a compound condition is a condition which compares two or more separate conditions

then reports back true or false depending on the outcome of those individual conditions and the type of compound condition being used

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

name three types of compound conditions

A
  1. and ( {condition 1} and {condition 2} )
  2. or ( {condition 1} or {condition 2} )
  3. not ( not{condition 2} )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

you have used an “or” compound condition

what might you need to do in the following block of code

A

in this case we may need additional checks to find out which component of the compound condition was true

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

explain what a “mutually exclusive condition” is

A

a mutually exclusive condition is where only one outcome can ever be true out of a given set of events

example
3 = 3
so cannot be
3 < 3
or 
3 > 3
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is “sequential selection”

A

sequential selection is having a list of selections one after the other

example
if (x) {
    do y
}
if (x) {
    do y
}
if (x) {
    do y
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is “nested selection”

A

nested selection is where you have a selection within a selection

example:
if (x) {
    do y
    if (x) {
        do y
    }
}

nested selections will not run if there there parents condition did not allow the selections code to run

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

in what situation would nested selection be more efficient than sequential selection

A

when there is a case of a mutually exclusive condition then a nested selection would be more efficient

this is because only one of the selections can be true meaning a nested selection would make no further checks but a sequential selection would check anyway wasting resources

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

what four reasons are “flag variables” or “flags” used for

A

a flag variable is a variable that can be used to check if

  1. an event has taken place
  2. a condition was met
  3. having an event confirmed without having to make checks again later in the code
  4. checking an event did take place which can no longer be checked
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what two states will a flag variable have

A
  1. true

2. false

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

you see words such as “if”, “otherwise”, “depends”, “either”, “decide” in the specification

what do these words suggest you will need inside your program

A

words such as “if”, “otherwise”, “depends”, “either”, “decide” and any synonymous suggest that selection will be needed within your program

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

can you think of five words that suggest selection may be needed in your algorithm and program

A
  1. “if”
  2. “otherwise”,
  3. “depends”,
  4. “either”,
  5. “decide”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is a “boundary value”

A

a boundary value is a value that determines when the program should behave differently

example:
if (x = 5) {
do something
}

here 5 is the boundary value

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

what is “boundary testing”

A

boundary testing involves testing any boundary values that might exist

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

when boundary testing what three tests should be carried out

A
  1. test one value lower than the boundary value
  2. test the boundary value
  3. test one value higher than the boundary value
17
Q

why is boundary testing performed

A

the reason for boundary testing is to ensure that the expected code is ran for the boundary value and its surrounding values