What is the maximum number of activation records

Assignment Help Computer Engineering
Reference no: EM132706832

Assignment

1 LR(1) Grammars
Consider the following grammar, where {a,b,c,d,e} are terminal symbols and S is the initial symbol.
S → A a (1)
S → e (2)
A → d B (3)

A → b B S (4)

B → c B (5)
B → ? (6)

1. Write the First sets for all non-terminal symbols of the grammar.

2. Construct the full LR(1) DFA, showing all items in each state.

3. Construct the LR(1) parsing table using the DFA. For the reduce actions, use the provided enumeration of the productions in the grammar.

4. Show all steps required to parse the following string: bbcceaa

5. Is this grammar LALR(1)?

2 Activation Records

In the following listing we show an excerpt of a program in a language that allows nested definitions for functions and uses call-by-value:int collatz_length(int n, int len) {

boolean collatz_base() { return n == 34;
}

if (collatz_base()) return len + 13;
else
if ((n mod 2) == 1)
return collatz_length(3 * n + 1, len + 1); else
return collatz_length(n div 2, len + 1);
}

Suppose we have in our main() function a call to collatz length(7, 0). Assume that the compiler allocates all the variables (i.e. both named and temporary) on the stack.
Questions
1. What will the return value of this call be?
2. What is the maximum number of activation records that will ever be in the stack before the call from main returns? (Assume that the compiler does not optimize tail calls.)

3. Give a diagram of the state of the stack just before collatz base returns true. Your diagram should contain at least the following information:
(a) Boundaries of the activation records.
(b) Location and content of the actual parameters for the calls to the functions.
(c) Where in the stack is the value of n, for which collatz base returns true.
(d) Location of the return values.
(e) Location of the return addresses.
(f) Location and content of the control links and access links.
(g) Optional: Location and content of temporary variables.
4. How should the value of n be retrieved, in order to make the comparison in collatz base?

5. Optional: Describe briefly the tail call (or tail recursion) optimization and whether it can be applied to this code snippet. You can read about it in the Wikipedia.

Attachment:- CSE_assignment 3.rar

Reference no: EM132706832

Questions Cloud

Does vision always acquire transformation : 1. Does vision always acquire transformation? 2. Explain why the CEO is the only person in the organization who can coordinate?
Explain the differences between a president and a ceo : 1. Discuss the differences between the roles of top (CEO) management and middle management.
What is the estimate of stock price based on firm valuation : A company had free cash flows of $556 million last year. What is the estimate of the stock price based on the firm valuation model?
Find what is estimate of the stock price based on the firm : What is the estimate of the stock price based on the firm valuation model? Free cash flows are expected to grow at 2.9% per year.
What is the maximum number of activation records : Write the First sets for all non-terminal symbols of the grammar and What is the maximum number of activation records that will ever be in the stack
Determine the cost of merchandise sold : Assume one unit is sold on October 31 for $15. Determine the cost of merchandise sold, gross profit, and Ending Inventory under the Average cost method
How public policy is formed in american system : Explain how public policy is formed in the American system of government. How is the problem identified?
Find what is the expected return of the preferred stock : Find What is the expected return of the preferred stock?Bank of America has a preferred stock dividend of $2.83. The stock is trading for $94.63.
Determine the cost of manufacturing one custom kitchen : Determine the cost of manufacturing one custom kitchen assuming the units given. Assume the MOH costs are allocated based on the direct labor hours per unit

Reviews

Write a Review

Computer Engineering Questions & Answers

  Evaluate and choose appropriate software design patterns

Demonstrates an ability to evaluate a problem and choose an appropriate software design pattern. Demonstrates a sound understanding of the chosen software

  Show how the split function can be used

Show how the Split function can be used. Show how the Chomp function can be used. Show how a for loop can be used in Perl.

  Which minterms are represented by cells adjacent to the cell

Draw a K-map for a function in four variables. Put a 1 in the cell that represents w¯xyz¯.

  Construct prediction models using multiple machine

The data set comes from the Kaggle Digit Recognizer competition. The goal is to recognize digits 0 to 9 in handwriting images. Because the original data set.

  How an implementation phase works within the model

Writr a brief explanation of the Agile model and how an implementation phase works within the model. At least three technical design specifications for program.

  Managed care organizations and information technology

Normal 0 false false false EN-US X-NONE X-NONE Managed Care Organizations and..

  Solves a system of linear equations

Write a function that solves a system of linear equations or calculates the inverse of a matrix by Gauss-Jordan elimination.

  How old information system handles functions you mentioned

Explain how the old information system handles the functions you mentioned, the problems that occur, and why your information system will handle things better.

  Write clearly and concisely about systems analysis and

application architecture due week 8 and worth 50 points you have been tasked with building a payroll program for a

  Designing the flow chart and algorithm

Write down an algorithm and develop a flow chart to find all the people who have computer experience and at least five years of company service.

  Write efficient functions that take only a pointer to root

Write efficient functions that take only a pointer to the root of a binary search tree, T, and compute The number of nodes in T.

  What are simple coping strategies for indicated stressors

What are simple coping strategies you can suggest for the indicated stressors. What action plans should be implemented to better cope with the stressors?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd