3 - Booleans and selection Flashcards
How does the Conjunction operator work in the boolean ADT?
The Conjunction operator (AND) in the boolean ADT returns “true” if both operands are “true,” otherwise it returns “false.” It is left associative and has the second highest precedence among logical operators.
What is the behavior of the Disjunction operator in the boolean ADT?
The Disjunction operator (OR) in the boolean ADT returns “false” if both operands are “false,” otherwise it returns “true.” It is left associative and has the lowest precedence among logical operators.
How does the Negation operator function in the boolean ADT?
The Negation operator (NOT) in the boolean ADT returns “false” if the operand is “true,” and it returns “true” if the operand is “false.” It is right associative and has the highest precedence among logical operators.
What is a decision problem, and how many possible outcomes does it typically have?
A decision problem is a type of problem that has only two possible outcomes, and it is best represented using a boolean data type.
What type of problem is a decision problem, and how is it related to classification?
A decision problem is a type of classification problem. It involves categorizing an input into one of two possible classes or outcomes.
What is a problem definition in software development, and how is it typically written?
A problem definition in software development is the description of the problem that needs to be solved, usually written in plain English.
How does a problem definition translate into a function definition in software development?
A problem definition translates into a function definition by specifying the function’s name, inputs, preconditions, outputs, and postconditions.
What are the key considerations when translating a problem description into a function definition?
When translating a problem description into a function definition, ensure that:
- The function has a clear name.
- All inputs mentioned in the problem description are accounted for as function inputs.
- Outputs match the expected outcomes.
- Postconditions clearly represent the desired conditions using boolean logic.
- The postcondition may use brackets to explicitly convey the precedence remember in engish the precedence of conjunction and disjunction are opposite to boolean logic
What is a problem instance in the context of software testing?
A problem instance in software testing is a specific, concrete problem or scenario that consists of input values satisfying the preconditions of a function definition.
What is a test case, and how is it related to a problem instance?
A test case is a specific problem instance along with the expected output for that instance. It is usually represented as one row in a test table.
Why is it important to consider edge cases when defining problem instances and test cases and what should we be testing?
It is important to consider edge cases because they represent extreme or boundary conditions of inputs. They include
* the lowest and highest possible values
* zero (boundary between negative and positive integers)
* 1 (lowest positive number)
* -1 (highest negative number)
* etc.,
*
* which can help uncover potential issues in the function’s behavior and off by one errors
How can you calculate the total number of problem instances when you have multiple inputs with two possible values each?
To calculate the total number of problem instances when you have multiple inputs with two possible values each, you can use the formula:
Total Instances = (Number of Values for Input 1) x (Number of Values for Input 2) x (Number of Values for Input 3) x …
and so on.
How is the complexity of an algorithm determined, and what is it based on?
The complexity of an algorithm is determined based on the English-written version of the algorithm. It involves analyzing the operations within the algorithm to understand its computational efficiency.
What are three key considerations when analyzing the complexity of an algorithm?
When analyzing the complexity of an algorithm, consider the following:
- Identify and count the operations within the algorithm.
- Assess the complexity of each operation (e.g., constant complexity).
- Determine if the number of operations is fixed or variable.
What is the complexity of an algorithm that has constant complexity operations and a fixed number of operations?
An algorithm that has constant complexity operations and a fixed number of operations is considered to have constant complexity, denoted as Θ(1).
For this algorithm we would say:
The algorithm has complexity Θ(1)