Testing, Debugging, and Verification exam DIT082/TDA567. Day: 9 January 2016 Time: Will be published mid February or earlier
|
|
- Jason Collin McDaniel
- 5 years ago
- Views:
Transcription
1 Testing, Debugging, and Verification exam DIT08/TDA567 Responsible: Day: 9 January 016 Time: Atze van der Ploeg Results: Extra aid: Will be published mid February or earlier Only dictionaries may be used. Other aids are not allowed! Grade intervals: U: 0 18p, 3: 19 4 p, 4: 5 9p, 5: 30 37p, G: 19 9p, VG: 30 37p, Max. 37p. Please observe the following: This exam has 14 numbered pages. Please check immediately that your copy is complete Answers must be given in English Please use page numbering on your pages Please write clearly Fewer points are given for unnecessarily complicated solutions Indicate clearly when you make assumptions that are not given in the assignment Answers to the exam will be published on the course website tomorrow. Good luck! 1
2
3 Exam/Tenta DIT08/TDA567 9 Jan Testing Assignment 1 Certainty and Testing (p) In most cases, unit testing can give some assurances, but not guarantees for all inputs. Explain why in most cases unit testing cannot give such hard guarantees. Methods typically have an (practically) infinite number of inputs. It is hence impossible to have a unit test for each possible input. Assignment Coverage (4p) Consider the following piece of Java code: class Group{ private final String[] names; Group(String[] names){ this.names = names; // requires: All elements of names are non-null // ensures: returns true if and only if // there is an element in // names that equals name boolean ispartofgroup(string name){ if(name == null) { return false; for(int i = 0; i < names.length ; i ++){ if(name.equals(names[i])){ return true; return false; Construct a Java class where the methods are tests of the ispartofgroup method above, such that the test-cases together provide statement coverage.
4 Exam/Tenta DIT08/TDA567 9 Jan class Test{ static Group g = new Group( new String[]{"simon", "mauricio", void test1() { assertequals(g.ispartofgroup(null), void test() { assertequals(g.ispartofgroup("mauricio"), void test3() { assertequals(g.ispartofgroup("gustav"), false);
5 Exam/Tenta DIT08/TDA567 9 Jan Assignment 3 Mutation testing (4p) Consider the following Java method: /* requires: input left and right are non-null arrays which are sorted in non-decreasing order ensures: output is a non-null array, sorted in non-decreasing order, such that for any integer i, the number of occurrences in the output of i, is equal to the number of occurrences in the left arrays of i plus the number of occurrences in the right array of i. */ public static int[] merge(int[] left, int[] right){ int [] res = new int[left.length + right.length]; int il = 0, ir = 0, i = 0; while(il < left.length && ir < right.length){ if(left[il] <= right[ir]){ res[i] = left[il]; il += 1; i += 1; else { res[i] = right[ir]; ir += 1; i += 1; while (il < left.length) { res[i] = left[il]; il += 1; i += 1; while (ir < right.length) { res[i] = right[ir]; ir += 1; i += 1; return res; Ludvig has constructed a set of tests for this method which consists of the following tests (in shorthand): merge({,{) == { merge({,,3,{1,1,1) == {1,1,1,,,3 merge({0,1,3,5,{,4) == {0,1,,3,4,5 Ludvig thinks that he does not need more tests: he cannot imagine a bug that he has not tested for. You, as a fresh expert on testing, do not agree with Ludvig.
6 Exam/Tenta DIT08/TDA567 9 Jan Show that Ludvig is wrong: construct a mutant of the method that does not conform to the specification, but that is not killed by Ludvig s test set. For example: public static int[] merge(int[] left, int[] right){ int [] res = new int[left.length + right.length]; int il = 0, ir = 0, i = 0; while(il < left.length && ir < right.length){ if(left[il] <= right[ir]){ res[i] = left[il]; il += 1; i += 1; else { res[i] = right[ir]; ir += 1; i += 1; while (il < left.length) { res[i] = left[il]; il += 1; i += 1; while (false) { // <- mutate here res[i] = right[ir]; ir += 1; i += 1; return res; This code is wrong, but none of the tests from Ludvig s tests fail (kill the mutant).
7 Exam/Tenta DIT08/TDA567 9 Jan Assignment 4 Test driven development (p) The test driven development methodology is often summarized as red-green-refactor. Explain what red-green-refactor means. The process is as follows: 1. Write tests, make sure they fail (red).. Implement method, make sure the tests succeed(green). 3. Clean up code (refactor). Assignment 5 Minimization (5p) Suppose we have method f which takes an array of characters as input and suppose that this method computes the output incorrectly if the input contains an even number of X characters (but not zero), and otherwise computes the result correctly. The shortest example of a string which contains an even number of X characters is the string "XX". However, Sven has used a correct implementation of the ddmin algorithm to minimize a failing example of the method f, and the result was not "XX" but "XXXX". (a) Explain why this is possible. (p) The ddmin algorithm computes a 1-minimal failing input, which means an input where if you remove any single character, the resulting input succeeds. To go from "XXXX" to "X" you need to remove two characters at the same time. So ddmin does not guarantee that it will reduce "XXXX" to "XX". (b) Simulate a run of the ddmin algorithm and compute a 1-minimal failing input from the following initial failing input: [x,a,x,x,c,x,x,x]. Clearly state what happens at each step of the algorithm and what the final result is. (3p) Start with granularity n = and sequence [x,a,x,x,c,x,x,x].
8 Exam/Tenta DIT08/TDA567 9 Jan The number of chunks is ==> n :, [x, a, x, x] PASS (take away first chunk) ==> n :, [c, x, x, x] PASS (take away second chunk) Increase number of chunks to min(n, len([x, a, x, x, c, x, x, x])) = 4 ==> n : 4, [x, x, c, x, x, x] PASS (take away first chunk) ==> n : 4, [x, a, c, x, x, x] FAIL (take away second chunk) Adjust number of chunks to max(n 1, ) = 3 ==> n : 3, [c, x, x, x] PASS (take away first chunk) ==> n : 3, [x, a, x, x] PASS (take away second chunk) ==> n : 3, [x, a, c, x] FAIL (take away third chunk) Adjust number of chunks to max(n 1, ) = ==> n :, [x, a] PASS (take away first chunk) ==> n :, [c, x] PASS (take away first chunk) Increase number of chunks to min(n, len([l, f, o, o]) = 4 ==> n : 4, [a, c, x] PASS (take away first chunk) ==> n : 4, [x, c, x] Fail (take away second chunk) Adjust number of chunks to max(n 1, ) = 3 ==> n : 4, [c, x] PASS (take away first chunk) ==> n : 3, [x, x] Fail (take away second chunk) Adjust number of chunks to max(n 1, ) = ==> n : 4, [x] PASS (take away first chunk) ==> n : 3, [x] PASS (take away second chunk) As n == len([x, x]) the algorithm terminates with 1-minimal failing input [x, x]
9 Exam/Tenta DIT08/TDA567 9 Jan Assignment 6 Formal Specification (1) (3p) CompCert is a verified compiler from C to assembly. Briefly explain what we mean when we say that CompCert is a verified compiler from C to assembly. Use at least the following words in your answer: specification, behavior, proof. CompCert has three ingredients: A formal specification of the C language, which states which input/output behaviors can be exhibited by a a program in C. A formal specification of the assembly language, which states which input/output behaviors can be exhibited by a a program in assembly. An executable mathematical function which translates a program in C to a program in assembly. When we say that CompCert is verified, we mean that there is a proof that if a compiled version of a program (in assembly) can exhibit some behavior according to the specification of the assembly language, then this behavior can also be exhibited by the uncompiled version (in C) according to the specification of the C language. (Less accurate, but also OK is if a student says that there is a proof that that all input-output behaviors that can be exhibited by the source program can also exhibited by the target program) Assignment 7 Formal Specification () (7p) In this question you are going to specify and implement a method that gives a reversed copy of an array in Dafny. For example, the result of running the method on an array containing [1,,3,4] will be a new array containing [4,3,,1]. The header of the method is as follows: method reverse(a : array<int>) returns (res : array<int>) requires a!= null ensures? (a) Complete the specification of reverse by filling in the ensures field. (3p)
10 Exam/Tenta DIT08/TDA567 9 Jan res!= null && res.length == a.length && forall i : int :: 0 <= i < a. Length ==> res[i] == a[a.length i] (b) Implement the reverse method. Use a while loop and provide a loop invariant and decrease clauses such that Dafny will be able to prove total correctness. (It is not allowed to use a parallel for loop.) (4p) var i := 0; res := new int[a.length]; while i < a.length invariant 0 <= i <= a.length invariant forall j : int :: 0 <= j < i ==> res[j] == a[a.length j] { res[i] := a[a.length i]; i := i + 1;
11 Exam/Tenta DIT08/TDA567 9 Jan Assignment 8 (Formal Verification) (10p) A remarkable fact of numbers is that the sum of the natural numbers 0 till n is n(n+1). In other words (assuming n ): n = n(n + 1) For example, = 5(5+1) = 15 In this question, you are going to prove that n = n(n+1) is true using the weakest-precondition calculus. The expression n(n+1) is implemented by sumn: function sumn(n : int) : int { n * (n + 1) / The following method implements n: method sum(n : nat) returns (s : nat) ensures s == sumn(n) { i := 0; s := 0; while i < n invariant i <= n && s == sumn(i) decreases n - i { i := i + 1; s := s + i; Prove total correctness (including termination) for the above program. You can assume: sumn(0) = 0 s == sum(i) ==> s + (i + 1) == sum(i+1) (or sumn(i) + (i + 1) = sumn(i + 1)) (below I explain why this is true in case you are interested, but this is not needed to make the exam.) Recall that a method without an requires clause is the same as a method with the clause requires true.
12 Exam/Tenta DIT08/TDA567 9 Jan Compute weakest postcondition : wp( i := 0; s := 0 ; while..., s == sumn(n)) Apply seq rule (x) wp( i := 0, wp( s := 0, wp(while..., s == sumn(n)))) Compute wp(while..., s == sumn(n)) first wp(while (i < n) (i <= n && s == sum(i)) (n-i) i := i + 1; s := s+i, s == sum(n)) Which expands to (these should all hold): 1. Invariant holds before loop: i <= n && s == sum(i). Invariant maintained in loop: i < n && i <= n && s == sum(i) ==> wp(i := i + 1; s := s+i, i <= n && s == sum(i) 3. Invariant and loop fail implies postcondition:!(i < n) && i <= n && s == sum(i) ==> s == sumn(n) 4. Decreases clause always positive : i <= n && s == sum(i) ==> n - i >= 0 5. Iteration decreases : i < n && i <= n && s == sum(i) ==> wp(tmp := n-i; i := i + 1; s := s+i, tmp > n - i) Simplify (): i < n && i <= n && s == sum(i) ==> wp(i := i + 1; s := s+i, i <= n && s == sum(i) Compute wp(i := i + 1; s := s+i, i <= n && s == sum(i)) Apply seq rule: wp(i := i + 1, wp(s := s + i, i <= n && s == sum(i)) Apply assignment rule (x) i <= n && s+(i + 1) == sum(i+1) Plug in to (): i < n && i <= n && s == sum(i) ==> i <= n && s+(i + 1) == sum(i+1) Simplify using i <= n is both before and after ==> and remove i < n s == sum(i) ==> s+(i + 1) == sum(i+1) This is an assumption we had, so reduces to true.
13 Exam/Tenta DIT08/TDA567 9 Jan Simplify (3) :!(i < n) && i <= n && s == sum(i) ==> s == sumn(n) Use!(i < n) = i >= n i >= n && i <= n && s == sum(i) ==> s == sumn(n) Use i >= n \&\& i <= n <==> i == n i == n && s == sum(i) ==> s == sumn(n) Use i == n in right hand side and remove i == n s == sum(i) ==> s == sumn(i) Simplify using a ==> a == True True Simplify (4) i <= n && s == sum(i) ==> n - i >= 0 Remove irrelevant: i <= n ==> n - i >= 0 Rewrite n - i >= 0 i <= n ==> n >= i Flip i <= n ==> i <= n Simplify using a ==> a == True True Simplify (5) i < n && i <= n && s == sum(i) ==> wp(tmp := n-i; i := i + 1; s := s+i, tmp > n - i) Compute: wp(tmp := n-i; i := i + 1; s := s+i, tmp > n - i) Seq rule (x) wp(tmp := n-i, wp(i := i + 1, wp( s := s+i, tmp > n - i))) Assignment rule (x 3) n - i > n - (i + 1) Simplify n - i > n - i - 1 True by a > a - 1 True Now,3,4,5 reduce to true. So the
14 Exam/Tenta DIT08/TDA567 9 Jan wp(while..., s == sumn(n)) = i <= n && s == sum(i) Plug back into: wp( i := 0, wp( s := 0, wp(while..., s == sumn(n)))) becomes: wp( i := 0, wp( s := 0, i <= n && s == sum(i))) Assignment (x) 0 == sum(0) Use assumption 0 == 0 True So weakest precondition of program is true. Now check that our precondition (true) implies that: True ==> True Which is True This is the end of the exam, you do not need to read further to make the exam! Below I explain why the assumptions above are true in case you are interested: The assumption s == sum(i) ==> s + (i + 1) == sum(i+1) follows from sumn(i) + (i + 1) = sumn(i + 1) But why does this hold? Here is a proof: n(n + 1) n(n + 1) + (n + 1) sumn(n) + (n + 1) = + (n + 1) = (n + )(n + 1) = sumn(n + 1) (total 37p)
CSE 331 Winter 2016 Midterm Solution
CSE 331 Winter 2016 Midterm Solution Name There are 7 questions worth a total of 100 points. Please budget your time so that you get to all of the questions. Keep your answers concise. The exam is closed
More informationLecture 10 Design by Contract
CS 5959 Writing Solid Code Fall 2015 Nov-23 Lecture 10 Design by Contract Zvonimir Rakamarić University of Utah Design by Contract Also called assume-guarantee reasoning Developers annotate software components
More informationFormal Methods. CITS5501 Software Testing and Quality Assurance
Formal Methods CITS5501 Software Testing and Quality Assurance Pressman, R. Software Engineering: A Practitioner s Approach. Chapter 28. McGraw-Hill, 2005 The Science of Programming, David Gries, 1981
More informationTesting, Debugging, and Verification
Testing, Debugging, and Verification Formal Specification, Part II Srinivas Pinisetty 23 November 2017 Introduction Today: Introduction to Dafny: An imperative language with integrated support for formal
More informationAnnouncements. Specifications. Outline. Specifications. HW1 is due Thursday at 1:59:59 pm
Announcements HW1 is due Thursday at 1:59:59 pm Specifications 2 Outline Specifications Benefits of specifications Specification conventions Javadoc JML PoS specifications Specifications A specification
More informationAnnouncements. Representation Invariants and Abstraction Functions. Announcements. Outline
Announcements Representation Invariants and Abstraction Functions Exam 1 on Monday Feb. 26 th Closed book/phone/laptop, 2 cheat pages allowed Reasoning about code, Specifications, ADTs I will post Review
More informationCOMP 507: Computer-Aided Program Design
Fall 2014 April 7, 2015 Goal: Correctness proofs Prove that an algorithm written in an imperative language is correct Induction for algorithmic correctness Induction for functional programs: The program
More informationAssertions & Verification & Example Loop Invariants Example Exam Questions
2014 November 27 1. Assertions & Verification & Example Loop Invariants Example Exam Questions 2. A B C Give a general template for refining an operation into a sequence and state what questions a designer
More informationExam in Testing. Justin Pearson. Dec Cover Sheet. Problem no. Solution provided Max Your points Total: 59
Exam in Testing Justin Pearson Dec. 2011 Cover Sheet Problem no. Solution provided Max Your points 1 10 2 7 3 12 4 8 5 10 6 12 Total: 59 Anonymous Exam Code. :... 1 Exam Rubric All answers to be written
More informationCSE 331 Midterm Exam Sample Solution 2/18/15
Question 1. (10 points) (Forward reasoning) Using forward reasoning, write an assertion in each blank space indicating what is known about the program state at that point, given the precondition and the
More informationBackward Reasoning: Rule for Assignment. Backward Reasoning: Rule for Sequence. Simple Example. Hoare Logic, continued Reasoning About Loops
Backward Reasoning: Rule for Assignment Hoare Logic, continued Reasoning About Loops { wp( x=expression,q) x = expression; { Q Rule: the weakest precondition wp( x=expression,q) is Q with all occurrences
More informationCSE331 Winter 2014, Midterm Examination February 12, 2014
CSE331 Winter 2014, Midterm Examination February 12, 2014 Please do not turn the page until 10:30. Rules: The exam is closed-book, closed-note, etc. Please stop promptly at 11:20. There are 100 points
More informationSoftwaretechnik. Program verification. Albert-Ludwigs-Universität Freiburg. June 28, Softwaretechnik June 28, / 24
Softwaretechnik Program verification Albert-Ludwigs-Universität Freiburg June 28, 2012 Softwaretechnik June 28, 2012 1 / 24 Road Map Program verification Automatic program verification Programs with loops
More informationReasoning about programs
Reasoning about programs Last time Coming up This Thursday, Nov 30: 4 th in-class exercise sign up for group on moodle bring laptop to class Final projects: final project presentations: Tue Dec 12, in
More informationLast time. Reasoning about programs. Coming up. Project Final Presentations. This Thursday, Nov 30: 4 th in-class exercise
Last time Reasoning about programs Coming up This Thursday, Nov 30: 4 th in-class exercise sign up for group on moodle bring laptop to class Final projects: final project presentations: Tue Dec 12, in
More informationCIS 341 Final Examination 4 May 2017
CIS 341 Final Examination 4 May 2017 1 /14 2 /15 3 /12 4 /14 5 /34 6 /21 7 /10 Total /120 Do not begin the exam until you are told to do so. You have 120 minutes to complete the exam. There are 14 pages
More informationDo you remember any iterative sorting methods? Can we produce a good sorting method by. We try to divide and conquer: break into subproblems
MERGESORT 315 Sorting Recursively Do you remember any iterative sorting methods? How fast are they? Can we produce a good sorting method by thinking recursively? We try to divide and conquer: break into
More informationSemantics. There is no single widely acceptable notation or formalism for describing semantics Operational Semantics
There is no single widely acceptable notation or formalism for describing semantics Operational Describe the meaning of a program by executing its statements on a machine, either simulated or actual. The
More informationChapter 3. Describing Syntax and Semantics ISBN
Chapter 3 Describing Syntax and Semantics ISBN 0-321-49362-1 Chapter 3 Topics Describing the Meanings of Programs: Dynamic Semantics Copyright 2015 Pearson. All rights reserved. 2 Semantics There is no
More informationSpecifications. Prof. Clarkson Fall Today s music: Nice to know you by Incubus
Specifications Prof. Clarkson Fall 2015 Today s music: Nice to know you by Incubus Question Would you like a tiny bonus to your final grade for being here on time today? A. Yes B. Sí C. Hai D. Haan E.
More informationAssertions & Verification Example Exam Questions
2009 November 23 Assertions & Verification Example Exam Questions 1. 2. A B C Give a general template for refining an operation into a sequence and state what questions a designer must answer to verify
More informationCSE 143 Lecture 14. Sorting
CSE 143 Lecture 14 Sorting slides created by Marty Stepp and Ethan Apter http://www.cs.washington.edu/143/ Sorting sorting: Rearranging the values in an array or collection into a specific order (usually
More informationPrelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer
Prelim 2 CS 2110, November 20, 2014, 7:30 PM 1 2 3 4 5 Extra Total Question True/False Short Answer Complexity Induction Trees Graphs Extra Credit Max 20 10 15 25 30 5 100 Score Grader The exam is closed
More informationRepresentation Invariants and Abstraction Functions
Representation Invariants and Abstraction Functions Outline Reasoning about ADTs Representation invariants (rep invariants) Representation exposure Checking rep invariants Abstraction functions CSCI 2600
More informationUnit 10: Sorting/Searching/Recursion
Unit 10: Sorting/Searching/Recursion Notes AP CS A Searching. Here are two typical algorithms for searching a collection of items (which for us means an array or a list). A Linear Search starts at the
More informationInduction and Semantics in Dafny
15-414 Lecture 11 1 Instructor: Matt Fredrikson Induction and Semantics in Dafny TA: Ryan Wagner Encoding the syntax of Imp Recall the abstract syntax of Imp: a AExp ::= n Z x Var a 1 + a 2 b BExp ::=
More informationEXAMINATIONS 2009 MID-TERM TEST. COMP 202 / SWEN 202 Formal Methods of Computer Science / Formal Foundations of Software Engineering WITH ANSWERS
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Time Allowed: 90 minutes EXAMINATIONS 2009 MID-TERM TEST COMP 202 / SWEN 202 Formal Methods
More informationChapter 3. Describing Syntax and Semantics
Chapter 3 Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings of Programs:
More informationCSE 331 Final Exam 12/9/13
Name There are 10 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes, closed
More informationChapter 3 (part 3) Describing Syntax and Semantics
Chapter 3 (part 3) Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings
More informationChapter 19 Verification of Counting Sort and Radix Sort
Chapter 19 Verification of Counting Sort and Radix Sort Stijn de Gouw, Frank S. de Boer, Jurriaan Rot Sorting is an important algorithmic task used in many applications. Two main aspects of sorting algorithms
More informationSoftwaretechnik. Program verification. Software Engineering Albert-Ludwigs-University Freiburg. June 30, 2011
Softwaretechnik Program verification Software Engineering Albert-Ludwigs-University Freiburg June 30, 2011 (Software Engineering) Softwaretechnik June 30, 2011 1 / 28 Road Map Program verification Automatic
More informationUniversity of Massachusetts Amherst, Electrical and Computer Engineering
University of Massachusetts Amherst, Electrical and Computer Engineering ECE 122 Midterm Exam 1 Makeup Answer key March 2, 2018 Instructions: Closed book, Calculators allowed; Duration:120 minutes; Write
More informationSearching Algorithms/Time Analysis
Searching Algorithms/Time Analysis CSE21 Fall 2017, Day 8 Oct 16, 2017 https://sites.google.com/a/eng.ucsd.edu/cse21-fall-2017-miles-jones/ (MinSort) loop invariant induction Loop invariant: After the
More informationLecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning
Lecture 1 Contracts 15-122: Principles of Imperative Computation (Spring 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,
More informationCSE 331 Spring 2018 Midterm
CSE 331 Spring 2018 Midterm Name There are 8 questions worth a total of 93 points. Please budget your time so that you get as many points as possible. We have done our best to make a test that folks can
More informationn 1 x i = xn 1 x 1. i= (2n 1) = n 2.
Questions 1. Use mathematical induction to prove that, for any n 1 n 1 x i = xn 1 x 1. (Recall that I proved it in a different way back in lecture 2.) 2. Use mathematical induction to prove that, for all
More informationProgram Verification (6EC version only)
Program Verification (6EC version only) Erik Poll Digital Security Radboud University Nijmegen Overview Program Verification using Verification Condition Generators JML a formal specification language
More informationHardware versus software
Logic 1 Hardware versus software 2 In hardware such as chip design or architecture, designs are usually proven to be correct using proof tools In software, a program is very rarely proved correct Why?
More informationTesting! Prof. Leon Osterweil! CS 520/620! Spring 2013!
Testing Prof. Leon Osterweil CS 520/620 Spring 2013 Relations and Analysis A software product consists of A collection of (types of) artifacts Related to each other by myriad Relations The relations are
More informationAssertions & Design-by-Contract using JML Erik Poll University of Nijmegen
Assertions & Design-by-Contract using JML Erik Poll University of Nijmegen Erik Poll - JML p.1/39 Overview Assertions Design-by-Contract for Java using JML Contracts and Inheritance Tools for JML Demo
More informationComputer-Aided Program Design
Computer-Aided Program Design Spring 2015, Rice University Unit 1 Swarat Chaudhuri January 22, 2015 Reasoning about programs A program is a mathematical object with rigorous meaning. It should be possible
More informationCSE331 Winter 2014, Midterm Examination February 12, 2014
CSE331 Winter 2014, Midterm Examination February 12, 2014 Please do not turn the page until 10:30. Rules: The exam is closed-book, closed-note, etc. Please stop promptly at 11:20. There are 100 points
More informationNew Concepts. Lab 7 Using Arrays, an Introduction
Lab 7 Using Arrays, an Introduction New Concepts Grading: This lab requires the use of the grading sheet for responses that must be checked by your instructor (marked as Question) AND the submission of
More informationa) Answer all questions. b) Write your answers in the space provided. c) Show all calculations where applicable.
Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2008 January Exam Question Max Internal
More informationHoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré
Hoare Logic COMP2600 Formal Methods for Software Engineering Rajeev Goré Australian National University Semester 2, 2016 (Slides courtesy of Ranald Clouston) COMP 2600 Hoare Logic 1 Australian Capital
More informationCMSC 433 Section 0101 Fall 2012 Midterm Exam #1
Name: CMSC 433 Section 0101 Fall 2012 Midterm Exam #1 Directions: Test is closed book, closed notes. Answer every question; write solutions in spaces provided. Use backs of pages for scratch work. Good
More informationPrelim 2 Solutions. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer
Prelim 2 Solutions CS 2110, November 20, 2014, 7:30 PM 1 2 3 4 5 Extra Total Question True/False Short Answer Complexity Induction Trees Graphs Extra Credit Max 20 10 15 25 30 5 100 Score Grader The exam
More informationPlease note that if you write the mid term in pencil, you will not be allowed to submit a remark request.
University of Toronto CSC148 Introduction to Computer Science Fall 2001 Mid Term Test Section L5101 Duration: 50 minutes Aids allowed: none Make sure that your examination booklet has 8 pages (including
More informationTesting and Debugging
Testing and Debugging Comp-303 : Programming Techniques Lecture 14 Alexandre Denault Computer Science McGill University Winter 2004 March 1, 2004 Lecture 14 Comp 303 : Testing and Debugging Page 1 Announcements...
More informationRecall our recursive multiply algorithm:
Recall our recursive multiply algorithm: PRECONDITION: x and y are both binary bit arrays of length n, n a power of 2. POSTCONDITION: Returns a binary bit array equal to the product of x and y. REC MULTIPLY
More informationto calculate Fib(N) very quickly 1 Task 1: High-school algebra helps to design your program
University of New South Wales SENG 2011 Software Engineering Workshop 2A 2014 Session 1 Assignment 2 Using coupling invariants to calculate Fib(N) very quickly Due Friday of Week 7 (Good Friday) 1 18 April
More informationIncremental Proof Development in Dafny
15-414 Lecture 17 1 Instructor: Matt Fredrikson Incremental Proof Development in Dafny TA: Ryan Wagner In this discussion, we ll see in more detail how to go about proving the total correctness of imperative
More informationLecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning
Lecture 1 Contracts 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,
More informationTrace call recsum(x, 3)
12. Section 8 Exercises Program Memory Exercise 8-1 Trace for this value of X Working memory Global Memory Trace call recsum(x, 3) GIVENS: x (an array of integers) n (number of elements to sum in x) RESULT:
More informationProgramming Languages and Compilers Qualifying Examination. Answer 4 of 6 questions.1
Programming Languages and Compilers Qualifying Examination Monday, September 19, 2016 Answer 4 of 6 questions.1 GENERAL INSTRUCTIONS 1. Answer each question in a separate book. 2. Indicate on the cover
More informationViolations of the contract are exceptions, and are usually handled by special language constructs. Design by contract
Specification and validation [L&G Ch. 9] Design patterns are a useful way to describe program structure. They provide a guide as to how a program fits together. Another dimension is the responsibilities
More informationCOS 126 General Computer Science Spring Written Exam 1
COS 126 General Computer Science Spring 2017 Written Exam 1 This exam has 9 questions (including question 0) worth a total of 70 points. You have 50 minutes. Write all answers inside the designated spaces.
More informationProf. Dr. A. Podelski, Sommersemester 2017 Dr. B. Westphal. Softwaretechnik/Software Engineering
Prof. Dr. A. Podelski, Sommersemester 2017 Dr. B. Westphal Softwaretechnik/Software Engineering http://swt.informatik.uni-freiburg.de/teaching/ss2017/swtvl Exercise Sheet 6 Early submission: Wednesday,
More informationLaboratorio di Algoritmi e Strutture Dati
Laboratorio di Algoritmi e Strutture Dati Guido Fiorino guido.fiorino@unimib.it aa 2013-2014 Maximum in a sequence Given a sequence A 1,..., A N find the maximum. The maximum is in the first or in the
More informationCHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science
CHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science Entrance Examination, 5 May 23 This question paper has 4 printed sides. Part A has questions of 3 marks each. Part B has 7 questions
More informationCSE 307: Principles of Programming Languages
CSE 307: Principles of Programming Languages Advanced Topics R. Sekar Topics 1 / 14 1. 2 / 14 Section 1 3 / 14 Semantics of Programs Syntax defines what programs are valid. Semantics defines what the valid
More informationSymbolic Execution and Proof of Properties
Chapter 7 Symbolic Execution and Proof of Properties Symbolic execution builds predicates that characterize the conditions under which execution paths can be taken and the effect of the execution on program
More informationEECS 481 Software Engineering Exam #1. You have 1 hour and 20 minutes to work on the exam.
EECS 481 Software Engineering Exam #1 Write your name and UM uniqname on the exam. There are ten (10) pages in this exam (including this one) and seven (7) questions, each with multiple parts. Some questions
More informationCITS5501 Software Testing and Quality Assurance Formal methods
CITS5501 Software Testing and Quality Assurance Formal methods Unit coordinator: Arran Stewart May 1, 2018 1 / 49 Sources Pressman, R., Software Engineering: A Practitioner s Approach, McGraw-Hill, 2005
More informationLecture 15 Binary Search Trees
Lecture 15 Binary Search Trees 15-122: Principles of Imperative Computation (Fall 2017) Frank Pfenning, André Platzer, Rob Simmons, Iliano Cervesato In this lecture, we will continue considering ways to
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
0/6/6 CS Introduction to Computing II Wayne Snyder Department Boston University Today Conclusions on Iterative Sorting: Complexity of Insertion Sort Recursive Sorting Methods and their Complexity: Mergesort
More informationLecture 6 Binary Search
Lecture 6 Binary Search 15-122: Principles of Imperative Computation (Spring 2018) Frank Pfenning One of the fundamental and recurring problems in computer science is to find elements in collections, such
More informationFinal Exam. COMP Summer I June 26, points
Final Exam COMP 14-090 Summer I 2000 June 26, 2000 200 points 1. Closed book and closed notes. No outside material allowed. 2. Write all answers on the test itself. Do not write any answers in a blue book
More informationQUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 13 th February
QUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 13 th February 2006 11.05-12.35 Please fill in your Examination Number here: Student Number here: All answers to
More informationCSE 331 Summer 2016 Final Exam. Please wait to turn the page until everyone is told to begin.
Name The exam is closed book, closed notes, and closed electronics. Please wait to turn the page until everyone is told to begin. Score / 54 1. / 12 2. / 12 3. / 10 4. / 10 5. / 10 Bonus: 1. / 6 2. / 4
More informationSpecifying and Verifying Programs (Part 2)
Specifying and Verifying Programs (Part 2) Wolfgang Schreiner Wolfgang.Schreiner@risc.jku.at Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria http://www.risc.jku.at
More informationChapter 12 Supplement: Recursion with Java 1.5. Mr. Dave Clausen La Cañada High School
Chapter 12 Supplement: Recursion with Java 1.5 La Cañada High School Recursion: Definitions Recursion The process of a subprogram (method) calling itself. A clearly defined stopping state must exist. The
More informationMidterm Exam 2 CS 455, Fall 2014
Name: USC NetId (e.g., ttrojan): Midterm Exam 2 CS 455, Fall 2014 November 11, 2014 There are 8 problems on the exam, with 62 points total available. There are 8 pages to the exam, including this one;
More informationCOS 126 Written Exam 2, Fall 2009
NAME: COS 126 Written Exam 2, Fall 2009 login ID: precept: This test is 11 questions, weighted as indicated. The exam is closed book, except that you are allowed to use a one page cheatsheet. No calculators
More informationhttps://www.lri.fr/ linaye/gl.html
Software Engineering https://www.lri.fr/ linaye/gl.html lina.ye@centralesupelec.fr Sequence 3, 2017-2018 1/61 Software Engineering Plan 1 2 3 4 5 2/61 Software Engineering Software Testing 3/61 Software
More informationPrelim 1, Solution. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer
Prelim 1, Solution CS 2110, 13 March 2018, 7:30 PM 1 2 3 4 5 6 Total Question Name Short answer Exception handling Recursion OO Loop invariants Max 1 30 11 14 30 14 100 Score Grader The exam is closed
More informationPrelim 2. CS 2110, 16 November 2017, 7:30 PM Total Question Name Short Heaps Tree Collections Sorting Graph
Prelim 2 CS 2110, 16 November 2017, 7:30 PM 1 2 3 4 5 6 7 Total Question Name Short Heaps Tree Collections Sorting Graph answer Max 1 18 10 25 10 16 20 100 Score Grader The exam is closed book and closed
More informationLecture 4 Specifications
CSE 331 Software Design and Implementation Administrivia Next assignments posted tonight HW2: Written problems on loops Lecture 4 Specifications Readings posted as well! Quizzes coming soon J Zach Tatlock
More informationCPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001
CPSC 211, Sections 201 203: Data Structures and Implementations, Honors Final Exam May 4, 2001 Name: Section: Instructions: 1. This is a closed book exam. Do not use any notes or books. Do not confer with
More informationCSE 331 Midterm Exam 11/9/15 Sample Solution
Remember: For all of the questions involving proofs, assertions, invariants, and so forth, you should assume that all numeric quantities are unbounded integers (i.e., overflow can not happen) and that
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 9 (Part II) Recursion MOUNA KACEM Recursion: General Overview 2 Recursion in Algorithms Recursion is the use of recursive algorithms to solve a problem A recursive algorithm
More informationCS61B Lecture #2. Public Service Announcements:
CS61B Lecture #2 Please make sure you have obtained an account, run register, and finished the survey today. In the future (next week), the password required for surveys and such will be your account password
More informationCOMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1
COMP 202 Recursion CONTENTS: Recursion COMP 202 - Recursion 1 Recursive Thinking A recursive definition is one which uses the word or concept being defined in the definition itself COMP 202 - Recursion
More informationBasic Verification Strategy
ormal Verification Basic Verification Strategy compare behavior to intent System Model of system behavior intent Verifier results Intent Usually, originates with requirements, refined through design and
More informationExam Datastrukturer. DIT960 / DIT961, VT-18 Göteborgs Universitet, CSE
Exam Datastrukturer DIT960 / DIT961, VT-18 Göteborgs Universitet, CSE Day: 2018-10-12, Time: 8:30-12.30, Place: SB Course responsible Alex Gerdes, tel. 031-772 6154. Will visit at around 9:30 and 11:00.
More informationCS 455 Final Exam Fall 2012 [Bono] Dec. 17, 2012
Name: USC loginid (e.g., ttrojan): CS 455 Final Exam Fall 2012 [Bono] Dec. 17, 2012 There are 6 problems on the exam, with 70 points total available. There are 7 pages to the exam, including this one;
More informationPlan of the lecture. Quick-Sort. Partition of lists (or using extra workspace) Quick-Sort ( 10.2) Quick-Sort Tree. Partitioning arrays
Plan of the lecture Quick-sort Lower bounds on comparison sorting Correctness of programs (loop invariants) Quick-Sort 7 4 9 6 2 2 4 6 7 9 4 2 2 4 7 9 7 9 2 2 9 9 Lecture 16 1 Lecture 16 2 Quick-Sort (
More informationC212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.
C212 Early Evaluation Exam Mon Feb 10 2014 Name: Please provide brief (common sense) justifications with your answers below. 1. What is the type (and value) of this expression: 5 * (7 + 4 / 2) 2. What
More informationPrelim 2. 5:30 PM, 25 April Total Question Name Short Search/ Collections Trees Graphs. Max Score Grader
Prelim 2 5:30 PM, 25 April 2017 1 2 3 4 5 6 Total Question Name Short Search/ Collections Trees Graphs answer sort stuff Max 1 26 18 15 20 20 100 Score Grader The exam is closed book and closed notes.
More informationPrelim 2 SOLUTION. CS 2110, 16 November 2017, 7:30 PM Total Question Name Short Heaps Tree Collections Sorting Graph
Prelim 2 SOLUTION CS 2110, 16 November 2017, 7:30 PM 1 2 3 4 5 6 7 Total Question Name Short Heaps Tree Collections Sorting Graph answer Max 1 18 10 25 10 16 20 100 Score Grader The exam is closed book
More informationSo far. Specifications, conclusion. Abstract Data Types (ADTs) Comparison by Logical Formulas. Outline
So far Specifications, conclusion. Abstract Data Types (ADTs) Based on notes by Michael Ernst, University of Washington Specifications Benefits of specifications Specification conventions Javadoc JML/Dafny
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 10 Recursion and Search MOUNA KACEM Recursion: General Overview 2 Recursion in Algorithms Recursion is the use of recursive algorithms to solve a problem A recursive algorithm
More informationMidterm Exam. CS169 Fall November 17, 2009 LOGIN: NAME: SID: Problem Max Points Points TOTAL 100
Midterm Exam CS169 Fall 2009 November 17, 2009 Please read all instructions (including these) carefully. Write your name, login, and SID. There are 12 pages in this exam and 6 questions, each with multiple
More informationCIS 110 Introduction To Computer Programming. February 29, 2012 Midterm
CIS 110 Introduction To Computer Programming February 29, 2012 Midterm Name: Recitation # (e.g. 201): Pennkey (e.g. bjbrown): My signature below certifies that I have complied with the University of Pennsylvania
More informationPrelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer
Prelim 1 CS 2110, March 15, 2016, 5:30 PM 0 1 2 3 4 5 Total Question Name True False Short Answer Object- Oriented Recursion Loop Invariants Max 1 20 14 25 19 21 100 Score Grader The exam is closed book
More informationCS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 10: Asymptotic Complexity and
CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 10: Asymptotic Complexity and What Makes a Good Algorithm? Suppose you have two possible algorithms or
More informationUniversity of Cape Town ~ Department of Computer Science Computer Science 1015F ~ June Exam
Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2009 June Exam Question Max Internal
More informationLecture 18 Restoring Invariants
Lecture 18 Restoring Invariants 15-122: Principles of Imperative Computation (Spring 2018) Frank Pfenning In this lecture we will implement heaps and operations on them. The theme of this lecture is reasoning
More informationSEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY. Lecture 11 CS2110 Spring 2016
1 SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY Lecture 11 CS2110 Spring 2016 Time spent on A2 2 Histogram: [inclusive:exclusive) [0:1): 0 [1:2): 24 ***** [2:3): 84 ***************** [3:4): 123 *************************
More information