9. Algorithms and Programs Flashcards
What does the operator DIV do?
Finds the whole number of times a divisor can be divided into a number e.g. 11 DIV 2 = 5
What does the operator MOD do?
Finds the remainder when a divisor is divided into a number e.g. 11 DIV 2 = 1
What is an algorithm?
An algorithm is a set of organised steps or rules to solve a given problem
What is a Boolean?
A binary variable that can have two possible values, true or false
What is a string?
A data type used to represent a sequence of characters
What is an integer?
A whole number (positive or negative)
What is a real value?
Numbers including fractions and decimals
What is a character?
A letter, digit, space, punctuation mark or various other symbols
What is selection?
Determines which path a program takes when it is running e.g. if statements
What is a sequence?
The order in which instructions occur and are processed
What is repetition and what are the two types?
The repeated execution of a section of code when a program is running
- count controlled iteration: repeatedly executes a section of code a predetermined fixed amount of times
- condition controlled iteration: repeatedly executes a section of code until a condition is met/no longer met
What is a variable?
A named space in memory that can contain a single piece of data, which can change during the execution of a program.
What is a constant
A named space in memory that always contains the same value during program execution.
What is a variable scope?
It indicates the accessibility of a variable.
What is a local variable and what are its advantages?
A variable that only exists until the subroutine in which it was created ends.
advantages:
- subroutines with local variables can be reused in other programs
- easier to debug
- saves memory as it only takes up space when it is needed
What is a global variable and what are its advantages?
A variable that exists throughout the entire lifetime of a program’s execution.
advantages:
- can be used anywhere in the whole program
- makes maintenance easier as it only has to be declared once
- can be used for constants
What is a subprogram and what are the two types?
A subprogram is a smaller program written within a larger one with the purpose of performing a specific task.
- Procedures
A procedure performs a specific task and when it is done, the program continues where it left off. - Functions
Functions work the same way as procedures, but can manipulate data and return a result back to the main program.
What are the benefits of using subprograms?
- they are small in size so can be tested and debugged easily
- can be saved as modules and reused in different programs
- can be used repeatedly in a program and only be written out once
What is a standard function and what are the benefits of using them?
A standard function is an in built, ready made function, e.g. print()
benefits:
- gone through rigorous testing so they work
- code optimised for maximum performance
- portable
- considerable amount of development time
What is a parameter?
An item of data passed from one subroutine to another
How does a binary search work?
A binary search takes the midpoint of a set of sorted data and compares it to the search value. If the search value is less than the midpoint, all data after the midpoint is eliminated, and if the search value is more than the midpoint, all data before the midpoint is eliminated. The midpoint of the new set of data is then found and the process is repeated until the midpoint equals the search data, or the end of the data is reached.
How does a linear search work?
A linear search takes the first item in a set of data (does not have to be sorted) and compares it to the search value. If the search value is not equal to the item in the current position, then the search value is compared to the next piece of data in the list. This process is repeated until the search value equals the item in the current position, or until the end of the data is reached.
What is abstraction in terms of computational thinking?
When a problem is simplified so that only the important and relevant details are considered.
What is decomposition in terms of computational thinking?
When a large, complex problem is broken down into smaller, more easily solvable problems.