2.2.1 Programming Techniques Flashcards
What are the primary programming constructs?
Sequence
Iteration
Branching/Selection
What are examples of count-controlled and condition-controlled loops?
Count: For loop
Condition: While loop
Define ‘recursion’
A function calling itself until a condition is met
What are the benefits and drawbacks of recursion?
Benefits:
Can be used to traverse trees
Drawbacks:
Requires more storage space than an iterative solution
A missing condition will lead to a stack overflow
Define ‘global variable’
- A variable accessible anywhere within a program
- Allocated a distinct memory location during execution
Define ‘local variable’
- A variable only accessible within a specific part of a program
- Usually defined within a function or passed by value
Define ‘scope’
Refers to where a variable/constant can be accessed.
The scope is either local to a subroutine or global to a program
Explain ‘passing by value’
A copy of the variable is created within the subroutine, therefore the original variable is unchanged without returning the value
Explain ‘passing by reference’
A pointer to the variable is created when passed.
When changed within the subroutine, it is updated to the original as well
Define ‘IDE’
Integrated Development Environment:
Provides tools and an area to create code
What are some common features of an IDE?
- Warning alerts
- Colour coding
- Commenting
- Auto-complete and hints
- Translating and running code