F453 - programming techniques Flashcards

1
Q

What type of traversal should be used to obtain reverse polish from a binary tree?

A

post-order (traversal)

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

State a data structure that may be associated with reverse polish notation

A

stack binary tree

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

What symbol used in mathematical expressions is not required in reverse polish?

A

bracket

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

How can functions and procedures develop a program in a structured way?

A

each module can be written as a functional procedure… …which can be tested individually library routines code is reusable main program consists of calls to functions/procedures… …which may be nested

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

Compare the use of local and global variables and parameters

A

local variables a variable defined within one part of program… …& is only accessible in that part data contained is lost when execution of that part of program is completed the same variable names can be used in different modules global variables a variable that is defined at the start of a program… & exists throughout program… …including functions/procedures allows data to be shared between modules overridden by local variables with the same name parameters information about an item of data… …supplied to a function or procedure can be passed by reference or by value used as a local variable

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

What data structure is used when procedures are called during program execution?

A

stack

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

What is the purpose of using a stack?

A

so program can return correctly when procedure has been completed/store return address allows data to be transferred

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

State the need for BNF

A

to unambiguously define the syntax of a computer language

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

What’s the use of functions, procedures and step-wise refinement when developing a program?

A

function: block of code… …which performs a single task/calculation… returns a single value uses local variables procedure: block of code… …which performs a task …which may or may not produce a single value uses local variables stepwise refinement: breaks a problem into sections… …which become progressively smaller… …until each module can be written as a single procedure/function each module can be tested separately library routines can be used

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

What data structure is used to handle procedure calling and parameter passing?

A

stack

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

What’s a parameter?

A

(information about) an item of data… …supplied to a procedure or function may be passed by reference or by value used as a local variable

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

What is the purpose of a syntax diagram?

A

to define terms unambiguously (for a computer language)

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

What is an advantage of reverse polish over infix notation?

A

any expression can be processed in order (left to right) no rules of precedence are needed/no brackets are needed/unambiguous

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

State what is meant by selection (2)

A

A condition is used to decide whether code should be executed (if statement)

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

State what is meant by iteration (2)

A

code is executed repeatedly (While or For loop)

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

Look at image

A

 only 1 letter allowed

 letter missing

17
Q

Look at image

A

 identifierA must include 1 or more letters

 identifierB need not include any letters

 eg $2 is valid for identifierB but not for identifierA…

 …while $2ab is valid for both

18
Q

Look at image

A

(b) (i) only 1 letter allowed/letter must be at start only [1] 8
(b) (ii) G is not defined (as a letter) [1] 8
(c) e.g. < DIGITS> ::= | < DIGIT> < LETTERS > ::= < LETTER > | < LETTER > < LETTERS > ::= < DIGITS> | < DIGITS> < LETTERS > • DIGITS defined correctly • LETTERS defined correctly • NEW_CODE defined correctly [

19
Q

Look at image

A

(i)  to define terms unambiguously (for a computer language) [1]
(ii)  Backus-Naur Form

20
Q

Look at image

A

Look at image

21
Q

Look at image

A

Look at image