Problem Solving (Ch7) (M2) Flashcards
What are the three key components to computational thinking?
Three key components of computational thinking:
Abstraction, decomposition, algorithmic thinking
What is abstraction?
Abstraction is where you ignore unnecessary information and focus only on the important facts.
Why is abstraction used?
Abstraction is used because it simplifies a problem to make it less complex. This makes it more straightforward to understand the problem and create a solution.
What is decomposition?
Decomposition is when you break a problem down into smaller tasks so that it is easier to solve.
Give three advantages of decomposition
Advantages of decomposition:
• Smaller problems are easier to solve
• They can be created independent of the other problems
• They can be tested independently
• Then combined to produce the full problem
• Each individual problem can be separately tested and solved
What does algorithmic thinking do?
Algorithmic thinking will put the tasks into a step-by-step process to solve to problem.
How does algorithmic thinking approach a problem?
The problem is broken down using decomposition into smaller problems. The required data and relevant data structures are considered using abstraction.
Give one difference between functions and procedures
Procedures:
Carry out a task
Provide structure to code
Functions:
Carry out a task AND return a value
Create reusable program components
Give one advantage of a sub program
Advantages of sub programs:
The program is easier to write The program is easier to debug
We are creating reusable components
The program is easier to test
Functions could be gathered together into a library for easy reuse across multiple programs
What is the advantage of structuring code into sub-programs?
Structuring code into sub-programs makes the code easier to read and debug.
What do functions do?
Functions return values and create reusable program components.
What do procedures do?
Procedures create a modular structure to a program, making it easier to read.
Pre-defined subroutines don’t have to be written by the programmer. Why?
Pre-defined subroutines don’t have to be written by the programmer, they are built into the IDE and already exist.
Who are user defined subroutines written by?
User defined subroutines are written by the programmer.
Give an example of where random numbers would/could be used
Random numbers could/would be used in:
A random number generator
A game
What is concatenation?
Concatenation is where strings are joined together to form new strings
What operator is concatenation usually performed with?
Concatenation is often done using the + operator
What does .length do?
.length returns the length of a string
What does .upper and .lower do?
.upper returns the string in uppercase
.lower returns the string in lowercase
What does .substring(x, i) do?
Returns part of a string, starting at the character of the first parameter and counting up by the number in the second parameter.