2.2.1 Programming Techniques Flashcards

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

what is the difference between global and local variables

A

Global variables can be accessed from the entire program
Local variables have a limited scope where they can only be accessed from the module of code they were defined in

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

what is the difference of passing in a parameter byval and byref

A

by value means that a coy of the data is given to the subroutine meaning anychanges to the data made inside the subroutine dont change the value passed in
by ref gives the address of the data to the subroutine meaning any changes to the data update the address as its changed

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

what are the two ways to pass parameters into a subroutine

A

by reference and by value

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

define a recursive algorithm

A

a recursive algorithm is a function which calls itself from within the function

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

name the pros of a recursive algorithm

A

Certain problems are more suited to a recursive solution
problems can be more elegantly solved
can reduce the size of the problem on every recursive call
more natural to read
quicker to write

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

name the cons of recursion

A

uses more memory
can run out of stack space
difficult to debug
harder to trace

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

example of a time recursion is idea

A

factorial
fibbonnacci
tree traversal

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