1. Consider the following pseudocode, assuming a language with nested subroutines: procedure main () x :...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Consider the following pseudocode, assuming a language with nested subroutines: procedure main () x : integer procedure B (a : integer) y: integer -1 procedure A (n : integer) x := n print x procedure R(x : integer) X = x - 2 if x > 1 -- else y = x + a A (y +1) body of B print x R (3) X B (5) print x body of main : = 2 R (y + 1) A (x) a) What does this program print if static scoping rules are in effect? Explain. b) What does this program print if dynamic scoping rules are in effect? Explain. c) Show the frames on the stack when procedure R has just been called. For each frame, show the values of local variables and parameters as well as the static links. 1. Consider the following pseudocode, assuming a language with nested subroutines: procedure main () x : integer procedure B (a : integer) y: integer -1 procedure A (n : integer) x := n print x procedure R(x : integer) X = x - 2 if x > 1 -- else y = x + a A (y +1) body of B print x R (3) X B (5) print x body of main : = 2 R(y + 1) A (x) a) What does this program print if static scoping rules are in effect? Explain. b) What does this program print if dynamic scoping rules are in effect? Explain. c) Show the frames on the stack when procedure R has just been called. For each frame, show the values of local variables and parameters as well as the static links. 1. Consider the following pseudocode, assuming a language with nested subroutines: procedure main () x : integer procedure B (a : integer) y: integer -1 procedure A (n : integer) x := n print x procedure R(x : integer) X = x - 2 if x > 1 -- else y = x + a A (y +1) body of B print x R (3) X B (5) print x body of main : = 2 R (y + 1) A (x) a) What does this program print if static scoping rules are in effect? Explain. b) What does this program print if dynamic scoping rules are in effect? Explain. c) Show the frames on the stack when procedure R has just been called. For each frame, show the values of local variables and parameters as well as the static links. 1. Consider the following pseudocode, assuming a language with nested subroutines: procedure main () x : integer procedure B (a : integer) y: integer -1 procedure A (n : integer) x := n print x procedure R(x : integer) X = x - 2 if x > 1 -- else y = x + a A (y +1) body of B print x R (3) X B (5) print x body of main : = 2 R(y + 1) A (x) a) What does this program print if static scoping rules are in effect? Explain. b) What does this program print if dynamic scoping rules are in effect? Explain. c) Show the frames on the stack when procedure R has just been called. For each frame, show the values of local variables and parameters as well as the static links.
Expert Answer:
Answer rating: 100% (QA)
a Static Scoping In static scoping the scope of a variable is determined at compiletime The variable ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
A board game uses the deck of 20 cards shown. Two cards are randomly selected from this deck. Determine the probability of the following a) With replacement. b) Without replacement. At least one of...
-
In Exercises 8182, graph each linear function. 3x - 4f(x) - 6 = 0
-
Select a familiar multichannel retailer. Evaluate its website in terms of how well it provides value to its customers. Do you believe that offering multiple selling channels to customers enhances...
-
The following data represent the percentage of total adjusted gross income (AGI) earned and percentage of tax paid by various income classes. The top 1% represents the percentage of total AGI earned...
-
E-Z-Boy Furniture makes sofas, loveseats, and recliners. The company allocates manufacturing overhead based on direct labor hours. E-Z-Boy estimated a total of \($2\) million of manufacturing...
-
Wilson Wonders bonds have 12 years remaining to maturity. Interest is paid annually, the bonds have a $1,000 par value, and the coupon interest rate is 10 percent. The bonds sell at a price of $850....
-
Which OSI layer is responsible for connection - oriented communication?
-
Utilizing the financial information below for The Cookie Company, complete a budget performance report combining activity and revenue and spending variances like that in Exhibit Please be sure to...
-
A company seeks to effectively implement a preventive maintenance strategy for its equipment and machinery. To do this, take into account that, to achieve efficient productivity in the company, a...
-
You can only invest in two securities: A and X. The correlation between the returns of A and X is 0.2. Expected returns and standard deviations are as follows: Security E[R] A X o(R) 20% 20% 15% 25%...
-
1- Define the following key concepts below: Keyword Placement Tags and Attributes Landing Pages Behavioral Targeting Placement Targeting
-
I understand that the equivalent annual cost is the cost of owning and operating a machine for a period of one year. And one of the shortfalls of the calculation is that it is assumed the machine can...
-
How do economic policies and governmental interventions influence the trajectory of social mobility within a given society?
-
How do the lending institutions prevent delinquency without relying on traditional method of lending policies and practices?
-
Kohl Co. provides warranties for many of its products. The January 1, 2019, balance of the Estimated Warranty Liability account was $34,256. Based on an analysis of warranty claims during the past...
-
Borrowing costs should be recognised as an expense and charged to the profit and loss account of the period in which they are incurred : A. If the borrowing costs relate to qualifying asset B. If the...
-
Suppose that every monitor has a separate mutual exclusion lock, so that different threads can run in different monitors concurrently, and that we want to release exclusion on both inner and outer...
-
Compare Java final methods with C++ nonvirtual methods. How are they the same? How are they different?
-
If you have taken a course in automata theory or recursive function theory, explain why while loops are strictly more powerful than for loops. (If you havent had such a course, skip this question!)...
-
Do any problems arise when translating physical assets and economic events into monetary units? Give one or two illustrations to support your answer.
-
Entries for the Warren Clinic 2015 income statement are listed below in alphabetical order. Reorder the data in proper format. Depreciation expense General/administrative expenses Interest expense $...
-
Great Forks Hospital reported net income for 2015 of \($2.4\) million on total revenues of \($30\) million. Depreciation expense totaled \($1\) million. a. What were total expenses for 2015? b. What...
Study smarter with the SolutionInn App