CS3360 Design and Implementation of Programming Languages Final Exam May 16, pm to 12:45pm (2 hour and 40 minutes) NAME:

Similar documents
MIDTERM EXAMINATION - CS130 - Spring 2005

MIDTERM EXAMINATION - CS130 - Spring 2003

CS 3360 Design and Implementation of Programming Languages. Exam 1

11. a b c d e. 12. a b c d e. 13. a b c d e. 14. a b c d e. 15. a b c d e

Question Marks 1 /12 2 /6 3 /14 4 /8 5 /5 6 /16 7 /34 8 /25 Total /120

COMP 524 Spring 2018 Midterm Thursday, March 1

CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam

CS2102, D15 Exam 1. Name:

Question Marks 1 /11 2 /4 3 /13 4 /5 5 /11 6 /14 7 /32 8 /6 9 /11 10 /10 Total /117

CS164: Midterm I. Fall 2003

CS 3360 Design and Implementation of Programming Languages. Exam 1

CMSC 331 Final Exam Section 0201 December 18, 2000

CSCI 3155: Principles of Programming Languages Exam preparation #1 2007

Total Score /1 /20 /41 /15 /23 Grader

CS 415 Midterm Exam Spring 2002

CS143 Final Fall 2009

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

CS 223: Data Structures and Programming Techniques. Exam 2

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

CSE413 Midterm. Question Max Points Total 100

CPSC 311: Analysis of Algorithms (Honors) Exam 1 October 11, 2002

Midterm I - Solution CS164, Spring 2014

CS143 Final Spring 2016

n Closed book n You are allowed 5 cheat pages n Practice problems available in Course Materials n Check grades in Rainbow grades

COP4020 Spring 2011 Midterm Exam

CS 201 Exam 3 Spring 2005 Grading Key

COMPUTER SCIENCE TRIPOS

CS 132 Compiler Construction, Fall 2012 Instructor: Jens Palsberg Multiple Choice Exam, Nov 6, 2012

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

Introduction to Algorithms October 12, 2005 Massachusetts Institute of Technology Professors Erik D. Demaine and Charles E. Leiserson Quiz 1.

R13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA.

CS56 final (E03) W15, Phill Conrad, UC Santa Barbara Wednesday, 03/18/2015. Name: Umail umail.ucsb.edu. Circle one: 4pm 5pm 6pm

UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING ECE 250 ALGORITHMS AND DATA STRUCTURES

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

cs173: Programming Languages Final Exam

Examination in Compilers, EDAN65

Question Points Score

Chapter 3 (part 3) Describing Syntax and Semantics

Programming Languages Third Edition

CS152 Programming Language Paradigms Prof. Tom Austin, Fall Syntax & Semantics, and Language Design Criteria

Programming Language Concepts, cs2104 Lecture 01 ( )

Name EID. (calc (parse '{+ {with {x {+ 5 5}} {with {y {- x 3}} {+ y y} } } z } ) )

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

Programming Languages and Techniques (CIS120)

Midterm II CS164, Spring 2006

CSc 372, Fall 2001 Final Examination December 14, 2001 READ THIS FIRST

DO NOT OPEN UNTIL INSTRUCTED

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

CS 415 Midterm Exam Fall 2003

CS 415 Midterm Exam Spring SOLUTION

San José State University College of Science/Department of Computer Science CS 152, Programming Language Paradigms, Section 03/04, Fall, 2018

Fall 2016 CSE Qualifying Exam CSCE 531, Compilers

Spring 2018 PhD Qualifying Exam in Languages

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

Program Abstractions, Language Paradigms. CS152. Chris Pollett. Aug. 27, 2008.

PL Revision overview

Prelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer

Introduction to Algorithms May 14, 2003 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser.

CSE 143, Winter 2009 Sample Midterm Exam #2

G COURSE PLAN ASSISTANT PROFESSOR Regulation: R13 FACULTY DETAILS: Department::

First Midterm Exam CS164, Fall 2007 Oct 2, 2007

Largest Online Community of VU Students

Semester Review CSC 301

UNIVERSITY OF CALIFORNIA

CS 164 Handout 16. Final Examination. There are nine questions on the exam, some in multiple parts. You have 3 hours to work on the

CIS 110 Introduction to Computer Programming Summer 2018 Midterm. Recitation ROOM :

CS4215 Programming Language Implementation

Exam Data structures DAT036/DAT037/DIT960

CS134 Spring 2005 Final Exam Mon. June. 20, 2005 Signature: Question # Out Of Marks Marker Total

Informal Semantics of Data. semantic specification names (identifiers) attributes binding declarations scope rules visibility

Programming Paradigms Written Exam (6 CPs)

Comp 311: Sample Midterm Examination

Final Examination CSE 100 UCSD (Practice)

CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2013

c) A perfect ternary tree of height h? (In a ternary tree, each node may have up to three children.)

CS2110 Assignment 2 Lists, Induction, Recursion and Parsing, Summer

Programming Languages, Summary CSC419; Odelia Schwartz

CMSC 330: Organization of Programming Languages. Operational Semantics

CSE Data Structures and Introduction to Algorithms... In Java! Instructor: Fei Wang. Mid-Term Exam. CSE2100 DS & Algorithms 1

CSE 401 Final Exam. December 16, 2010

CS 132 Compiler Construction, Fall 2011 Instructor: Jens Palsberg Multiple Choice Exam, Dec 6, 2011

COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz

CS 6371: Advanced Programming Languages

Exam Datastrukturer. DIT960 / DIT961, VT-18 Göteborgs Universitet, CSE

CS 61B: Midterm Exam I

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CPS 506 Comparative Programming Languages. Syntax Specification

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

Programmiersprachen (Programming Languages)

INSTITUTE OF AERONAUTICAL ENGINEERING

CS Compiler Construction West Virginia fall semester 2014 August 18, 2014 syllabus 1.0

NAME: c. (true or false) The median is always stored at the root of a binary search tree.

Midterm 1. CMSC 430 Introduction to Compilers Spring Instructions Total 100. Name: March 14, 2012

CSE 332, Spring 2010, Midterm Examination 30 April 2010

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

CS 2150 (fall 2010) Midterm 2

Chapter 3. Describing Syntax and Semantics

Sample Exam; Solutions

Transcription:

CS3360 Design and Implementation of Programming Languages Final Exam May 16, 2013 10pm to 12:45pm (2 hour and 40 minutes) NAME: GRADE = / 140 1. Choice of Programming Languages / 25 2. Programming languages: Design Issues / 30 3. Programming / 20 4. Grammars / 20 5. Dynamic Semantics / 10 6. Storage and Type Binding /20 7. Parameter Passing /15 Rules: This exam is to be done individually. Class notes, cheat sheets, and books of any kind are NOT allowed. You must write legibly and in a structured manner: unreadable answers will be graded 0; messy / hard-to-follow answers will be penalized by taking off up to 75% of the points of the corresponding question. Cell phones should be turned off, no headsets allowed. Turn in your exam by 12:45pm sharp: no exam will be accepted past this time. 1

1 Choice of Programming Languages/Paradigms [25 points + 5 points of extra-credit] 1.1 What does AspectJ bring to Java? Which dimension(s) of the evaluation of a programming language can it enhance, and how? [10 points] 1.2 Suppose that you have to design a piece of software to determine the best schedule of courses in your department. You know which courses need to be offered, who can teach what, how many courses does each instructor teach, which classes can each instructor teach, etc. Which programming language/paradigm would you recommend using and why?. [10 points] 2

1.3 Name and discuss a programming language of your choice, specify the programming paradigm it belongs to, and evaluate it critically using the dimensions and criteria we presented and discussed in class. [10 points] 2 Programming Languages: Design issues [30 points + 10 points of extra-credit] 2.1 Discuss how aliasing affects (positively or negatively) the reliability of programming languages that allow it. [5 points] 2.2 Give an example of implicit heap dynamic variables along with the corresponding programming language. [5 points] 3

2.3 Discuss the advantages and inconvenients of static variables. [10 points] 2.4 Discuss the advantages and inconvenients of dynamically-typed variables. [10 points] 2.5 Discuss the feasibility of implementing a in-out parameter-passing method in a programming language that does not allow aliasing. [10 points] 4

3 Programming [20 points] 3.1 Functional Programming [10 points] Consider the following piece of code: module Main where mystery n = if n == 0 then 1 else n * mystery (n - 1) main = do putstrln What is mystery(5)?" x readln if x == mystery 5 then putstrln You re right!" else putstrln You re wrong!" What does mystery do? What does the above main function do? What can you say about variable x? (e.g., type binding, storage binding) 3.2 Logic Programming [10 points] 1. Consider the following Prolog code: mystery(x,[ ]):-!. mystery(x,[y L]):- X \ = Y, mystery(x,l). 5

What does this predicate do? What is the result of mystery(2,[1,3,5]).? 2. Consider the following Prolog code: What does this predicate do? mystery2([ ],[H,R]). mystery2([x T],[H,R]):- (X = H; X = R), mystery2(t,[h,r]). What is mystery2([2,4,6],[2,4]).? How can you improve the above code so that the compiler will not throw any warning? 6

4 Grammars [20 points + 5 points of extra credit] 4.1 Translate the following grammar from EBNF to BNF. [10 points] <sequence> <letter> {(<letter> <digit>)} @ <letter> {(<letter> <digit>)}. (fr com edu) 4.2 Attribute Grammar. [15 points] Consider the following grammar that defines binary trees. <BT> (<BT> <value> <BT>) nil <value> 0 1... 9 where nil stands for the empty tree. Draw the parse tree of the following tree [5 points]: 7

Augment the above grammar with attributes so that only balanced binary trees are allowed (balanced binary trees are trees such each node in the tree is such that the number of levels of its left subtree does not differ from the number of levels of its right subtree by more than 1) [10 points]. Note: use the following attribute of <BT>: actual-number-of-levels. 8

5 Dynamic semantics [10 points + 20 points of extra-credit] 5.1 Operational semantics [10 points] Write the operational semantics of if B then C else D. 5.2 Denotational semantics [10 points] Write the denotational semantics of do C while B. 5.3 Axiomatic semantics [10 points] Consider the following fragment of code with its given general post-condition: {???} y = 2x + y; if (y is even) then x = 2y; else x = 2y + 1; { x > 0} Determine the weakest precondition of this fragment of code. Justify your answer and detail your reasoning. 9

6 Storage and Type Binding [20 points] 6.1 Answer the following questions [20 points] 1. When talking about stack-dynamic variables, heap-dynamic variables, what do we refer to? storage binding type binding other; explain: 2. Stack-dynamic variables are: statically bound to type dynamically bound to type other; explain: 3. Heap-dynamic variables are: statically bound to type dynamically bound to type other; explain: 4. When it comes to type binding, what are the three main types of type binding: (a)... (b)... (c)... 10

7 Parameter-passing methods [15 points + 5 points of extra credit] 7.1 What is the mode of pass-by-reference parameter-passing methods? [5 points] 7.2 Discuss the differences and pros-cons of pass-by-reference and pass-byvalue-result parameter-passing methods? [10 points] 7.3 Consider the following program is run using pass-by-value-result parameterpassing mode. What are the values in the variables at the end of execution? [5 points] void fun (int first, int second) { first=second; second=10; } void main () { int list[2] = {1,3}; fun(list[0],list[1]); } 11