Spring 2018 PhD Qualifying Exam in Languages

Similar documents
Qualifying Exam Languages

Programming Languages and Compilers Qualifying Examination. Answer 4 of 6 questions.

Midterm I - Solution CS164, Spring 2014

Synchronization: Semaphores

MIDTERM EXAMINATION - CS130 - Spring 2003

CS 3360 Design and Implementation of Programming Languages. Exam 1

Forward Assignment; Strongest Postconditions

Formal Methods. CITS5501 Software Testing and Quality Assurance

CS164: Midterm I. Fall 2003

CS 3360 Design and Implementation of Programming Languages. Exam 1

MIDTERM EXAM (Solutions)

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

Lecture Notes: Hoare Logic

Shared Variables and Interference

Guarded Commands, Nondeterminancy and Formal Derivation of Programs. Edsger W. Dijkstra. CACM 18, 8 pp (Aug. 1975).

CSE331 Winter 2014, Midterm Examination February 12, 2014

CSCE 110: Programming I

EXAMINATIONS 2009 END-OF-YEAR. COMP 202 / SWEN 202 Formal Methods of Computer Science / Formal Foundations of Software Engineering

Outline. Introduction to Programming (in C++) Introduction. First program in C++ Programming examples

CSE wi Midterm Exam 2/8/18. Name UW ID #

CS 164 Handout 11. Midterm Examination. There are seven questions on the exam, each worth between 10 and 20 points.

Assertions & Verification & Example Loop Invariants Example Exam Questions

Assertions & Verification Example Exam Questions

Hoare Logic: Proving Programs Correct

Midterm I (Solutions) CS164, Spring 2002

Lexical Analysis. Lecture 3. January 10, 2018

CSE 582 Autumn 2002 Exam 11/26/02

Spring 2017 CS 1110/1111 Exam 1

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

Shared Variables and Interference

MIDTERM EXAMINATION - CS130 - Spring 2005

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

My dear students, Believe in yourselves. Believe in your abilities. You have got this! -Dr. M

Lexical Analysis. Lecture 3-4

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

(the bubble footer is automatically inserted into this space)

CSE 105 THEORY OF COMPUTATION

CpSc 421 Final Solutions

CSE331 Winter 2014, Midterm Examination February 12, 2014

CS 415 Midterm Exam Spring 2002

COS 126 General Computer Science Spring Written Exam 1

COMPSCI 230 Discrete Math Prime Numbers January 24, / 15

Lecture 2. CS118 Term planner. Refinement. Recall our first Java program. Program skeleton GCD. For your first seminar. For your second seminar

CS 164 Programming Languages and Compilers Handout 9. Midterm I Solution

CSE 105 THEORY OF COMPUTATION

Lecture 15: Iteration and Recursion

COMP 507: Computer-Aided Program Design

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

CS 1301 Exam 1 Fall 2010

CS143 Final Fall 2009

CPSC 121 Some Sample Questions for the Final Exam Tuesday, April 15, 2014, 8:30AM

Solutions to the Second Midterm Exam

Theory of Computations Spring 2016 Practice Final Exam Solutions

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

Exam 1 CSCI 2600 Principles of Software October 6, 2015

CSE 331 Midterm Exam 2/13/12

CSE 307: Principles of Programming Languages

CS 373: Combinatorial Algorithms, Spring 1999

CS 1301 Exam 1 Fall 2010

Homework 1 Due Tuesday, January 30, 2018 at 8pm

UVa ID: NAME (print): CS 4501 LDI Midterm 1

Programming Languages and Compilers Qualifying Examination. Answer 4 of 6 questions.1

15-122: Principles of Imperative Computation (Section G)

CMPSCI 250: Introduction to Computation. Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014

Spring 2017 CS 1110/1111 Exam 3

Intro to semantics; Small-step semantics Lecture 1 Tuesday, January 29, 2013

First Midterm Exam CS164, Fall 2007 Oct 2, 2007

Reasoning About Imperative Programs. COS 441 Slides 10

1 Elementary number theory

Lectures 20, 21: Axiomatic Semantics

CS 536 Midterm Exam Spring 2013

Reasoning about programs

CSE 331 Summer 2016 Final Exam. Please wait to turn the page until everyone is told to begin.

Last time. Reasoning about programs. Coming up. Project Final Presentations. This Thursday, Nov 30: 4 th in-class exercise

Midterm Exam. CS169 Fall November 17, 2009 LOGIN: NAME: SID: Problem Max Points Points TOTAL 100

Prelim 1. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants

CS152: Programming Languages. Lecture 2 Syntax. Dan Grossman Spring 2011

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

Proving Programs Correct

Backward Reasoning: Rule for Assignment. Backward Reasoning: Rule for Sequence. Simple Example. Hoare Logic, continued Reasoning About Loops

Structure and Interpretation of Computer Programs

Iterative Statements. Iterative Statements: Examples. Counter-Controlled Loops. ICOM 4036 Programming Languages Statement-Level Control Structure

9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement

6. Discuss how producer-consumer problem and Dining philosophers problem are solved using concurrency in ADA. [16]

CS4411 Intro. to Operating Systems Exam 1 Fall points 10 pages

Spring 2017 CS 1110/1111 Exam 2

Structure and Interpretation of Computer Programs

Integers and Mathematical Induction

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1

CSE wi Midterm Exam 2/8/18 Sample Solution

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

Midterm I Exam Principles of Imperative Computation Frank Pfenning, Tom Cortina, William Lovas. September 30, 2010

Question Points Score

Lexical Analysis. Lecture 2-4

The exam is closed book, closed calculator, and closed notes except your one-page crib sheet.

UNIVERSITY OF CALIFORNIA

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

CSE332 Summer 2010: Final Exam

Lexical Analysis. Chapter 2

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Transcription:

Spring 2018 PhD Qualifying Exam in Languages Illinois Institute of Technology Department of Computer Science Monday, January 29, 2018 Instructions This exam is closed book and closed notes. Read each problem very carefully and do all the listed problems. Write your exam id at the top of every page, in the indicated space. Write your answers only on the fronts of the pages. Wrote only within the dashed rectangles. Extra pages appear at the end of the exam you may use them as extra space for answers. Use the back of each sheet for scratch work; you aren't allowed extra paper for scratch work. You may unstaple the exam, but you must return all the exam pages. To pass the entire exam, you must pass both halves of the exam. Problem Points Score Problem Points Score 1 20 4 6 5 5 2 10 6 9 7 15 3 20 8 15 CS 440 Total 50 CS 536 Total 50 Grand Total 100 PhD Qualifying Exam in Languages 1 Spring 2018

Part I: CS440 Question 1: Languages (20 points) Please do NOT use more than three sentences to answer each of the following questions. We will NOT grade anything after the third sentence in your answer sheet. Some languages such as Python and Java are compiled to a byte code instead machine code. 1a. [3 points] What advantages does this have? 1b. [3 points] What disadvantages? (Closures) 1c. [3 points] What is a closure? 1d. [3 points] What advantages does it give a language to have them? PhD Qualifying Exam in Languages 2 Spring 2018

1e. [4 points] We can divide languages roughly into two classes: statically typed (e.g., Java, Haskell, C++) and dynamically typed (e.g., Lisp, Clojure, Ruby). Explain the tradeoffs between these two systems. 1f. [4 points] Many languages support parametric polymorphism. Examples include Haskell s type variables, Java generics, and C++ templates. What advantage does parametric polymorphism give to the programmer? PhD Qualifying Exam in Languages 3 Spring 2018

Question 2: Abstraction (10 points) Make your answers concise and to the point. Write at most three sentences for each answer. You will lose points for excessively long-winded answers. 2a. [5 points] What is an abstract data type? (Please note, an abstract type, not an abstract class.) 2b. [5 points] Give three distinct advantages that abstract data types provide. PhD Qualifying Exam in Languages 4 Spring 2018

Question 3: Grammars (20 points) Consider the following grammar: S E x a b E E S c S 3a. [5 points] Give the First and Follow sets for the non-terminals. 3b. [7 points] Construct the Characteristic Finite State Machine. 3c. [4 points] Convert the above grammar to an LL grammar, explain why it s already LL, or explain why it cannot be converted to LL. 3d. [4 points] Is the above grammar ambiguous? Give a proof with your answer. PhD Qualifying Exam in Languages 5 Spring 2018

Part II: CS536 Question 4: Meaning of Programs (6 points) 4a. [3 points] Let W while i n do S od, where S y := y+1 ; i := i+1, and σ ={i = 1, y = 1, n = 2}. Calculate M(W, σ) (or M[[W]](σ), depending on the notation you learned) 4b. [3 points] Let W i := i+1 ; b[i] := b[1]+5, and σ = {i = 0, b[0] = 3, b[1] = 4}. Calculate M(W, σ). Question 5: Validity of Hoare Triples (5 points) Each part below is worth a maximum of 2.5 points if correctly answered, 0 points of left unanswered, and -1 point if answered incorrectly. Let x be an integer variable (positive, negative, or zero). For each triple below say whether it is partially correct, totally correct, both, or neither. 5a. {x > 0} x := x-1 {x > 0} 5b. {x < 0} while x 0 do x := x+1 od {x = 0} PhD Qualifying Exam in Languages 6 Spring 2018

Question 6: Deterministic and Nondeterministic wp and sp (9 points) Calculate the weakest preconditions and strongest postconditions as requested. Please show your work. 6a. [3 points] wp(if x > 0 then s := x * y else s := -x * y fi {s > 0} 6b. [3 points] sp(y 1, y := y+5) 6c. [3 points] Let p be wp(s, q). Suppose also that there is a state σ that does not satisfy p, but nonetheless, running S in σ terminates successfully but in a memory state that does satisfy q. Explain how this could happen. PhD Qualifying Exam in Languages 7 Spring 2018

Question 7: Deterministic Loop Programs (15 points) The greatest common divider (gcd) of two positive integers x and y is the largest value that divides both x and y evenly (without remainder). For example, gcd(30, 18) = 6. The relevant gcd properties are: if x > y, then gcd(x, y) = gcd(x-y, y) if y > x, then gcd(x, y) = gcd(x, y-x) if x = y, then gcd(x, y) = x (= y) For example, gcd(30, 18) = gcd(12, 18) = gcd(12, 6) = gcd(6, 6) = 6 7a. [8 points] Write the gcd(a, b) program. Include a precondition and postcondition, but omit other conditions. 7b. [7 points] Now expand your program from the previous part into a full proof outline for total correctness. PhD Qualifying Exam in Languages 8 Spring 2018

Question 8: Synchronization (15 points) Consider the following concurrent program {true} x := 1 ; y := 1; {true} [ {true} await y > 0 then x := 2 end {x 0} {true} await x > 0 then y := 2 end {y 0} ] {x 0 y 0} 8a. [5 points] List all its potential deadlock predicates 8b. [10 points] Strengthen the conditions and get an new outline that is deadlock-free. Write out the new outline and list the new potential deadlock predicates. PhD Qualifying Exam in Languages 9 Spring 2018

This page left blank for your use PhD Qualifying Exam in Languages 10 Spring 2018

This page left blank for your use PhD Qualifying Exam in Languages 11 Spring 2018