2.2.1. Programming Techniques Flashcards

(18 cards)

1
Q

What are the 3 programming constructs?

A

sequence selection iteration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 2 catagroies of loop iteration is split up into?

A

count controlled
condition controlled

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does the selection programming construct work?

A

a certain block of code is run if a specific condition is met, using IF statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is recursion?

A

a programming construct where a subroutine calls itself during its execution until the base case is met

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the base case in recursion?

A

a condition that must be met in order for the recursion to end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are 2 advantages of recursion?

A
  1. can be represented in fewer lines of code
  2. easier to express some function recursively than iteratively
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are 3 disadvantages of using recursion?

A

inefficient use of memory
danger of stack overfow
difficult to trace

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are 3 peices of information that are stored on the call stack?

A

parameters
return adresses
local variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the defenition of scope?

A

the section of the program where a variable can be accessed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are 3 advantages of using local variables over global variables?

A

less memory is used
self contained, so unaffected by code outside of the subroutine
takes precedence over global variables with the same name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a top-down design? (2 things)

A

a technique used to modularise programs where the problem is continually broken down into sub-problems,

until each can be represented as an individual, self contained module that performs a certain task

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are 3 advantages of a modular design?

A
  1. greater reusability
  2. makes a problem easier to understand and approach
  3. testing and maintenance simplified as modules are self-contained
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the difference between procedures and functions?

A

functions must always return a value whilst a procedure does not

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does it mean to pass a parameter to a subroutine by reference?

A

the memory address of the parameter is passed to the subroutine, so its value outside of the subroutine will be updated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are features of IDE’s?

A

debugging tools
source code editor
variables watch
stepping
breakpoint

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does IDE stand for?

A

integrated development environment

17
Q

What is encapsulation in object-orientated programming?

A

where attributes are declared as private so can only be accessed and edited by public methods

18
Q

What is the purpose of encapsulation in object-orientated programming?

A

to reduce program complexity by protecting data from being accidentally edited by other parts of the program