Lists, Stacks, and Queues (plus Priority Queues)

Size: px
Start display at page:

Download "Lists, Stacks, and Queues (plus Priority Queues)"

Transcription

1 Lists, Stacks, and Queues (plus Priority Queues) The structures lists, stacks, and queues are composed of similar elements with different operations. Likewise, with mathematics: (Z, +, 0) vs. (Z,, 1) List Stack (LIFO) Queue (FIFO) Priority Queue create empty str. test emptiness add elem to head [push] add elem to end add elem access head elem [top] access front elem access highest prio. elem access tail [pop] top of stack remove front elem remove highest prio. elem modify head modify tail J.Carette (McMaster) CS/SE 2S03 1 / 1

2 Implementation a Stack via Wrapping a List c l a s s Stack { p r i v a t e L i s t c ; Stack ( f i n a l L i s t x ) { t h i s. c = x ; } } Stack ( ) { t h i s. c=n u l l ; } p u b l i c boolean i s e m p t y ( ) { r e t u r n t h i s. c == n u l l ; } p u b l i c void push ( i n t x ) { t h i s. c = new L i s t ( x, t h i s. c ) ; } p u b l i c i n t top ( ) { r e t u r n t h i s. c. hd ; } p u b l i c void pop ( ) { t h i s. c = t h i s. c. t l ; } } There are two bugs in this code! J.Carette (McMaster) CS/SE 2S03 2 / 1

3 Functional Stack c l a s s FStack { p r i v a t e f i n a l L i s t c ; FStack ( ) { t h i s. c = n u l l ; } FStack ( f i n a l L i s t l ) { t h i s. c = l ; } s t a t i c boolean i s e m p t y ( f i n a l FStack l ) { r e t u r n l. c == n u l l ; } s t a t i c FStack push ( f i n a l i n t a, f i n a l FStack l ) { r e t u r n new FStack (new L i s t ( a, l. c ) ) ; } s t a t i c FStack pop ( f i n a l FStack l ) { r e t u r n new FStack ( l. c. t l ) ; s t a t i c i n t top ( f i n a l FStack l ) { r e t u r n l. c. hd ; } } Note final FStack l means that l is never modified but its contents may be. J.Carette (McMaster) CS/SE 2S03 3 / 1

4 Exceptional Circumstances Two exceptional circumstances in FStack executions: pop of an empty stack top of an empty stack How to Deal With them: 1 figure out and deal with usual situations. 2 (Old Style Programming) let weird stuff happen otherwise: (Newer Style Programming) deal with unusual situations explicitly. J.Carette (McMaster) CS/SE 2S03 4 / 1

5 Exceptions - Cont. Safety conscious (Using Exceptions): 1 figure out unsafe situations. 2 deal with those first. 3 once safe do something usual. s t a t i c i n t top ( f i n a l FStack l ) throws E x c e p t i o n { i f ( l == n u l l ) throw new E x c e p t i o n ( ) ; r e t u r n l. c. hd ; } J.Carette (McMaster) CS/SE 2S03 5 / 1

6 Catching Exceptions. Specifying what to happen when the function raises an exception: The construct try p catch (Exception e) q; t r y { i n t x = top (new FStack ( ) ) ; } catch E x c e p t i o n e ) { system. out. p r i n t l n ( oh oh! ) ; } The exceptions will propagate until caught. Note. in {p 1 p 2 }, if p 1 throws exception, p 2 is not executed. (like return) J.Carette (McMaster) CS/SE 2S03 6 / 1

7 Exception Handling in Caml and C. Caml: throw e is written raise e. try with C: There are no exceptions in C. some constructs like long jumps have some similarities. J.Carette (McMaster) CS/SE 2S03 7 / 1

8 Exception - Cont. We can have new classes of exceptions (you can make your own) We can catch multiple exceptions try-catch-finally: The finally block always executes when the try block exits. This ensures that the finally block is executed even if an unexpected exception occurs. Error Messages in Java: System. out. p r i n t l n ( 1 / 0 ) ; throws the exception: j a v a. l a n g. A r i t h m e t i c E x c e p t i o n : / by z e r o J.Carette (McMaster) CS/SE 2S03 8 / 1

9 Objects and Classes - Dynamic Methods A class is a type plus some functions (methods) and constructors on that type. J.Carette (McMaster) CS/SE 2S03 9 / 1

10 Objects and Classes - Dynamic Methods A class is a type plus some functions (methods) and constructors on that type. Dynamic methods: void push ( f i n a l i n t a ) { c = new L i s t ( a, c ) ; } void pop ( ) { c = c. t l ; } We call these methods with p.pop(); p.push(5); dynamic belongs to an object. static belongs to a class. J.Carette (McMaster) CS/SE 2S03 9 / 1

11 Dynamic Methods - Cont. Stack p = new Stack ( ) ; p. push ( 5 ) ; p. push ( 6 ) ; System. out. p r i n t l n ( p. top ( ) ) ; p. pop ( ) ; The printed result of the above code is 6. If System.out.println(p.top()); is used after p.pop(); then the result is 5. Empty stack is an object with c == null. A common error is to write a dynamic method: L i s t f ( ) { i f ( t h i s == n u l l )... } (this == null) always false!: the method f cannot be called when the object is null. J.Carette (McMaster) CS/SE 2S03 10 / 1

12 Static Fields When we modify a static field, it is modified for all the class (global fields!). c l a s s M { s t a t i c i n t mem;... J.Carette (McMaster) CS/SE 2S03 11 / 1

Constructors - Cont. must be distinguished by the number or type of their arguments.

Constructors - Cont. must be distinguished by the number or type of their arguments. Constructors - Cont. 1 Constructors can be overloaded! must be distinguished by the number or type of their arguments. 2 When no constructor is defined, there is a default constructor with no arguments.

More information

Introduction to Computing II (ITI1121) FINAL EXAMINATION

Introduction to Computing II (ITI1121) FINAL EXAMINATION Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of engineering School of Electrical Engineering and Computer Science Identification

More information

Lecture 4: Stacks and Queues

Lecture 4: Stacks and Queues Reading materials Goodrich, Tamassia, Goldwasser (6th), chapter 6 OpenDSA (https://opendsa-server.cs.vt.edu/odsa/books/everything/html/): chapter 9.8-13 Contents 1 Stacks ADT 2 1.1 Example: CharStack ADT

More information

Introduction to Computing II (ITI 1121) FINAL EXAMINATION

Introduction to Computing II (ITI 1121) FINAL EXAMINATION Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of engineering School of Electrical Engineering and Computer Science Identification

More information

Computer Science Introductory Course MSc - Introduction to Java

Computer Science Introductory Course MSc - Introduction to Java Computer Science Introductory Course MSc - Introduction to Java Lecture 3:,, Pablo Oliveira ENST Outline 1 2 3 Definition An exception is an event that indicates an abnormal condition

More information

Stacks. Definitions Operations Implementation (Arrays and Linked Lists) Applications (system stack, expression evaluation) Data Structures 1 Stacks

Stacks. Definitions Operations Implementation (Arrays and Linked Lists) Applications (system stack, expression evaluation) Data Structures 1 Stacks Stacks Definitions Operations Implementation (Arrays and Linked Lists) Applications (system stack, expression evaluation) Data Structures 1 Stacks Stacks: Definitions and Operations A LIFO list: Last In,

More information

Solution suggestions for examination of Logic, Algorithms and Data Structures,

Solution suggestions for examination of Logic, Algorithms and Data Structures, Department of VT12 Software Engineering and Managment DIT725 (TIG023) Göteborg University, Chalmers 24/5-12 Solution suggestions for examination of Logic, Algorithms and Data Structures, Date : April 26,

More information

Queues. Principles of Computer Science II. Basic features of Queues

Queues. Principles of Computer Science II. Basic features of Queues Queues Principles of Computer Science II Abstract Data Types Ioannis Chatzigiannakis Sapienza University of Rome Lecture 9 Queue is also an abstract data type or a linear data structure, in which the first

More information

Introduction to Computing II (ITI 1121) FINAL EXAMINATION

Introduction to Computing II (ITI 1121) FINAL EXAMINATION Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of engineering School of Electrical Engineering and Computer Science Introduction

More information

Insert Sorted List Insert as the Last element (the First element?) Delete Chaining. 2 Slide courtesy of Dr. Sang-Eon Park

Insert Sorted List Insert as the Last element (the First element?) Delete Chaining. 2 Slide courtesy of Dr. Sang-Eon Park 1617 Preview Data Structure Review COSC COSC Data Structure Review Linked Lists Stacks Queues Linked Lists Singly Linked List Doubly Linked List Typical Functions s Hash Functions Collision Resolution

More information

Introduction to Computing II (ITI 1121) MIDTERM EXAMINATION

Introduction to Computing II (ITI 1121) MIDTERM EXAMINATION Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of Engineering School of Electrical Engineering and Computer Science Identification

More information

Outline Resource Introduction Usage Testing Exercises. Linked Lists COMP SCI / SFWR ENG 2S03. Department of Computing and Software McMaster University

Outline Resource Introduction Usage Testing Exercises. Linked Lists COMP SCI / SFWR ENG 2S03. Department of Computing and Software McMaster University COMP SCI / SFWR ENG 2S03 Department of Computing and Software McMaster University Week 10: November 7 - November 11 Outline 1 Resource 2 Introduction Nodes Illustration 3 Usage Accessing and Modifying

More information

Distributed Systems Part II Solution to Exercise Sheet 10

Distributed Systems Part II Solution to Exercise Sheet 10 Distributed Computing HS 2012 Prof. R. Wattenhofer / C. Decker Distributed Systems Part II Solution to Exercise Sheet 10 1 Spin Locks A read-write lock is a lock that allows either multiple processes to

More information

1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ;

1 Trees. Listing 1: Node with two child reference. public class ptwochildnode { protected Object data ; protected ptwochildnode l e f t, r i g h t ; 1 Trees The next major set of data structures belongs to what s called Trees. They are called that, because if you try to visualize the structure, it kind of looks like a tree (root, branches, and leafs).

More information

CMSC 132, Object-Oriented Programming II Summer Lecture 12

CMSC 132, Object-Oriented Programming II Summer Lecture 12 CMSC 132, Object-Oriented Programming II Summer 2016 Lecturer: Anwar Mamat Lecture 12 Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 12.1 Trees

More information

public void run ( ) { i f ( this. id == 0) System. out. p r i n t ( 3 ) ; bro. j o i n ( ) ; else System. out. p r i n t ( 2 ) ;

public void run ( ) { i f ( this. id == 0) System. out. p r i n t ( 3 ) ; bro. j o i n ( ) ; else System. out. p r i n t ( 2 ) ; 1 Unusual programs 1. Consider the following Java program : public c l a s s Thread2 extends Thread { public int id ; public Thread2 bro ; public Thread2 ( int id, Thread2 bro ) { this. id = id ; this.

More information

Declarative Computation Model. Conditional. Case statement. Procedure values (2) Procedure values. Sequential declarative computation model

Declarative Computation Model. Conditional. Case statement. Procedure values (2) Procedure values. Sequential declarative computation model Declarative Computation Model Kernel language semantics revisited (VRH.4.5) From kernel to practical language (VRH.6) Exceptions (VRH.7) Carlos Varela RPI October 0, 009 Adapted with permission from: Seif

More information

ARE211, Fall2012. Contents. 2. Linear Algebra (cont) Vector Spaces Spanning, Dimension, Basis Matrices and Rank 8

ARE211, Fall2012. Contents. 2. Linear Algebra (cont) Vector Spaces Spanning, Dimension, Basis Matrices and Rank 8 ARE211, Fall2012 LINALGEBRA2: TUE, SEP 18, 2012 PRINTED: SEPTEMBER 27, 2012 (LEC# 8) Contents 2. Linear Algebra (cont) 1 2.6. Vector Spaces 1 2.7. Spanning, Dimension, Basis 3 2.8. Matrices and Rank 8

More information

Black-Box Testing Techniques III

Black-Box Testing Techniques III Black-Box Testing Techniques III Software Testing and Verification Lecture 6 Prepared by Stephen M. Thebaut, Ph.D. University of Florida Another Cause-Effect Example: Symbol Table Storage Specification

More information

Part I: Definitions and Properties

Part I: Definitions and Properties Turing Machines Part I: Definitions and Properties Finite State Automata Deterministic Automata (DFSA) M = {Q, Σ, δ, q 0, F} -- Σ = Symbols -- Q = States -- q 0 = Initial State -- F = Accepting States

More information

Algorithmic verification

Algorithmic verification Algorithmic verification Ahmed Rezine IDA, Linköpings Universitet Hösttermin 2018 Outline Overview Model checking Symbolic execution Outline Overview Model checking Symbolic execution Program verification

More information

Graph Search Howie Choset

Graph Search Howie Choset Graph Search Howie Choset 16-11 Outline Overview of Search Techniques A* Search Graphs Collection of Edges and Nodes (Vertices) A tree Grids Stacks and Queues Stack: First in, Last out (FILO) Queue: First

More information

MI-RUB Exceptions Lecture 7

MI-RUB Exceptions Lecture 7 MI-RUB Exceptions Lecture 7 Pavel Strnad pavel.strnad@fel.cvut.cz Dept. of Computer Science, FEE CTU Prague, Karlovo nám. 13, 121 35 Praha, Czech Republic MI-RUB, WS 2011/12 Evropský sociální fond Praha

More information

ITI Introduction to Computing II

ITI Introduction to Computing II (with contributions from R. Holte) School of Electrical Engineering and Computer Science University of Ottawa Version of January 11, 2015 Please don t print these lecture notes unless you really need to!

More information

Element x is R-minimal in X if y X. R(y, x).

Element x is R-minimal in X if y X. R(y, x). CMSC 22100/32100: Programming Languages Final Exam M. Blume December 11, 2008 1. (Well-founded sets and induction principles) (a) State the mathematical induction principle and justify it informally. 1

More information

No Solution Equations Let s look at the following equation: 2 +3=2 +7

No Solution Equations Let s look at the following equation: 2 +3=2 +7 5.4 Solving Equations with Infinite or No Solutions So far we have looked at equations where there is exactly one solution. It is possible to have more than solution in other types of equations that are

More information

Design Patterns and Refactoring

Design Patterns and Refactoring Singleton Oliver Haase HTWG Konstanz 1 / 19 Description I Classification: object based creational pattern Puropse: ensure that a class can be instantiated exactly once provide global access point to single

More information

Safety and Liveness. Thread Synchronization: Too Much Milk. Critical Sections. A Really Cool Theorem

Safety and Liveness. Thread Synchronization: Too Much Milk. Critical Sections. A Really Cool Theorem Safety and Liveness Properties defined over an execution of a program Thread Synchronization: Too Much Milk Safety: nothing bad happens holds in every finite execution prefix Windows never crashes No patient

More information

The L Machines are very high-level, in two senses:

The L Machines are very high-level, in two senses: What is a Computer? State of the machine. CMPSCI 630: Programming Languages An Abstract Machine for Control Spring 2009 (with thanks to Robert Harper) Internal registers, memory, etc. Initial and final

More information

Lock using Bakery Algorithm

Lock using Bakery Algorithm Lock using Bakery Algorithm Shankar April 16, 2014 Overview Classical mutual exclusion problem given program with critical sections and threads 0..N 1 obtain entry and exit code for each critical section

More information

CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: Oct 26. Homework #2. ( Due: Nov 8 )

CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: Oct 26. Homework #2. ( Due: Nov 8 ) CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: Oct 26 Homework #2 ( Due: Nov 8 ) Task 1. [ 80 Points ] Average Case Analysis of Median-of-3 Quicksort Consider the median-of-3 quicksort algorithm

More information

MIT Loop Optimizations. Martin Rinard

MIT Loop Optimizations. Martin Rinard MIT 6.035 Loop Optimizations Martin Rinard Loop Optimizations Important because lots of computation occurs in loops We will study two optimizations Loop-invariant code motion Induction variable elimination

More information

SDS developer guide. Develop distributed and parallel applications in Java. Nathanaël Cottin. version

SDS developer guide. Develop distributed and parallel applications in Java. Nathanaël Cottin. version SDS developer guide Develop distributed and parallel applications in Java Nathanaël Cottin sds@ncottin.net http://sds.ncottin.net version 0.0.3 Copyright 2007 - Nathanaël Cottin Permission is granted to

More information

Decentralized Control of Discrete Event Systems with Bounded or Unbounded Delay Communication

Decentralized Control of Discrete Event Systems with Bounded or Unbounded Delay Communication Decentralized Control of Discrete Event Systems with Bounded or Unbounded Delay Communication Stavros Tripakis Abstract We introduce problems of decentralized control with communication, where we explicitly

More information

Python. chrysn

Python. chrysn Python chrysn 2008-09-25 Introduction Structure, Language & Syntax Strengths & Weaknesses Introduction Structure, Language & Syntax Strengths & Weaknesses Python Python is an interpreted,

More information

Skip Lists. What is a Skip List. Skip Lists 3/19/14

Skip Lists. What is a Skip List. Skip Lists 3/19/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Skip Lists 15 15 23 10 15 23 36 Skip Lists

More information

1 ListElement l e = f i r s t ; / / s t a r t i n g p o i n t 2 while ( l e. next!= n u l l ) 3 { l e = l e. next ; / / next step 4 } Removal

1 ListElement l e = f i r s t ; / / s t a r t i n g p o i n t 2 while ( l e. next!= n u l l ) 3 { l e = l e. next ; / / next step 4 } Removal Präsenzstunden Today In the same room as in the first week Assignment 5 Felix Friedrich, Lars Widmer, Fabian Stutz TA lecture, Informatics II D-BAUG March 18, 2014 HIL E 15.2 15:00-18:00 Timon Gehr (arriving

More information

Voortgezet Programmeren

Voortgezet Programmeren Voortgezet Programmeren Lecture 4: Interfaces and polymorphism Tommi Tervonen Econometric Institute, Erasmus School of Economics Rule #1: never duplicate code p u b l i c c l a s s Course { p u b l i c

More information

ITI Introduction to Computing II

ITI Introduction to Computing II (with contributions from R. Holte) School of Electrical Engineering and Computer Science University of Ottawa Version of January 9, 2019 Please don t print these lecture notes unless you really need to!

More information

GOTO the past / programs choose their own adventure. CSE 505: Programming Languages

GOTO the past / programs choose their own adventure. CSE 505: Programming Languages GOTO the past / programs choose their own adventure. CSE 505: Programming Languages Lecture 13 Evaluation Contexts First-Class Continuations Continuation-Passing Style Zach Tatlock Fall 2013 Zach Tatlock

More information

CMSC 132, Object-Oriented Programming II Summer Lecture 6:

CMSC 132, Object-Oriented Programming II Summer Lecture 6: CMSC 132, Object-Oriented Programming II Summer 2016 Lecturer: Anwar Mamat Lecture 6: Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 6.1 Singly

More information

Information Flow Inference for ML

Information Flow Inference for ML POPL 02 INRIA Rocquencourt Projet Cristal Francois.Pottier@inria.fr http://cristal.inria.fr/~fpottier/ Vincent.Simonet@inria.fr http://cristal.inria.fr/~simonet/ Information flow analysis account number

More information

Abstract Data Types. EECS 214, Fall 2017

Abstract Data Types. EECS 214, Fall 2017 Abstract Data Types EECS 214, Fall 2017 2 What is an ADT? An ADT defines: A set of (abstract) values A set of (abstract) operations on those values 2 What is an ADT? An ADT defines: A set of (abstract)

More information

CMSC 132, Object-Oriented Programming II Summer Lecture 10:

CMSC 132, Object-Oriented Programming II Summer Lecture 10: CMSC 132, Object-Oriented Programming II Summer 2016 Lecturer: Anwar Mamat Lecture 10: Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 10.1 RECURSION

More information

CSC501 Operating Systems Principles. Deadlock

CSC501 Operating Systems Principles. Deadlock CSC501 Operating Systems Principles Deadlock 1 Last Lecture q Priority Inversion Q Priority Inheritance Protocol q Today Q Deadlock 2 The Deadlock Problem q Definition Q A set of blocked processes each

More information

Modular Bisimulation Theory for Computations and Values

Modular Bisimulation Theory for Computations and Values Modular Bisimulation Theory for Computations and Values Swansea University, UK FoSSaCS, Rome March 2013 Part of the project: PLanCompS http://www.plancomps.org EPSRC-funded, 2011-2015 {Swansea, Royal Holloway,

More information

Lecture 4 Event Systems

Lecture 4 Event Systems Lecture 4 Event Systems This lecture is based on work done with Mark Bickford. Marktoberdorf Summer School, 2003 Formal Methods One of the major research challenges faced by computer science is providing

More information

Outline Resource Introduction Usage Testing Exercises. Linked Lists COMP SCI / SFWR ENG 2S03. Department of Computing and Software McMaster University

Outline Resource Introduction Usage Testing Exercises. Linked Lists COMP SCI / SFWR ENG 2S03. Department of Computing and Software McMaster University COMP SCI / SFWR ENG 2S03 Department of Computing and Software McMaster University Week 10: November 10 - November 14 Outline 1 Resource 2 Introduction Nodes Illustration 3 Usage Adding Finding and Removing

More information

Exercise 1 (15 points)

Exercise 1 (15 points) Exam System Validation (214012) 8:45-12:15, 25-06-2010 The exercises are worth a total of 90 points. The final grade is 10+pts 10. The exam is open book: copies of slides/papers/notes/etc. are allowed.

More information

CS162 Operating Systems and Systems Programming Lecture 7 Semaphores, Conditional Variables, Deadlocks"

CS162 Operating Systems and Systems Programming Lecture 7 Semaphores, Conditional Variables, Deadlocks CS162 Operating Systems and Systems Programming Lecture 7 Semaphores, Conditional Variables, Deadlocks" September 19, 2012! Ion Stoica! http://inst.eecs.berkeley.edu/~cs162! Recap: Monitors" Monitors represent

More information

process arrival time CPU burst time priority p1 0ms 25ms 3 p2 1ms 9ms 1 p3 20ms 14ms 4 p4 32ms 4ms 2

process arrival time CPU burst time priority p1 0ms 25ms 3 p2 1ms 9ms 1 p3 20ms 14ms 4 p4 32ms 4ms 2 Homework #2 Solutions 1. Suppose that the following processes arrive for execution at the times indicated. Each process will run with a single burst of CPU activity (i.e., no I/O) which lasts for the listed

More information

Context Free Languages: Decidability of a CFL

Context Free Languages: Decidability of a CFL Theorem 14.1 Context Free Languages: Decidability of a CFL Statement: Given a CFL L and string w, there is a decision procedure that determines whether w L. Proof: By construction. 1. Proof using a grammar

More information

Warmup. A programmer s wife tells him, Would you mind going to the store and picking up a loaf of bread. Also, if they have eggs, get a dozen.

Warmup. A programmer s wife tells him, Would you mind going to the store and picking up a loaf of bread. Also, if they have eggs, get a dozen. Warmup A programmer s wife tells him, Would you mind going to the store and picking up a loaf of bread. Also, if they have eggs, get a dozen. The programmer returns with 12 loaves of bread. Section 3:

More information

Distributed Algorithms (CAS 769) Dr. Borzoo Bonakdarpour

Distributed Algorithms (CAS 769) Dr. Borzoo Bonakdarpour Distributed Algorithms (CAS 769) Week 1: Introduction, Logical clocks, Snapshots Dr. Borzoo Bonakdarpour Department of Computing and Software McMaster University Dr. Borzoo Bonakdarpour Distributed Algorithms

More information

Math 3361-Modern Algebra Lecture 08 9/26/ Cardinality

Math 3361-Modern Algebra Lecture 08 9/26/ Cardinality Math 336-Modern Algebra Lecture 08 9/26/4. Cardinality I started talking about cardinality last time, and you did some stuff with it in the Homework, so let s continue. I said that two sets have the same

More information

Correctness of Concurrent Programs

Correctness of Concurrent Programs Correctness of Concurrent Programs Trifon Ruskov ruskov@tu-varna.acad.bg Technical University of Varna - Bulgaria Correctness of Concurrent Programs Correctness of concurrent programs needs to be formalized:

More information

Information System Design IT60105

Information System Design IT60105 n IT60105 Lecture 13 Statechart Diagrams Lecture #13 What is a Statechart diagram? Basic components in a state-chart diagram and their notations Examples: Process Order in OLP system What is a Statechart

More information

Experiments with Measuring Time in PRISM 4.0 (Addendum)

Experiments with Measuring Time in PRISM 4.0 (Addendum) Experiments with Measuring Time in PRISM 4.0 (Addendum) Wolfgang Schreiner Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria Wolfgang.Schreiner@risc.jku.at April

More information

Simply Typed Lambda Calculus

Simply Typed Lambda Calculus Simply Typed Lambda Calculus Language (ver1) Lambda calculus with boolean values t ::= x variable x : T.t abstraction tt application true false boolean values if ttt conditional expression Values v ::=

More information

Real-Time and Embedded Systems (M) Lecture 5

Real-Time and Embedded Systems (M) Lecture 5 Priority-driven Scheduling of Periodic Tasks (1) Real-Time and Embedded Systems (M) Lecture 5 Lecture Outline Assumptions Fixed-priority algorithms Rate monotonic Deadline monotonic Dynamic-priority algorithms

More information

A particle system takes small time-steps and updates each particle's location and velocity based on the forces acting on it.

A particle system takes small time-steps and updates each particle's location and velocity based on the forces acting on it. A particle system is a simple physics model that deals only with point- masses and forces. That means that as opposed to rigid-body models objects in particle systems occupy no volume. Their behavior is

More information

CS 21 Decidability and Tractability Winter Solution Set 3

CS 21 Decidability and Tractability Winter Solution Set 3 CS 21 Decidability and Tractability Winter 2018 Posted: January 31 Solution Set 3 If you have not yet turned in the Problem Set, you should not consult these solutions. 1. (a) A 2-NPDA is a 7-tuple (Q,,

More information

AP Physics 1 Summer Assignment

AP Physics 1 Summer Assignment Name: Email address (write legibly): AP Physics 1 Summer Assignment Packet 3 The assignments included here are to be brought to the first day of class to be submitted. They are: Problems from Conceptual

More information

Outline. PeerSim: Informal introduction. Resources. What is PeerSim? Alberto Montresor Gianluca Ciccarelli

Outline. PeerSim: Informal introduction. Resources. What is PeerSim? Alberto Montresor Gianluca Ciccarelli Outline PeerSim: Informal introduction Alberto Montresor Gianluca Ciccarelli Networking group - University of Trento April 3, 2009 1 2 files structure 3 1 / 45 2 / 45 Resources What is PeerSim? These slides

More information

SFWR ENG 3S03: Software Testing

SFWR ENG 3S03: Software Testing (Slide 1 of 69) Dr. Ridha Khedri Writing in Department of Computing and Software, McMaster University Canada L8S 4L7, Hamilton, Ontario Acknowledgments: Material based on [HT03] Unit Testing in Java with

More information

DRIVE vs. BALANCE August 10, By Michael Erlewine

DRIVE vs. BALANCE August 10, By Michael Erlewine DRIVE vs. BALANCE August 10, 2012 By Michael Erlewine (Michael@Erlewine.net) We Become What We Want Why do we have the drive and ambition to accomplish some days and don t feel like doing much of anything

More information

Outline F eria AADL behavior 1/ 78

Outline F eria AADL behavior 1/ 78 Outline AADL behavior Annex Jean-Paul Bodeveix 2 Pierre Dissaux 3 Mamoun Filali 2 Pierre Gaufillet 1 François Vernadat 2 1 AIRBUS-FRANCE 2 FéRIA 3 ELLIDIS SAE AS2C Detroit Michigan April 2006 FéRIA AADL

More information

Motivation. Dictionaries. Direct Addressing. CSE 680 Prof. Roger Crawfis

Motivation. Dictionaries. Direct Addressing. CSE 680 Prof. Roger Crawfis Motivation Introduction to Algorithms Hash Tables CSE 680 Prof. Roger Crawfis Arrays provide an indirect way to access a set. Many times we need an association between two sets, or a set of keys and associated

More information

Verifying Java-KE Programs

Verifying Java-KE Programs Verifying Java-KE Programs A Small Case Study Arnd Poetzsch-Heffter July 22, 2014 Abstract This report investigates the specification and verification of a simple list class. The example was designed such

More information

Hoare Logic for Realistically Modelled Machine Code

Hoare Logic for Realistically Modelled Machine Code Hoare Logic for Realistically Modelled Machine Code Magnus O. Myreen, Michael J. C. Gordon TACAS, March 2007 This talk Contribution: A mechanised Hoare logic for machine code with emphasis on resource

More information

Homework 5: Parallelism and Control Flow : Types and Programming Languages Fall 2015 TA: Evan Cavallo

Homework 5: Parallelism and Control Flow : Types and Programming Languages Fall 2015 TA: Evan Cavallo Homework 5: Parallelism and Control Flow 15-814: Types and Programming Languages Fall 2015 TA: Evan Cavallo (ecavallo@cs.cmu.edu) Out: 11/5/15 Due: 11/17/15, 10:30am 1 Cost Dynamics In this section, we

More information

COMP 204. Exceptions continued. Yue Li based on material from Mathieu Blanchette, Carlos Oliver Gonzalez and Christopher Cameron

COMP 204. Exceptions continued. Yue Li based on material from Mathieu Blanchette, Carlos Oliver Gonzalez and Christopher Cameron COMP 204 Exceptions continued Yue Li based on material from Mathieu Blanchette, Carlos Oliver Gonzalez and Christopher Cameron 1 / 27 Types of bugs 1. Syntax errors 2. Exceptions (runtime) 3. Logical errors

More information

Solutions to EoPL3 Exercises

Solutions to EoPL3 Exercises Solutions to EoPL3 Exercises Release 0.1.0 Cheng Lian May 16, 2017 Contents 1 Contents 3 2 Overview 29 i ii Author Cheng Lian Contents 1 2 Contents CHAPTER 1 Contents Chapter 1.

More information

CS 453 Operating Systems. Lecture 7 : Deadlock

CS 453 Operating Systems. Lecture 7 : Deadlock CS 453 Operating Systems Lecture 7 : Deadlock 1 What is Deadlock? Every New Yorker knows what a gridlock alert is - it s one of those days when there is so much traffic that nobody can move. Everything

More information

Programming Language Concepts, CS2104 Lecture 3

Programming Language Concepts, CS2104 Lecture 3 Programming Language Concepts, CS2104 Lecture 3 Statements, Kernel Language, Abstract Machine 31 Aug 2007 CS2104, Lecture 3 1 Reminder of last lecture Programming language definition: syntax, semantics

More information

Data Structures and Algorithms Winter Semester

Data Structures and Algorithms Winter Semester Page 0 German University in Cairo December 26, 2015 Media Engineering and Technology Faculty Prof. Dr. Slim Abdennadher Dr. Wael Abouelsadaat Data Structures and Algorithms Winter Semester 2015-2016 Final

More information

1 import java. u t i l. ArrayList ; 2 import java. u t i l. L i s t ; 4 /

1 import java. u t i l. ArrayList ; 2 import java. u t i l. L i s t ; 4 / 1 import java. u t i l. ArrayList ; 2 import java. u t i l. L i s t ; 3 4 / 5 The c l a s s {@code Othello } r e p r e s e n t s the game Othello i t s e l f. 6 All game l o g i c i s done in t h i s c

More information

Two Hanging Masses. ) by considering just the forces that act on it. Use Newton's 2nd law while

Two Hanging Masses. ) by considering just the forces that act on it. Use Newton's 2nd law while Student View Summary View Diagnostics View Print View with Answers Edit Assignment Settings per Student Exam 2 - Forces [ Print ] Due: 11:59pm on Tuesday, November 1, 2011 Note: To underst how points are

More information

Did you read chapter 7? Housekeeping. Special Relativity Postulates. Famous quotes from Einstein. Symmetry. (Special Principle of Relativity) 5/9/2007

Did you read chapter 7? Housekeeping. Special Relativity Postulates. Famous quotes from Einstein. Symmetry. (Special Principle of Relativity) 5/9/2007 Housekeeping Vocab quiz: Do Due Exam versus Vocab Quiz Did you read chapter 7? a) Yes b) No c) We have a book? 1 2 Famous quotes from Einstein "Everything should be made as simple as possible, but not

More information

Pushing to the Top FMCAD 15. Arie Gurfinkel Alexander Ivrii

Pushing to the Top FMCAD 15. Arie Gurfinkel Alexander Ivrii Pushing to the Top FMCAD 15 Arie Gurfinkel Alexander Ivrii Safety Verification Consider a verification problem (Init, Tr, Bad) The problem is UNSAFE if and only if there exists a path from an Init-state

More information

MEM380 Applied Autonomous Robots I Fall BUG Algorithms Potential Fields

MEM380 Applied Autonomous Robots I Fall BUG Algorithms Potential Fields MEM380 Applied Autonomous Robots I Fall BUG Algorithms Potential Fields What s Special About Bugs? Many planning algorithms assume global knowledge Bug algorithms assume only local knowledge of the environment

More information

Sharing Objects. Pieter van den Hombergh. Fontys Hogeschool voor Techniek en Logistiek. February 15, 2017

Sharing Objects. Pieter van den Hombergh. Fontys Hogeschool voor Techniek en Logistiek. February 15, 2017 Pieter van den Hombergh Fontys Hogeschool voor Techniek en Logistiek February 15, 2017 and /FHTenL February 15, 2017 is safe Idioms 1/34 and and is safe Idioms /FHTenL February 15, 2017 2/34 visibility

More information

Space-aware data flow analysis

Space-aware data flow analysis Space-aware data flow analysis C. Bernardeschi, G. Lettieri, L. Martini, P. Masci Dip. di Ingegneria dell Informazione, Università di Pisa, Via Diotisalvi 2, 56126 Pisa, Italy {cinzia,g.lettieri,luca.martini,paolo.masci}@iet.unipi.it

More information

EE 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization Fall 2016

EE 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization Fall 2016 EE 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization Fall 2016 Discrete Event Simulation Stavros Tripakis University of California, Berkeley Stavros Tripakis (UC Berkeley)

More information

CPU SCHEDULING RONG ZHENG

CPU SCHEDULING RONG ZHENG CPU SCHEDULING RONG ZHENG OVERVIEW Why scheduling? Non-preemptive vs Preemptive policies FCFS, SJF, Round robin, multilevel queues with feedback, guaranteed scheduling 2 SHORT-TERM, MID-TERM, LONG- TERM

More information

Course Announcements. John Jannotti (cs32) Scope, Collections & Generics Feb 8, / 1

Course Announcements. John Jannotti (cs32) Scope, Collections & Generics Feb 8, / 1 Course Announcements Stars is due tomorrow. Stars grades should be out by next Monday. Javascript lab out today. How you make interactive webby GUIs. Today we re going to cover a bit of a hodge podge.

More information

Maps performance tips On server: Maintain DB connections, prepared statements (per thread/request!)

Maps performance tips On server: Maintain DB connections, prepared statements (per thread/request!) Announcements Maps performance tips On server: Maintain DB connections, prepared statements (per thread/request!) Use Spark.before, Spark.after to open and close. Use ThreadLocal, or pass the connection

More information

Actors for Reactive Programming. Actors Origins

Actors for Reactive Programming. Actors Origins Actors Origins Hewitt, early 1970s (1973 paper) Around the same time as Smalltalk Concurrency plus Scheme Agha, early 1980s (1986 book) Erlang (Ericsson), 1990s Akka, 2010s Munindar P. Singh (NCSU) Service-Oriented

More information

Übung Informatik I - Programmierung - Blatt 7

Übung Informatik I - Programmierung - Blatt 7 RHEINISCH- WESTFÄLISCHE TECHNISCHE HOCHSCHULE AACHEN LEHR- UND FORSCHUNGSGEBIET INFORMATIK II RWTH Aachen D-52056 Aachen GERMANY http://programmierung.informatik.rwth-aachen.de LuFG Informatik II Prof.

More information

INF Models of concurrency

INF Models of concurrency INF4140 - Models of concurrency Fall 2017 October 17, 2017 Abstract This is the handout version of the slides for the lecture (i.e., it s a rendering of the content of the slides in a way that does not

More information

SFWR ENG/COMP SCI 2S03 Principles of Programming

SFWR ENG/COMP SCI 2S03 Principles of Programming (Slide 1 of 23) Dr. Ridha Khedri Department of Computing and Software, McMaster University Canada L8S 4L7, Hamilton, Ontario Acknowledgments: Material based on Java actually: A Comprehensive Primer in

More information

CSE505, Fall 2012, Final Examination December 10, 2012

CSE505, Fall 2012, Final Examination December 10, 2012 CSE505, Fall 2012, Final Examination December 10, 2012 Rules: The exam is closed-book, closed-notes, except for one side of one 8.5x11in piece of paper. Please stop promptly at 12:20. You can rip apart

More information

CS 4100 // artificial intelligence. Recap/midterm review!

CS 4100 // artificial intelligence. Recap/midterm review! CS 4100 // artificial intelligence instructor: byron wallace Recap/midterm review! Attribution: many of these slides are modified versions of those distributed with the UC Berkeley CS188 materials Thanks

More information

Hypothesis Testing. ECE 3530 Spring Antonio Paiva

Hypothesis Testing. ECE 3530 Spring Antonio Paiva Hypothesis Testing ECE 3530 Spring 2010 Antonio Paiva What is hypothesis testing? A statistical hypothesis is an assertion or conjecture concerning one or more populations. To prove that a hypothesis is

More information

Clock-driven scheduling

Clock-driven scheduling Clock-driven scheduling Also known as static or off-line scheduling Michal Sojka Czech Technical University in Prague, Faculty of Electrical Engineering, Department of Control Engineering November 8, 2017

More information

Accumulators. A Trivial Example in Oz. A Trivial Example in Prolog. MergeSort Example. Accumulators. Declarative Programming Techniques

Accumulators. A Trivial Example in Oz. A Trivial Example in Prolog. MergeSort Example. Accumulators. Declarative Programming Techniques Declarative Programming Techniques Accumulators, Difference Lists (VRH 3.4.3-3.4.4) Carlos Varela RPI Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL September 13, 2007 Accumulators Accumulator

More information

Declarative Programming Techniques

Declarative Programming Techniques Declarative Programming Techniques Accumulators (CTM 3.4.3) Difference Lists (CTM 3.4.4) Carlos Varela RPI Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL December 1, 2015 C. Varela; Adapted

More information

Foundations of the X-machine Theory for Testing

Foundations of the X-machine Theory for Testing Foundations of the X-machine Theory for Testing Research Report CS-02-06 J. Aguado and A. J. Cowling Department of Computer Science, Sheffield University Regent Court, 211 Portobello Street, Sheffield,

More information

CS-141 Exam 2 Review October 19, 2016 Presented by the RIT Computer Science Community

CS-141 Exam 2 Review October 19, 2016 Presented by the RIT Computer Science Community CS-141 Exam 2 Review October 19, 2016 Presented by the RIT Computer Science Community http://csc.cs.rit.edu Linked Lists 1. You are given the linked list: 1 2 3. You may assume that each node has one field

More information

CSC236 Week 2. Larry Zhang

CSC236 Week 2. Larry Zhang CSC236 Week 2 Larry Zhang 1 Announcements Tutorials start this week. Problem Set 1 will be out by Friday 2 Mathematical Induction 3 Mathematical Induction It s a proof technique It s an old proof technique

More information