Programming Techniques Flashcards

1
Q

Explain the term procedure.

A
  • A block of code/ set of instructions
  • Performs a task
  • Receives parameter values
  • Uses local variables
  • May return values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Explain how parameters are used.

A
  • Supplied to a procedure or function
  • They are used to pass values between functions/procedures
  • They are passed by reference or by value
  • Uses as a local variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

State benefits of using procedures.

A
  • procedures tested separately
  • easier to maintain program
  • main program is simpler/code is clearly structured
  • use of library routines to save time
  • code is reusable
  • program produced faster/to a higher standard…
  • …as procedures may be shared between
    programmers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe stepwise refinement.

A
  • problem broken into sections…
  • which become progressively smaller
  • until each section can be written as a single
    procedure/represents one step in the algorithm
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Explain the term global variable.

A
  • a variable defined at the start of a program
  • exists throughout program…
  • including functions & procedures
  • allows data to be shared by modules
  • overridden by local variables with same name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Explain the term local variable.

A
  • a variable defined within one module…
  • & only accessible in that module
  • data is lost when module is completed
  • same variable name may be used in different
    modules
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Discuss the use of functions in developing programs.

A
  • block of code…
  • …which performs a single task/calculation…
  • returns a single value
  • uses local variables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Discuss the use of procedures in developing programs.

A
  • block of code…
  • …which performs a task
  • …which may or may not produce a single value
  • uses local variables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Discuss the use of stepwise refinement in developing programs.

A
  • 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

Explain the term 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

State the purpose of of syntax diagrams.

A

to unambiguously define terms for a computer language

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

What other notation can be used other than syntax diagrams?

A

Backus-Naur Form

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

State advantages of using reverse polish notation compared with infix algebraic 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
15
Q

What tree traversal should be used for reverse polish notation?

A

post order

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