CS-140 Fall 2018 Test 2 Version Practice Nov. 12, 2018

Size: px
Start display at page:

Download "CS-140 Fall 2018 Test 2 Version Practice Nov. 12, 2018"

Transcription

1 CS-140 Fall 2018 Test 2 Version Practice Nov. 12, 2018 Name: 1. (10 points) For the following, Check T if the statement is true, or F if the statement is false. (a) T X F : If a child overrides its parent s method, it can still invoke the parent method with the super keyword, but if it does so, then it must invoke the parent method first. A parent class method can be invoked anywhere from the child method. It s only the constructor that has special requirements. (b) T X F : It is possible to create a concrete class in Java which does not support the tostring method. Every object inherits Object which has a tostring method which is always inherited. (c) X T F : The compiler will not compile a concrete class which implements an interface, but fails to implement all the methods in that interface. (d) X T F : A GUI contains code that manipulates a rectangular array of pixels, where each pixel is represented by three color values. (e) T X F : An abstract class is used to prevent a child class from overriding specific methods (such as a checkpassword method.) The final keyword prevents a child class from overriding a method. (f) X T F : Under the covers, the backing store for an ArrayList is an array of Object references. (g) X T F : In Java there is an expectation that if two objects are equal, they will have the same hashcode. (h) T X F : An interface defines the list of fields that must be provided by a class that implements that interface An interface defines the methods that must be implemented, not the fields. (i) X T F : An abstract class can implement an interface without implementing all the methods in the interface. The methods not yet implemented are considered abstract methods. (j) X T F : A child class cannot inherit the class methods of its parent. Class methods (or static methods) are not inherited. 2. (5 points) Given an array of strings such as String [] arr = { abc, acd,... ;, check all of the following which are valid ways to convert the array into an arraylist. X List<String> list = new ArrayList<>(); for(string str : arr) list. add(str); List<String> list = arr; X List<String> list = new ArrayList<>(); list.addall(arrays.aslist(arr)); List<String> list = arr.toarraylist(); X List<String> list = new ArrayList<>(Arrays.asList(arr)); String [] list = new ArrayList<>(Arrays.asList(arr)); Page 1 of 11

2 3. (5 points) In the java library, there is an interface called CharSequence, which defines the methods charat(int index), chars(), length(), subsequence(int start, int end), and tostring(). Note that the String class implements the CharSequence interface. Given the following Java line of code: CharSequence csq = Welcome to Java! ; Check all of the following which are valid invocations of methods: X csq.length() X csq.charat(3) csq.concat( Enjoy the ride! ) X csq.equals( Bienvenido a Java ) CharSequence.subSequence(0,3) Answer the following questions by filling in the blanks. 4. (10 points) Given the following Java lambda expressions and argument values, what result will the lambda expression produce? (a) x >x+3 with argument 3.0, (a) 6.0 (b) x > x x + 2 x + 1 with argument 3, (b) 16 (c) (x,y) >(x y) (x y) with arguments 9 and 2 (c) 49 (d) (x,y) >x.lst.compareto(y.lst)==0? x.lst.compareto(y.lst) : x. fst. compareto(y.fst) with arguments n1 and n2 where n1 and n2 are objects with public fst and lst fields with values: n1[ fst= Tom lst= Smith ], n2[fst= Tom lst= Smith ] (d) 0 (e) (x) > { if (0==x%2) return 0; if (0==x%3) return 3; return 1; with argument 21 (e) 3 Page 2 of 11

3 5. (10 points) Given the Java classes in Listing 1 on page 7, Listing 2 on page 7, Listing 3 on page 7, and Listing 4 on page 7, (a) If you execute until just before the first for loop in the Debate main method, complete the following graphical display of memory: (b) If you run java -cp test2.debate, what will get printed to the screen? Donald will build a wall. Hillary will pay your college tuition. Donald will make America great again. Hillary says we re stronger together! Page 3 of 11

4 6. (20 points) Given the class in Listing 5 on page 8, (a) What is the string produced by Frac f=new Frac(1,2); f.mult(new Frac(1,3)).toString()? Fraction [numerator=1 denominator=6] (b) Write the code for the add method of the Fraction class so that fraction addition is performed using a the formula: b + c d = ad+bc bd. public Fraction add ( Fraction that ) { long num = ( this. numerator that. denominator ) + ( that. numerator this. denominator ) ; long den = this. denominator that. denominator ; return new Fraction (num, den ) ; (c) Given two instances of class Fraction, Fraction frac1 and Fraction frac2, such that frac1. hashcode()==frac2.hashcode(), will frac1. equals( frac2) be true? Why or why not? Probably, but not required. hashcode maps the values of numerator and denominator to an integer, and it is possible that two unequal fractions map to the same hashcode. (d) Given two instances of class Fraction, Fraction frac1 and Fraction frac2, such that frac1.equals(frac2), will frac1==frac2 be true? Why or why not? Probably not. frac1 == frac2 implies frac1 and frac2 point to the same object, but equals allows two different objects with the same numerator and denominator to return true. (e) (5 points (bonus)) If you create a new Fraction(3,0), will the Fraction class work? If not, what is the first code that will break? When the creator invokes normalize, and it invokes gcd, gcd will get in an endless loop. Page 4 of 11

5 7. (10 points) Given the Java class in Listing 6 on page 8: (a) The constructor for the Square class invokes the getfont routine to get the value of the Font field associated with this square. How can the value for the font field be anything other than null, since this Square object has just been created? Since Square extends JButton, and the Square constructor does not invoke the JButton constructor explicitly with the super keyword, Java automatically invokes the JButton constructor with no arguments. The no-argument JButton constructor initializes the fields of JButton, including the font field. (b) The actionperformed method does not use the argument ActionEvent arg0. Why is it valid for the actionperformed method to ignore its argument? The only action registered to the Square object is a press of the button represented by this. Therefore, arg0 can ıonly be this. (c) Once the choose method is invoked on a specific Square object, can the actionperformed method ever get invoked? No. The choose method invokes setenabled(false) which prevents the button associated with this object from ever getting pressed again, and if the button cannot get pressed, the actionperformed method will not be invoked. (d) The actionperformed method returns immediately instead of allowing the computer to have a turn if the TicTacToe checkwinner method returns a true value. Can you speculate what the return value from checkwinner means? The TicTacToe checkwinner method must return a true value if someone has won the TicTacToe game (gotten three in a row.) If the human player won by putting an X in this square, there is no need for the computer to take a turn. Page 5 of 11

6 8. (10 points) For the following question, refer to the zoo package in Listing 7 on page 9, Listing 8 on page 9, Listing 10 on page 10, Listing 9 on page 9, and Listing 11 on page 10 (a) What would get printed to the screen if you run the main method from the Zoo class? I eat leaves and grass. I move with a lumbering walk. I just had one calf. I eat small animals. I move silently and sneakily. I just had two cubs. I eat mice. I move on my belly. I left 20 eggs to hatch. (b) Write a new sub-class of animal to put in a zoo. Your class should have a no-argument constructor. public c l a s s Monkey extends Animal { public Monkey ( ) { super ( bananas, by swinging on v i n e s, a cute baby monkey ) ; (c) Which line of code in the zoo package demonstrates the concept of polymorphism? Explain why that line shows polymorphism. The invocation of a.birth() in the main method of the Zoo class demonstrates polymorphism because a single instruction causes Java to invoke different methods from a single line of code. Note that a.eat() and a.move() invoke the same methods for each different kind of animal - the Animal.eat and the Animal.move methods - but have different field values. Thus, the invocations of a.eat and a.move are not strictly polymorphism. 9. (10 points) What will get printed by the main method in the Java code in Listing 12 on page 10? The third element is 19 List: 21 ->33 ->19 ->44 ->19 ->19 The third element is now 44 List: 19 ->19 ->44 ->19 ->33 -> (10 points) What output is produced by the main method in the Mapper class in Listing 13 on page 11: Big : [3.0, 3.0, 3.5, 4.5] Little: [1.5, 2.5, 3.0, 3.0] Page 6 of 11

7 Tear-off Pages Listing 1: Subconscious.java public class Subconscious { private S t r i n g name ; public Subconscious ( S t r i n g name) { this. name = name ; public S t r i n g getname ( ) { return name ; public void pr omi se ( ) { System. out. p r i n t l n (name + promises not to keep any promises. ) ; public void claim ( ) { System. out. p r i n t l n (name + w i l l r u l e the world! ) ; Listing 2: Red.java public class Red extends Subconscious { public Red( S t r i n g name) { super (name ) public void pr omi se ( ) { System. out. p r i n t l n ( super. getname()+ w i l l b u i l d a wall. ) public void claim ( ) { System. out. p r i n t l n ( super. getname()+ w i l l make America g r e a t again. ) ; Listing 3: Blue.java public class Blue extends Subconscious { public Blue ( S t r i n g name) { super (name ) public void pr omi se ( ) { System. out. p r i n t l n ( super. getname()+ w i l l pay your c o l l e g e t u i t i o n. ) public void claim ( ) { System. out. p r i n t l n ( super. getname()+ says we re s t r o n g e r t o g e t h e r! ) ; Listing 4: Debate.java public class Debate { public static void main ( S t r i n g [ ] args ) { Blue dem = new Blue ( H i l l a r y ) ; Red rep = new Red( Donald ) ; Subconscious [ ] p a r t i e s = { rep, dem ; for ( Subconscious party : p a r t i e s ) { party. promise ( ) ; for ( Subconscious party : p a r t i e s ) { party. claim ( ) ; Page 7 of 11

8 Tear-off Pages Listing 5: Fraction.java public class Fraction { private long numerator ; private long denominator ; public Fraction ( long numerator, long denominator ) { this. numerator = numerator ; this. denominator = denominator ; normalize ( ) ; public double todouble ( ) { return ( double ) numerator / denominator ; public void normalize ( ) { i f ( denominator <0) { denominator= denominator ; numerator= numerator ; long g = gcd (Math. abs ( numerator ), denominator ) ; i f ( g>1) { numerator /=g ; denominator /=g ; public Fraction add ( Fraction that ) { // Code not s u p p l i e d public Fraction mult ( Fraction that ) { return new Fraction ( this. numerator that. numerator, this. denominator that. denominator ) public int hashcode ( ) { f i n a l int prime = 3 1 ; int r e s u l t = 1 ; r e s u l t = prime r e s u l t + ( int ) ( denominator ˆ ( denominator >>> 3 2 ) ) ; r e s u l t = prime r e s u l t + ( int ) ( numerator ˆ ( numerator >>> 3 2 ) ) ; return r e s u l t public boolean e q u a l s ( Object obj ) { i f ( this == obj ) return true ; i f ( obj == null ) return f a l s e ; i f ( g e t C l a s s ( )!= obj. g e t C l a s s ( ) ) return f a l s e ; Fraction other = ( Fraction ) obj ; i f ( denominator!= other. denominator ) return f a l s e ; i f ( numerator!= other. numerator ) return f a l s e ; return true public S t r i n g t o S t r i n g ( ) { return Fraction [ numerator= + numerator +, denominator= + denominator + ] ; static private long gcd ( long x, long y ) { i f ( x==y ) return x ; i f ( x<y ) return gcd ( y x, x ) ; return gcd ( x y, y ) ; Listing 6: Square.java public class Square extends JButton implements A c t i o n L i s t e n e r { Page 8 of 11

9 Tear-off Pages private static f i n a l long s erialversionuid = 1L ; int row ; int c o l ; TicTacToe game ; public Square ( TicTacToe game ) { this. game = game ; setfont ( getfont ( ). derivefont ( ( float ) ) ) ; s e t P r e f e r r e d S i z e (new Dimension ( 7 0, 7 0 ) ) ; setmargin (new I n s e t s ( 30, 30, 30, 30)); settext ( ) ; addactionlistener ( this ) ; public void choose ( S t r i n g val ) { settext ( val ) ; setenabled ( f a l s e ) public void actionperformed ( ActionEvent arg0 ) { choose ( X ) ; i f ( game. checkwinner ( ) ) return ; game. computerturn ( ) ; game. checkwinner ( ) ; Listing 7: Animal.java package zoo ; public class Animal { S t r i n g food ; S t r i n g motion ; S t r i n g k i d s ; public Animal ( S t r i n g food, S t r i n g motion, S t r i n g k i d s ) { this. food = food ; this. motion = motion ; this. k i d s = k i d s ; S t r i n g eat ( ) { return I eat + food +. ; S t r i n g move ( ) { return I move + motion +. ; S t r i n g b i r t h ( ) { return I j u s t had + k i d s +. ; Listing 8: Tiger.java package zoo ; public class Tiger extends Animal{ public Tiger ( ) { super ( small animals, s i l e n t l y and s n e a k i l y, two cubs ) ; pacakge zoo ; Listing 9: Elephant.java Page 9 of 11

10 Tear-off Pages public c l a s s Elephant extends Animal { public Elephant ( ) { super ( l e a v e s and g r a s s, with a lumbering walk, one c a l f ) ; Listing 10: Snake.java package zoo ; public c l a s s Snake extends Animal { public Snake ( ) { super ( mice, on my b e l l y, 20 h a t c h l i n g s ) S t r i n g b i r t h ( ) { return I l e f t 20 eggs to hatch. ; Listing 11: Zoo.java package zoo ; public class Zoo { ArrayList <Animal> animals ; public Zoo ( ) { this. animals = new ArrayList<Animal >(); public boolean add ( Animal e ) { return animals. add ( e ) ; public s t a t i c void main ( S t r i n g [ ] a r g s ) { Zoo zoo=new Zoo ( ) ; zoo. add (new Elephant ( ) ) ; zoo. add (new Tiger ( ) ) ; zoo. add (new Snake ( ) ) ; for ( Animal a : zoo. animals ) { System. out. p r i n t l n ( a. eat ( ) + + a. move ( ) + + a. b i r t h ( ) ) ; public class LinkedList { private int value ; private LinkedList next ; Listing 12: LinkedList.java public LinkedList ( int value ) { this. value = value ; public LinkedList add ( int value ) { i f ( next==null ) next=new LinkedList ( value ) ; else next. add ( value ) ; return this ; public int get ( int n ) { i f ( n==0) return value ; i f ( next==null ) throw new IllegalArgumentException ( I l l e g a l index ) ; return next. get (n 1); public LinkedList r e v e r s e ( ) { i f ( next==null ) return this ; return next. r e v e r s e ( ). add ( value ) ; public S t r i n g t o S t r i n g ( ) { S t r i n g r e s u l t= + value ; i f ( next!= null ) r e s u l t = r e s u l t + > + next. t o S t r i n g ( ) ; Page 10 of 11

11 Tear-off Pages return r e s u l t ; public s t a t i c void main ( S t r i n g [ ] a r g s ) { LinkedList l s t = new LinkedList ( 2 1 ) ; l s t. add ( 3 3 ) ; l s t. add ( 1 9 ) ; l s t. add ( 4 4 ) ; l s t. add ( 1 9 ) ; l s t. add ( 1 9 ) ; System. out. p r i n t l n ( The t h i r d element i s + l s t. get ( 2 ) ) ; System. out. p r i n t l n ( L i s t : + l s t ) ; l s t=l s t. r e v e r s e ( ) ; System. out. p r i n t l n ( The t h i r d element i s now + l s t. get ( 2 ) ) ; System. out. p r i n t l n ( L i s t : + l s t ) ; import java. u t i l. Arrays ; import java. u t i l. f u n c t i o n. Function ; Listing 13: Mapper.java public class Mapper { public double [ ] map( double [ ] rawdata, Function<Double, Double> f n ) { double [ ] r e s u l t=null ; i f ( rawdata!= null ) { r e s u l t = new double [ rawdata. l e n g t h ] ; for ( int i =0; i <rawdata. l e n g t h ; i ++) { r e s u l t [ i ]= fn. apply ( rawdata [ i ] ) ; return r e s u l t ; public s t a t i c void main ( S t r i n g [ ] a r g s ) { Mapper f o r a l l = new Mapper ( ) ; double [ ] data = { 1. 5, 2. 5, 3. 5, 4. 5 ; double [ ] big = f o r a l l. map( data, d >{ i f (d>3.0) return d ; else return 3. 0 ; ) ; double [ ] l i t t l e = f o r a l l. map( data, d >(d<=3.0)?d : 3. 0 ) ; System. out. p r i n t l n ( Big : + Arrays. t o S t r i n g ( big ) ) ; System. out. p r i n t l n ( L i t t l e : + Arrays. t o S t r i n g ( l i t t l e ) ) ; Question: Total Points: Bonus Points: Page 11 of 11

CS-140 Fall 2018 Test 2 Version Practice Nov. 12, Name:

CS-140 Fall 2018 Test 2 Version Practice Nov. 12, Name: CS-140 Fall 2018 Test 2 Version Practice Nov. 12, 2018 Name: 1. (10 points) For the following, Check T if the statement is true, or F if the statement is false. (a) T F : If a child overrides its parent

More information

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name:

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name: CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : If a child overrides

More information

Prelim 2[Solutions] Solutions. 1. Short Answer [18 pts]

Prelim 2[Solutions] Solutions. 1. Short Answer [18 pts] Prelim [Solutions]. Short Answer [8 pts] (a) [3 pts] In a model/view/controller, Swing is likely to be part of (there may be more than one): i. the model ii. the view iii. the controller The view and the

More information

Solutions. Prelim 2[Solutions]

Solutions. Prelim 2[Solutions] Prelim [Solutions]. Short Answer [ pts] (a) [ pts] A traversal of an expression tree produces the string + + 3. i. What kind of traversal is it? Preorder; the operator is printed before the operands. ii.

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

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

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

Elementary Sorts 1 / 18

Elementary Sorts 1 / 18 Elementary Sorts 1 / 18 Outline 1 Rules of the Game 2 Selection Sort 3 Insertion Sort 4 Shell Sort 5 Visualizing Sorting Algorithms 6 Comparing Sorting Algorithms 2 / 18 Rules of the Game Sorting is the

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

SFWR ENG/COMP SCI 2S03 Principles of Programming

SFWR ENG/COMP SCI 2S03 Principles of Programming (Slide 1 of 78) 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

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 1: Diving into java Pablo Oliveira ENST Outline 1 Introduction 2 Primitive types 3 Operators 4 5 Control Flow

More information

Java Programming. Final Examination on December 13, 2015 Fall 2015

Java Programming. Final Examination on December 13, 2015 Fall 2015 Java Programming Final Examination on December 13, 2015 Fall 2015 Department of Computer Science and Information Engineering National Taiwan University Problem 1 (10 points) Multiple choice questions.

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

Lecture 5: Sep. 23 &25

Lecture 5: Sep. 23 &25 CIS 2168 Data Structures Fall 2014 Lecturer: Anwar Mamat Lecture 5: Sep. 23 &25 Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 5.1 Doubly Linked

More information

1 Java Night Countdown (30%)

1 Java Night Countdown (30%) Midterm Examination Problem Sheet TIME: 04/18/2009, 19:00 21:00 This is a open-textbook exam. You can use the Absolute Java textbook as your reference during the exam. Any other references are not allowed.

More information

Tou has been released!

Tou has been released! Tou has been released! Shoot- em-up, heavy use of collision detection Much more open-ended than previous projects Easier than previous projects if you work smart Should help those of you combating the

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

CS1083 Week 4 : Polymorphism

CS1083 Week 4 : Polymorphism CS1083 Week 4 : Polymorphism Interfaces, Comparable, Searching David Bremner 2018-01-22 Interfaces Linear Search Binary Search Interfaces An interface is like a class, with all the implementation left

More information

FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING OBJECT ORIENTED PROGRAMMING DATE 09/06/2014 SESSION 8:30-10:30

FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING OBJECT ORIENTED PROGRAMMING DATE 09/06/2014 SESSION 8:30-10:30 FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING MODULE CAMPUS CSC2A10 OBJECT ORIENTED PROGRAMMING AUCKLAND PARK CAMPUS (APK) EXAM JUNE 2014 DATE 09/06/2014 SESSION 8:30-10:30 ASSESOR(S)

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

6.001 Recitation 22: Streams

6.001 Recitation 22: Streams 6.001 Recitation 22: Streams RI: Gerald Dalley, dalleyg@mit.edu, 4 May 2007 http://people.csail.mit.edu/dalleyg/6.001/sp2007/ The three chief virtues of a programmer are: Laziness, Impatience and Hubris

More information

Report of Dragable Notebook

Report of Dragable Notebook Report of Dragable Notebook Lu Guandong, Qi Zhenlin, Mao Yong, Han Bing May 18, 2017 Abstract This report shows you why we develop the app, the function of the app and the features of the app. We include

More information

Lab Exercise 6 CS 2334

Lab Exercise 6 CS 2334 Lab Exercise 6 CS 2334 September 28, 2017 Introduction In this lab, you will experiment with using inheritance in Java through the use of abstract classes and interfaces. You will implement a set of classes

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

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

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

MURA Office hours Thurs at 12-1pm in CIT 546 Contact for more info.

MURA Office hours Thurs at 12-1pm in CIT 546 Contact for more info. Course Announcements Lecture capture has begun, available from Lectures page. First two and a half weeks are packed. Testing lab done, HTML started, and Stars due next Friday. Department has a lot of student

More information

CSE 311: Foundations of Computing. Lecture 26: Cardinality

CSE 311: Foundations of Computing. Lecture 26: Cardinality CSE 311: Foundations of Computing Lecture 26: Cardinality Cardinality and Computability Computers as we know them grew out of a desire to avoid bugs in mathematical reasoning A brief history of reasoning

More information

Thomas Jefferson Invitational Open in Informatics

Thomas Jefferson Invitational Open in Informatics Thomas Jefferson Invitational Open in Informatics Sample Problems (With Solutions) Version 2.01.1 By programmers, For programmers Preface Preface Welcome to the TJ IOI Sample Problems document. Here, you

More information

CSEN202: Introduction to Computer Programming Spring Semester 2014 Final Exam

CSEN202: Introduction to Computer Programming Spring Semester 2014 Final Exam Page 0 German University in Cairo June 14, 2014 Media Engineering and Technology Faculty Prof. Dr. Slim Abdennadher CSEN202: Introduction to Computer Programming Spring Semester 2014 Final Exam Bar Code

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

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

CS Java. Introduction to Java. Andy Mroczkowski Department of Computer Science Drexel University

CS Java. Introduction to Java. Andy Mroczkowski Department of Computer Science Drexel University CS 190 - Java Introduction to Java Andy Mroczkowski uamroczk@cs.drexel.edu Department of Computer Science Drexel University February 18, 2008 / Lecture 5 Outline Course Status Course Information & Schedule

More information

CS Exam 3 Study Guide and Practice Exam

CS Exam 3 Study Guide and Practice Exam CS 163 - Exam 3 Study Guide and Practice Exam November 6, 2017 Summary 1 Disclaimer 2 Methods and Data 2.1 Static vs. Non-Static........................................... 2.1.1 Static Example..........................................

More information

A Java introduction SDK, FC 15/12/2009 UMR AMAP. SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50

A Java introduction SDK, FC 15/12/2009 UMR AMAP. SDK, FC (UMR AMAP) A Java introduction 15/12/ / 50 A Java introduction SDK, FC UMR AMAP 15/12/2009 SDK, FC (UMR AMAP) A Java introduction 15/12/2009 1 / 50 Plan 1 Introduction 2 Bases Java Application Variables & Expressions Simple Arrays Exceptions Collections

More information

Instance Methods and Inheritance (1/2)

Instance Methods and Inheritance (1/2) Instance Methods and Inheritance (1/2) 1 class Professor { 2 p u b l i c void say_hello ( ) { 3 System. out. p r i n t l n ( " Hello! " ) ; 4 } 5 } 6 class CSIEProfessor extends Professor { 7 p u b l i

More information

Introduction to Programming (Java) 3/12

Introduction to Programming (Java) 3/12 Introduction to Programming (Java) 3/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction

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

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

Techniques of Java Programming

Techniques of Java Programming Legi-Nr.:... Techniques of Java Programming ETH Zurich Date: 9 May 008 Family name, first name:... Student number:... I confirm with my signature, that I was able to take this exam under regular circumstances

More information

Discrete Math in Computer Science Solutions to Practice Problems for Midterm 2

Discrete Math in Computer Science Solutions to Practice Problems for Midterm 2 Discrete Math in Computer Science Solutions to Practice Problems for Midterm 2 CS 30, Fall 2018 by Professor Prasad Jayanti Problems 1. Let g(0) = 2, g(1) = 1, and g(n) = 2g(n 1) + g(n 2) whenever n 2.

More information

DNHI Homework 2 Solutions Recursion

DNHI Homework 2 Solutions Recursion Solutions Recursion Problem 1 Part A Write an iterative method that computes a value of x n for a positive integer n and a real number x. The return value of -1 indicates an error condition. 1 public static

More information

BoardGame: A MiniDraw extension

BoardGame: A MiniDraw extension BoardGame: A MiniDraw extension Henrik Bærbak Christensen Status: Draft. November 29, 2010 Chapter 1 Boardgame Architecture The MiniDraw framework is described in Chapter 30 in Flexible, Reliable Software.

More information

E23: Hotel Management System Wen Yunlu Hu Xing Chen Ke Tang Haoyuan Module: EEE 101

E23: Hotel Management System Wen Yunlu Hu Xing Chen Ke Tang Haoyuan Module: EEE 101 E23: Hotel Management System Author: 1302509 Zhao Ruimin 1301478 Wen Yunlu 1302575 Hu Xing 1301911 Chen Ke 1302599 Tang Haoyuan Module: EEE 101 Lecturer: Date: Dr.Lin December/22/2014 Contents Contents

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

Introduction to Algorithmic Complexity. D. Thiebaut CSC212 Fall 2014

Introduction to Algorithmic Complexity. D. Thiebaut CSC212 Fall 2014 Introduction to Algorithmic Complexity D. Thiebaut CSC212 Fall 2014 http://youtu.be/p0tlbl5lrj8 Case Study: Fibonacci public class RecurseFib {! private static long computefibrecursively( int n ) { if

More information

Notater: INF3331. Veronika Heimsbakk December 4, Introduction 3

Notater: INF3331. Veronika Heimsbakk December 4, Introduction 3 Notater: INF3331 Veronika Heimsbakk veronahe@student.matnat.uio.no December 4, 2013 Contents 1 Introduction 3 2 Bash 3 2.1 Variables.............................. 3 2.2 Loops...............................

More information

Running Time. Overview. Case Study: Sorting. Sorting problem: Analysis of algorithms: framework for comparing algorithms and predicting performance.

Running Time. Overview. Case Study: Sorting. Sorting problem: Analysis of algorithms: framework for comparing algorithms and predicting performance. Running Time Analysis of Algorithms As soon as an Analytic Engine exists, it will necessarily guide the future course of the science. Whenever any result is sought by its aid, the question will arise -

More information

n CS 160 or CS122 n Sets and Functions n Propositions and Predicates n Inference Rules n Proof Techniques n Program Verification n CS 161

n CS 160 or CS122 n Sets and Functions n Propositions and Predicates n Inference Rules n Proof Techniques n Program Verification n CS 161 Discrete Math at CSU (Rosen book) Sets and Functions (Rosen, Sections 2.1,2.2, 2.3) TOPICS Discrete math Set Definition Set Operations Tuples 1 n CS 160 or CS122 n Sets and Functions n Propositions and

More information

Generics. Hsuan-Tien Lin. OOP Class, May 23, Department of CSIE, NTU. H.-T. Lin (NTU CSIE) Generics OOP 05/23/ / 16

Generics. Hsuan-Tien Lin. OOP Class, May 23, Department of CSIE, NTU. H.-T. Lin (NTU CSIE) Generics OOP 05/23/ / 16 Generics Hsuan-Tien Lin Department of CSIE, NTU OOP Class, May 23, 2013 H.-T. Lin (NTU CSIE) Generics OOP 05/23/2013 0 / 16 How can we write a class for an Integer set of arbitrary size? H.-T. Lin (NTU

More information

Lecture 19: Universality and Computability

Lecture 19: Universality and Computability Fundamental Questions Lecture 19: Universality and Computability Universality What is a general purpose computer? Computability Are there problems that no machine can solve? Church-Turing thesis Are there

More information

CS Exam 1 Study Guide and Practice Exam

CS Exam 1 Study Guide and Practice Exam CS 150 - Exam 1 Study Guide and Practice Exam September 11, 2017 Summary 1 Disclaimer 2 Variables 2.1 Primitive Types.............................................. 2.2 Suggestions, Warnings, and Resources.................................

More information

CS177 Fall Midterm 1. Wed 10/07 6:30p - 7:30p. There are 25 multiple choice questions. Each one is worth 4 points.

CS177 Fall Midterm 1. Wed 10/07 6:30p - 7:30p. There are 25 multiple choice questions. Each one is worth 4 points. CS177 Fall 2015 Midterm 1 Wed 10/07 6:30p - 7:30p There are 25 multiple choice questions. Each one is worth 4 points. Answer the questions on the bubble sheet given to you. Only the answers on the bubble

More information

Object Oriented Software Design (NTU, Class Even, Spring 2009) Final Examination Problem Sheet TIME: 06/16/2009, 14:20 17:20

Object Oriented Software Design (NTU, Class Even, Spring 2009) Final Examination Problem Sheet TIME: 06/16/2009, 14:20 17:20 Final Examination Problem Sheet TIME: 06/16/2009, 14:20 17:20 This is a closed-book exam. Any form of cheating or lying will not be tolerated. Students can get zero scores and/or fail the class and/or

More information

DM507 - Algoritmer og Datastrukturer Project 1

DM507 - Algoritmer og Datastrukturer Project 1 DM507 - Algoritmer og Datastrukturer Project 1 Christian Skjøth Mat-Øk 280588 Morten Olsen Mat-Øk 090789 19. marts 2012 Task 1 - Double for-loop So, first we needed to create an instance of the class File

More information

Lecture 5: Jun. 10, 2015

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

More information

Heaps Induction. Heaps. Heaps. Tirgul 6

Heaps Induction. Heaps. Heaps. Tirgul 6 Tirgul 6 Induction A binary heap is a nearly complete binary tree stored in an array object In a max heap, the value of each node that of its children (In a min heap, the value of each node that of its

More information

More About Methods. Hsuan-Tien Lin. Deptartment of CSIE, NTU. OOP Class, March 8-9, 2010

More About Methods. Hsuan-Tien Lin. Deptartment of CSIE, NTU. OOP Class, March 8-9, 2010 More About Methods Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 8-9, 2010 H.-T. Lin (NTU CSIE) More About Methods OOP 03/08-09/2010 0 / 24 Methods: the Basic Method (1/2, Callee s View) 1 p

More information

Remainders. We learned how to multiply and divide in elementary

Remainders. We learned how to multiply and divide in elementary Remainders We learned how to multiply and divide in elementary school. As adults we perform division mostly by pressing the key on a calculator. This key supplies the quotient. In numerical analysis and

More information

Take-home Lab 1. Arrays

Take-home Lab 1. Arrays Take-home Lab 1 Arrays Findx 2-Dimensional Array Graded! Submit by Friday 23:59 Find You are given a treasure map by your friend Map is divided into R by C cells Super Marks The Spot You need to find all

More information

1. Write a program to calculate distance traveled by light

1. Write a program to calculate distance traveled by light G. H. R a i s o n i C o l l e g e O f E n g i n e e r i n g D i g d o h H i l l s, H i n g n a R o a d, N a g p u r D e p a r t m e n t O f C o m p u t e r S c i e n c e & E n g g P r a c t i c a l M a

More information

FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING OBJECT ORIENTED PROGRAMMING DATE 07/2014 SESSION 8:00-10:00

FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING OBJECT ORIENTED PROGRAMMING DATE 07/2014 SESSION 8:00-10:00 FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING MODULE CAMPUS CSC2A10 OBJECT ORIENTED PROGRAMMING AUCKLAND PARK CAMPUS (APK) EXAM JULY 2014 DATE 07/2014 SESSION 8:00-10:00 ASSESOR(S)

More information

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

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

More information

Basic Java OOP 10/12/2015. Department of Computer Science & Information Engineering. National Taiwan University

Basic Java OOP 10/12/2015. Department of Computer Science & Information Engineering. National Taiwan University Basic Java OOP 10/12/2015 Hsuan-Tien Lin ( 林軒田 ) htlin@csie.ntu.edu.tw Department of Computer Science & Information Engineering National Taiwan University ( 國立台灣大學資訊工程系 ) Hsuan-Tien Lin (NTU CSIE) Basic

More information

Softwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany

Softwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany Softwaretechnik Lecture 13: Design by Contract Peter Thiemann University of Freiburg, Germany 25.06.2012 Table of Contents Design by Contract Contracts for Procedural Programs Contracts for Object-Oriented

More information

Practice Midterm Exam

Practice Midterm Exam CS/MATH320L - Applied Discrete Math Spring 2013 Instructor: Marc Pomplun Practice Midterm Exam Sample Solutions Question 1: out of points Question 2: out of points Question 3: out of points Question 4:

More information

Softwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany

Softwaretechnik. Lecture 13: Design by Contract. Peter Thiemann University of Freiburg, Germany Softwaretechnik Lecture 13: Design by Contract Peter Thiemann University of Freiburg, Germany 25.06.2012 Table of Contents Design by Contract Contracts for Procedural Programs Contracts for Object-Oriented

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

Fundamental Questions. Universality. What is a general purpose computer? Computability. Are there problems that no machine can solve?

Fundamental Questions. Universality. What is a general purpose computer? Computability. Are there problems that no machine can solve? Universality and Computability Fundamental Questions Universality. What is a general purpose computer? Computability. Are there problems that no machine can solve? Universality Q. Which one of the following

More information

Compiling Techniques

Compiling Techniques Lecture 7: Abstract Syntax 13 October 2015 Table of contents Syntax Tree 1 Syntax Tree Semantic Actions Examples Abstract Grammar 2 Internal Representation AST Builder 3 Visitor Processing Semantic Actions

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

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

Measuring Goodness of an Algorithm. Asymptotic Analysis of Algorithms. Measuring Efficiency of an Algorithm. Algorithm and Data Structure

Measuring Goodness of an Algorithm. Asymptotic Analysis of Algorithms. Measuring Efficiency of an Algorithm. Algorithm and Data Structure Measuring Goodness of an Algorithm Asymptotic Analysis of Algorithms EECS2030 B: Advanced Object Oriented Programming Fall 2018 CHEN-WEI WANG 1. Correctness : Does the algorithm produce the expected output?

More information

Compiling Techniques

Compiling Techniques Lecture 11: Introduction to 13 November 2015 Table of contents 1 Introduction Overview The Backend The Big Picture 2 Code Shape Overview Introduction Overview The Backend The Big Picture Source code FrontEnd

More information

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

CS 61B Asymptotic Analysis Fall 2017

CS 61B Asymptotic Analysis Fall 2017 CS 61B Asymptotic Analysis Fall 2017 1 More Running Time Give the worst case and best case running time in Θ( ) notation in terms of M and N. (a) Assume that slam() Θ(1) and returns a boolean. 1 public

More information

Chapter 5: Section 5-1 Mathematical Logic

Chapter 5: Section 5-1 Mathematical Logic Chapter 5: Section 5-1 Mathematical Logic D. S. Malik Creighton University, Omaha, NE D. S. Malik Creighton University, Omaha, NE Chapter () 5: Section 5-1 Mathematical Logic 1 / 29 Mathematical Logic

More information

More on Methods and Encapsulation

More on Methods and Encapsulation More on Methods and Encapsulation Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 31, 2009 H.-T. Lin (NTU CSIE) More on Methods and Encapsulation OOP(even) 03/31/2009 0 / 38 Local Variables Local

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

A High Level Programming Language for Quantum Computing

A High Level Programming Language for Quantum Computing QUARK QUantum Analysis and Realization Kit A High Level Programming Language for Quantum Computing Team In lexicographical order: Name UNI Role Daria Jung djj2115 Verification and Validation Jamis Johnson

More information

highlights proof by contradiction what about the real numbers?

highlights proof by contradiction what about the real numbers? CSE 311: Foundations of Computing Fall 2013 Lecture 27: Turing machines and decidability highlights Cardinality A set S is countableiffwe can writeit as S={s 1, s 2, s 3,...} indexed by N Set of rationals

More information

Scripting Languages Fast development, extensible programs

Scripting Languages Fast development, extensible programs Scripting Languages Fast development, extensible programs Devert Alexandre School of Software Engineering of USTC November 30, 2012 Slide 1/60 Table of Contents 1 Introduction 2 Dynamic languages A Python

More information

4th year Project demo presentation

4th year Project demo presentation 4th year Project demo presentation Colm Ó héigeartaigh CASE4-99387212 coheig-case4@computing.dcu.ie 4th year Project demo presentation p. 1/23 Table of Contents An Introduction to Quantum Computing The

More information

6.001 SICP September? Procedural abstraction example: sqrt (define try (lambda (guess x) (if (good-enuf? guess x) guess (try (improve guess x) x))))

6.001 SICP September? Procedural abstraction example: sqrt (define try (lambda (guess x) (if (good-enuf? guess x) guess (try (improve guess x) x)))) September? 600-Introduction Trevor Darrell trevor@csail.mit.edu -D5 6.00 web page: http://sicp.csail.mit.edu/ section web page: http://www.csail.mit.edu/~trevor/600/ Abstractions Pairs and lists Common

More information

Code Listing for Problem 4

Code Listing for Problem 4 Code Listing for Problem 4 Phillip Cannata, arranged by Jonathan Bernard test.c 1 float x; 2 3 int main () { 4 int x; 5 x = 4 * 2 * 3 + 5 * 6 + 7 ; 6 } hmm.bat 1 @java -cp bin proj. Hmm %* Hmm.java 1 package

More information

Read all questions and answers carefully! Do not make any assumptions about the code other than those that are clearly stated.

Read all questions and answers carefully! Do not make any assumptions about the code other than those that are clearly stated. Read all questions and answers carefully! Do not make any assumptions about the code other than those that are clearly stated. CS177 Fall 2014 Final - Page 2 of 38 December 17th, 10:30am 1. Consider we

More information

Programming Languages Fall 2013

Programming Languages Fall 2013 Programming Languages Fall 2013 Lecture 11: Subtyping Prof Liang Huang huang@qccscunyedu Big Picture Part I: Fundamentals Functional Programming and Basic Haskell Proof by Induction and Structural Induction

More information

Comp 11 Lectures. Mike Shah. July 12, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 12, / 33

Comp 11 Lectures. Mike Shah. July 12, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 12, / 33 Comp 11 Lectures Mike Shah Tufts University July 12, 2017 Mike Shah (Tufts University) Comp 11 Lectures July 12, 2017 1 / 33 Please do not distribute or host these slides without prior permission. Mike

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

INF2220: algorithms and data structures Series 1

INF2220: algorithms and data structures Series 1 Universitetet i Oslo Institutt for Informatikk I. Yu, D. Karabeg INF2220: algorithms and data structures Series 1 Topic Function growth & estimation of running time, trees (Exercises with hints for solution)

More information

Liquid or Gas. New Mexico Super Computing Challenge Final Report April 1, 2006 Team #74 Oñate High School

Liquid or Gas. New Mexico Super Computing Challenge Final Report April 1, 2006 Team #74 Oñate High School Liquid or Gas New Mexico Super Computing Challenge Final Report April 1, 2006 Team #74 Oñate High School Team Members: Luke Murphy, Petrina Strader, and Jason Li Sponsors: Donald Downs and Josefina Dominguez

More information

Binary Search Trees. Motivation

Binary Search Trees. Motivation Binary Search Trees Motivation Searching for a particular record in an unordered list takes O(n), too slow for large lists (databases) If the list is ordered, can use an array implementation and use binary

More information

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019 CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2019 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis

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

HW8. Due: November 1, 2018

HW8. Due: November 1, 2018 CSCI 1010 Theory of Computation HW8 Due: November 1, 2018 Attach a fully filled-in cover sheet to the front of your printed homework Your name should not appear anywhere; the cover sheet and each individual

More information

Big-O Notation and Complexity Analysis

Big-O Notation and Complexity Analysis Big-O Notation and Complexity Analysis Jonathan Backer backer@cs.ubc.ca Department of Computer Science University of British Columbia May 28, 2007 Problems Reading: CLRS: Growth of Functions 3 GT: Algorithm

More information

2 Getting Started with Numerical Computations in Python

2 Getting Started with Numerical Computations in Python 1 Documentation and Resources * Download: o Requirements: Python, IPython, Numpy, Scipy, Matplotlib o Windows: google "windows download (Python,IPython,Numpy,Scipy,Matplotlib" o Debian based: sudo apt-get

More information

Introduction to Python

Introduction to Python Introduction to Python Luis Pedro Coelho Institute for Molecular Medicine (Lisbon) Lisbon Machine Learning School II Luis Pedro Coelho (IMM) Introduction to Python Lisbon Machine Learning School II (1

More information

Lists, Stacks, and Queues (plus Priority Queues)

Lists, Stacks, and Queues (plus Priority Queues) 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

More information

Functional Programming with F# Overview and Basic Concepts

Functional Programming with F# Overview and Basic Concepts Functional Programming with F# Overview and Basic Concepts Radu Nicolescu Department of Computer Science University of Auckland 27 Sep 2017 1 / 52 1 Background 2 Overview 3 Type System and Type Inference

More information