1. Show the operations of mark and sweep algorithm.
a. Mark: Go through live memory and mark all live cells. (data)
b. Sweep: Go through whole memory and put a reference to all non-live cells
into free pool.
2. Discuss explicit and implicit heap dynamic.
a. Explicit heap-dynamic
b. Explicit heap-dynamic variables are allocated and deallocated by explicit
directives, specified by the programmer, whichtake effect during execution
Implicit heap-dynamic variables -- Allocation and deallocation caused by assignment
statements and types not determined until assignment.
3. Develop the evaluation of short circuit.
• An expression in which the result is determined w/o evaluating all operands
and/or operators
(13*a) * (b/13–1)
If a is zero, there is no need to evaluate (b/13-1)
4. Differentiate Formal parameters with actual parameters.
a. A formal parameter is a dummy variable listed in the subprogram header
and used in the subprogram (e.g)
b. An actual parameter represents a value or address used in the subprogram
call statement (e.g)
5. Define Dynamic scoping.
• Deep Access: non-local references are found by searching the activation record
instances on the dynamic chain.
• Shallow Access: put locals in a central place
6. What are the methods to implement blocks?
Two Methods:
a. Treat blocks as parameter-less subprograms that are always called from
the same location
2. Since the maximum storage required for a block can be statically determined,
this amount of space can be allocated after the local variables in the activation
record
7. Differentiate pass by value and pass by result.
Pass-by-Value (In Mode)
The value of the actual parameter is used to initialize the corresponding formal
parameterNormally implemented by copying
Pass-by-Result (Out Mode)
When a parameter is passed by result, no value is transmitted to the subprogram; the
corresponding formal parameter acts as a local variable; its value is transmitted to
caller’s actual parameter when control is returned to the caller, by physical move
10. Discusswhat is meant by EP?And what is its purpose?
– End pointer Saves the old EP in the stack as the dynamic link and create
the new value.
– Restore the stack pointer by setting it to the value of the current EP-1 and
set the EP to the old dynamic link
PART - B
11a. Describe Arithmetic expression. Compare Relational and
Boolean Expressions with example. 13
Arithmetic Expressions
• Arithmetic expressions consist of operators, operands, parentheses, and
function calls
• Unary, binary, ternary (e.g., _?_:_) operators
• Implementation involves:
• Fetching operands, usually from memory
• Executing arithmetic operations on the operands
• Expressions using relational operators and operands of various types;
evaluate to Boolean
• Relational operators: compare values of 2 operands
• Operator symbols vary among languages (!=, /=, ~=, .NE., <>, #)
• Boolean Expressions
• Expressions using Boolean operators and Boolean operands, and evaluate to
Boolean
• Boolean operands: Booleanvariables, Booleanconstants, relational
expressions
OR
11b. (i) Discussthe need and issues involved in control Structures
with example.
• Computations in imperative-language programs
– Evaluating expressions – reading variables,executing operations
– Assigning resulting values to variables
– Selecting among alternative control flow paths
– Causing repeated execution
• A control structure is a control statement and the statementswhose execution it
controls
Most programming languages follow a single thread of control (or scheduling)
(ii) Illustrate the Overloaded Operators with example.
inta,b;
floatx,y;
…
b = a + 3;
y = x + 3.0;
• We wish to use the same operator ‘+’ to operate on integersand floating-point
numbers
– Let compiler make proper translation, e.g., ADD vs FADD
– How about ‘+’ to operate on two array variables?
• Use of an operator for more than one purpose is called operator overloading
• Some are common (e.g., + for int and float)
• Some are troublesome (e.g., * in C and C++)
– Loss of compiler error detection (omission of an operand should be a
detectable error)
– Some loss of readability
• C++/C# allow user-defined overloaded operator
– Users can define nonsense operations
12a. Explain data type .What are the various Primitive Data type?
Evaluate the various data types . 13
Primitive Data Types
These types are supported directly in the hardware of the machine and not defined in
terms of other types:
– Integer: Short Int, Integer, Long Int (etc.)
– Floating Point: Real, Double Precision
Stored in 3 parts, sign bit, exponent and mantissa (see Fig 5.1 page 199)
– Decimal: BCD (1 digit per 1/2 byte)
Used in business languages with a set decimal for dollars and cents
– Boolean: (TRUE/FALSE, 1/0, T/NIL)
– Character: UsingEBCDIC, ASCII, UNICODE, etc.
OR
12b. Compose the need for attribute grammar with example. 13
13 a. Discuss stack and dynamic variables.
13
OR
13 b. Analyze the various subprogram and how overloading of
subprograms are done? Explain with examples. 13
14 a. Formulatethe need for nested subprograms and explain them
with examples.
13
OR
14 b. Demonstrate how implementation of various parameter
passing methods is implemented. Explain with an example
13
15 a. Illustrate a program to implement the concepts of
(i)Overloaded methods.
(ii) Generic methods. With an example.
7
6
OR
15.b Explain the design issues of subprogram with sub program.
13

Ppl

  • 1.
    1. Show theoperations of mark and sweep algorithm. a. Mark: Go through live memory and mark all live cells. (data) b. Sweep: Go through whole memory and put a reference to all non-live cells into free pool. 2. Discuss explicit and implicit heap dynamic. a. Explicit heap-dynamic b. Explicit heap-dynamic variables are allocated and deallocated by explicit directives, specified by the programmer, whichtake effect during execution Implicit heap-dynamic variables -- Allocation and deallocation caused by assignment statements and types not determined until assignment. 3. Develop the evaluation of short circuit. • An expression in which the result is determined w/o evaluating all operands and/or operators (13*a) * (b/13–1) If a is zero, there is no need to evaluate (b/13-1) 4. Differentiate Formal parameters with actual parameters. a. A formal parameter is a dummy variable listed in the subprogram header and used in the subprogram (e.g) b. An actual parameter represents a value or address used in the subprogram call statement (e.g) 5. Define Dynamic scoping. • Deep Access: non-local references are found by searching the activation record instances on the dynamic chain. • Shallow Access: put locals in a central place 6. What are the methods to implement blocks? Two Methods:
  • 2.
    a. Treat blocksas parameter-less subprograms that are always called from the same location 2. Since the maximum storage required for a block can be statically determined, this amount of space can be allocated after the local variables in the activation record 7. Differentiate pass by value and pass by result. Pass-by-Value (In Mode) The value of the actual parameter is used to initialize the corresponding formal parameterNormally implemented by copying Pass-by-Result (Out Mode) When a parameter is passed by result, no value is transmitted to the subprogram; the corresponding formal parameter acts as a local variable; its value is transmitted to caller’s actual parameter when control is returned to the caller, by physical move 10. Discusswhat is meant by EP?And what is its purpose? – End pointer Saves the old EP in the stack as the dynamic link and create the new value. – Restore the stack pointer by setting it to the value of the current EP-1 and set the EP to the old dynamic link PART - B 11a. Describe Arithmetic expression. Compare Relational and Boolean Expressions with example. 13 Arithmetic Expressions • Arithmetic expressions consist of operators, operands, parentheses, and function calls • Unary, binary, ternary (e.g., _?_:_) operators • Implementation involves: • Fetching operands, usually from memory • Executing arithmetic operations on the operands • Expressions using relational operators and operands of various types; evaluate to Boolean
  • 3.
    • Relational operators:compare values of 2 operands • Operator symbols vary among languages (!=, /=, ~=, .NE., <>, #) • Boolean Expressions • Expressions using Boolean operators and Boolean operands, and evaluate to Boolean • Boolean operands: Booleanvariables, Booleanconstants, relational expressions OR 11b. (i) Discussthe need and issues involved in control Structures with example. • Computations in imperative-language programs – Evaluating expressions – reading variables,executing operations – Assigning resulting values to variables – Selecting among alternative control flow paths – Causing repeated execution • A control structure is a control statement and the statementswhose execution it controls Most programming languages follow a single thread of control (or scheduling) (ii) Illustrate the Overloaded Operators with example. inta,b; floatx,y; … b = a + 3; y = x + 3.0; • We wish to use the same operator ‘+’ to operate on integersand floating-point numbers – Let compiler make proper translation, e.g., ADD vs FADD – How about ‘+’ to operate on two array variables? • Use of an operator for more than one purpose is called operator overloading
  • 4.
    • Some arecommon (e.g., + for int and float) • Some are troublesome (e.g., * in C and C++) – Loss of compiler error detection (omission of an operand should be a detectable error) – Some loss of readability • C++/C# allow user-defined overloaded operator – Users can define nonsense operations 12a. Explain data type .What are the various Primitive Data type? Evaluate the various data types . 13 Primitive Data Types These types are supported directly in the hardware of the machine and not defined in terms of other types: – Integer: Short Int, Integer, Long Int (etc.) – Floating Point: Real, Double Precision Stored in 3 parts, sign bit, exponent and mantissa (see Fig 5.1 page 199) – Decimal: BCD (1 digit per 1/2 byte) Used in business languages with a set decimal for dollars and cents – Boolean: (TRUE/FALSE, 1/0, T/NIL) – Character: UsingEBCDIC, ASCII, UNICODE, etc. OR 12b. Compose the need for attribute grammar with example. 13 13 a. Discuss stack and dynamic variables. 13 OR
  • 5.
    13 b. Analyzethe various subprogram and how overloading of subprograms are done? Explain with examples. 13 14 a. Formulatethe need for nested subprograms and explain them with examples. 13 OR 14 b. Demonstrate how implementation of various parameter passing methods is implemented. Explain with an example 13 15 a. Illustrate a program to implement the concepts of (i)Overloaded methods. (ii) Generic methods. With an example. 7 6 OR 15.b Explain the design issues of subprogram with sub program. 13