Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
30 Cards in this Set
- Front
- Back
What are the two types of subroutine?
|
- Functions - Procedures |
|
What is a function?
|
- A block of code with its own identifier that performs a specific task - Returns a single value - May require parameters which are treated as local variables |
|
What is a procedure?
|
- A block of code with its own identifier that performs a specific task - Does not return a value - May require parameters which are treated as local variables |
|
What is stepwise refinement?
|
- The process of breaking down a complex problem into smaller more manageable sub tasks - Each task is repeatedly broken down into smaller modules until each module can be written as a single procedure |
|
What are the benefits of stepwise refinement?
|
- Modules can be reused across different programs - The final program will be easier to maintain - Modules can be stored as library routines and used by other programmers - Program can be produced faster as procedures can be shared between programmers |
|
What is a variable?
|
An identifier name that refers to a particular memory location that is used to store data. The value of the data that is stored can change when the program is running
|
|
What are the two types of variable? |
- Global
- Local |
|
What is a local variable?
|
- Is only accessible in that subroutine - The same variable names can be defined in different subroutines - The data is lost when execution of that subroutine is finished |
|
What is an example of a local variable |
a loop counter |
|
What are global variables?
|
- It can then be used in all subroutines in the program - The data 'exists' throughout the running of the program - Allows the same data to be shared between modules - A global variable will be overridden by local variables with the same name |
|
What is an example of a global variable?
|
VAT |
|
What is a parameter?
|
Values that are passed to a function or procedure and used within the body of the function or procedure
|
|
What are the 2 ways to pass a value to a function or procedure?
|
- passed by reference |
|
What is passed by value? |
The actual value (e.g. 5) is passed across and any original values are still there when the subroutine is finished
|
|
What is passed by reference? |
A location in memory (e.g. num1) is passed which can be overwritten during execution
|
|
What is BNF?
|
- is a standard way of representing the syntax rules of a programming language - It is incredibly precise so programmers fully understand the rules of the syntax |
|
Why is BNF needed?
|
It is needed to unambiguously define the syntax of a computer language
|
|
What does <> indicate?
|
a non-terminal that needs to be further expanded e.g. |
|
What does | mean?
|
it means or; it separates alternatives e.g. 0|1|2|3|4|5|6|7|8|9 |
|
What other type of diagram can BNF diagrams be represented as?
|
Syntax diagrams
|
|
What is reverse polish notation?
|
Polish and reverse polish notation are unambiguous ways to write down mathematical expressions
|
|
Who invented polish and reverse polish notation?
|
A Polish mathematician |
|
What is infix notation?
|
When we want to add two numbers together we would write A+B. This is called Infix notation, the operator comes IN between the two operands (A,B)
|
|
Why do we need RPN?
|
It is important because expressions written in it are: 1) Unambiguous 2) Do not need brackets 3) Can be solved using stacks |
|
Using Infix, what does A + B mean? |
A is added to B
|
|
Using Polish notation, what does + A B mean?
|
Add A to B |
|
Using Reverse Polish Notation, what does A B + mean?
|
Take A B and add them
|
|
Rather than Infix what is Polish Notation?
|
Prefix
|
|
Rather than Infix what is Reverse Polish Notation? |
Postfix
|
|
What do we use to obtain reverse polish notation from a tree? |
Post order traversal
|