2.2.1 Programming techniques Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

2.2.1 A)
What’s a programming construct used for.

A

used to represent control flow structured programming

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

2.2.1 A)
What are the 3 programming constructs.

A

Sequence , branching/selection , iteration

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

2.2.1 A)
What is a sequence in term of programming constructs.

A

Code is executed line by line top to bottom

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

2.2.1 A)
What is branching / selection in term of programming constructs.

A

Code is run if a specific condition is met (if statement)

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

2.2.1 A)
What is iteration in term of programming constructs.

A

Code is executed certain number of times or while a condition is met. (for/while statement)

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

2.2.1 B) What is recursion

A

A construct in which a subroutine calls apron itself during execution. This continues until a certain condition is met ( stopping condition ).

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

2.2.1 B)
What is recursion like and how is it different.

A

produces the same result as iteration but suited to certain problems.

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

2.2.1 B)
What’s the advantage of recursion.

A

CAN be represented in fewer lines which can lead to less errors. But it needs to be clearly defined to reach a stopping condition

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

2.2.1 B)
How do stacks work in recursion.

A

Every time the stack calls itself a new stack frame is created within the stack. Stack frames are created until stopping condition is met and subroutine unwinds. Information from the call stack being popped off the stack.

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

2.2.1 B)
What is recursion used for?

A

For storing parameters, local variables and return addresses are stored allowing the subroutine to return to a particular point during execution.

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

2.2.1 B)
What’s the disadvantage of recursion

A

inefficient use of memory, danger of stack overflow (if it calls it self too many times call stack runs out of memory) this can lead to the program crashing, Difficult to trace.

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

2.2.1 B)
How can recursion be improved ?

A

can use tail recursion its a form of recursion which implemented in a more eff way, less stack space is needed

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

2.2.1 C)
What is scope

A

refers to the section of code the variable is available too.

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

2.2.1 C)
What is a local variable

A

It has a limited scope, only can be accessed within a block of code in which they were defined.

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

2.2.1 C)
Adv of local variable

A

multiple local variables can have same name not effect each other. good practice ensures subroutines are self contained.

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

2.2.1 C)
What is a global variable

A

can be accessed across whole program its declared outside of a subroutine

17
Q

2.2.1 C)
dis(adv) of global variable

A

useful for values used by multiple parts of program
can be unintentionally overwritten / edited

18
Q

2.2.1 C)
When are global / local variables deleted.

A

Global variables deleted after the program finishes executing ( takes up more memory)
Local variables deleted after subroutine finishes

19
Q

2.2.1 C)
What happens if a local and global variable have the same name

A

local takes precedence

20
Q

2.2.1 D)
What is modular programming

A

A technique used to split large, complex programs into smaller, self contained modules.

21
Q

2.2.1 D)
What is top down approach / stepwise refinement

A

problems continually broken down into sub problems until it can be represented as individual, self contained black box which preforms a certain task.

21
Q

2.2.1 D)
What is the adv of modular programming

A

makes problem easier to understand and approach. Also makes it easier to divide takes between a team and manage. This improves testing / maintenance as its dealt with individually therefore improving reusability .

22
Q

2.2.1 D)
What are procedures and functions

A

modules form subroutines which can be categorized as either functions or procedures

functions named blocks of code that performs a specific task. function must always return one value and typically use local variables

procedures named block of code that performs a specific task. procedures dont have to return a value but can also return multiple values

23
Q

2.2.1 D)
How can parameters passed through to a subroutine

A

Either by value or by reference

24
Q

2.2.1 D)
What happens when parameter is passed by value

A

They are treated like a local variable. a copy is made passed through subroutine it is discarded at the end, value outside of subroutine unaffected.

25
Q

2.2.1 D)
What happens when parameter is passed by reference

A

Address passed through, address given to the subroutine so the value of parameter will be updated at given address

26
Q

2.2.1 D)
Which parameter passing should be assumed

A

By value unless told otherwise

27
Q

2.2.1 E)
What is an IDE and what is it used for

A

Integrated design environment
a program which provides a set of tools to make writing , developing and debugging code easier,

28
Q

2.2.1 E)
Common feature of IDE

A

Stepping
Variable watch
Breakpoint
Source code editor
Debugger tool

29
Q

2.2.1 E)
Common feature of IDE
What is stepping

A

monitor effect of each line of code by executing a single line at a time

30
Q

2.2.1 E)
Common feature of IDE
What is variable watch

A

Sometimes used to pinpoint errors observe how content of variable change in real time

31
Q

2.2.1 E)
Common feature of IDE
What is breakpoint

A

set a point in the program at which program will stop based on condition or specific line helps pinpoint error.

32
Q

2.2.1 E)
Common feature of IDE
What is source code editor

A

make writing easier with auto completion of words, indentation, syntax highlight

33
Q

2.2.1 E)
Common feature of IDE
What is debugging tool

A

run time detection of errors with a guild to where in the code likely to be. Through line number / highlights.