Homework 2: Imperative Due: 5:00 PM, Feb 16, 2018

Size: px
Start display at page:

Download "Homework 2: Imperative Due: 5:00 PM, Feb 16, 2018"

Transcription

1 CS18 Integrated Introduction to Computer Science Fisler, Nelson Contents Homework 2: Imperative Due: 5:00 PM, Feb 16, Double the Fun with Doubly-Linked Lists 3 2 SeatMap 6 3 Memory Maps for Lists and Mutation Google Sheet Tips (if needed) Appendix 11 Objectives By the end of this homework, you will know: ˆ What imperative programming is, and what kinds of problems it can solve By the end of this homework, you will be able to: ˆ Implement doubly-linked lists from soup to nuts! ˆ Determine when to use a for loop vs. a while loop How to Hand In For this (and all) homework assignments, you should hand in answers for all questions. For this homework specifically, this entails answering the Double the Fun with Doubly-Linked Lists and Seatmap questions. The Memory Map question will ask you to submit information through Google Forms. In addition to handing in your answers for Memory Map through Google Forms, you must submit a.txt file with a link to your Google Slides containing your answers to the graded portion of Memory Map. Be sure that you leave no identifying information (like name, login, etc) in your slides. You must submit your solutions in both places, the.txt file on the department machines and the Google Form in the PDF. In order to hand in your solutions to these problems, they must be stored in appropriately-named files with the appropriate package header in an appropriately-named directory. Begin by copying the source code (/course/cs0180/src/hw02/src/*.java) from the course directory to your own personal directory. That is, copy the following files from /course/cs0180/src/ hw02/src/*.java to /course/cs0180/workspace/javaproject/src/hw02/src:

2 ˆ IList.java containing public interface IList<T> ˆ AbsList.java containing public abstract class AbsList<T> ˆ IListTest.java containing public class IListTest ˆ Item.java containing public class Item ˆ Order.java containing public class Order ˆ Shop.java containing public class Shop ˆ Main.java containing public class Main Do not alter these files! After completing this assignment, the following solution files should be in your /course/cs0180/workspace/javaproject/sol/hw02/sol directory, all as part of the hw02.sol package: ˆ Double the Fun with Doubly-Linked Lists IExtList.java, containing public interface IExtList<T>, which extends IList <T> with the methods get, remove, and reverse. DoublyLinkedList.java containing public class DoublyLinkedList<T>, which extends AbsList<T> and implements IExtList<T>. A file IExtListTest.java containing public class IExtListTest, which thoroughly tests your doubly- linked list implementation. ˆ SeatMap SeatMap.java, containing public class SeatMap, which implements the methods bookseats, findblock1, findblock2, findblock3, findblock4, and findblock. SeatMapTest.java, containing public class SeatMapTest, which thoroughly tests your SeatMap implementation ˆ Memory Map for Lists and Mutations A.txt file containing the link to your Google Slides answer for the graded portion of the assignment. To hand in your files, navigate to the /course/cs0180/workspace/javaproject/ directory, and run the command cs018 handin hw02. This will automatically hand in all of the above files. Once you have handed in your homework, you should receive an , more or less immediately, confirming that fact. If you don t receive this , try handing in again, or ask the TAs what went wrong. 2

3 Regarding Exceptions In Java, the Exception class is used to indicate that something has gone wrong or an abnormal condition has occured. These are widely used, and you will see more detail about them in future lectures. For this assignment, there are a few places where we want you to throw exceptions. throw is the keyword we use when talking about exceptions, and we will demonstrate an example below. Consider a problem we might run into in the DoublyLinkedList class. We start with an empty list, and say a user wishes to remove the first item from this empty list. What can we do? The type signature says that we have to return some item, but we don t have any item to return. We also don t want to return some random item, because we didn t remove it. Additionally, it would be bad practice to return null. The solution here is to throw an Exception! This tells the user that they ve done something wrong, like removing an item from an empty list. Let s see what this would look like in an example. Here, we are going to throw a Java built in exception called the NoSuchElementException We can start in IExtList.java, since that is where we are declaring the removefirst() method. First, we put import java.util.nosuchelementexception; at the top of your IExtList file. This way, your code will compile. The declaration for the method should look like the following: /** * Removes the first item from the list. If the list is empty, throws an * exception. * the item that was removed * NoSuchElementException if the list is empty */ public T removefirst() throws NoSuchElementException; First, we have in our comments - this is part of proper commenting. Next, note that our method declaration also includes the line throws NoSuchElementException. This is required, and lets Java know that this class might throw that exception. We can now move into our DoublyLinkedList file. As before, we import java.util.nosuchelementexception. Then, when we override the removefirst() method, we don t need to add throws NoSuchElementException - that is already captured by the IExtList. Then, when we reach a point in our code where we think it is appropriate to throw this exception we do that by writing throw new NoSuchElementException ("message"). The message should be informative as to why the error was thrown. You should throw exceptions whenever a method is called in error. For example, calling any method that gets or removes an element on an empty list should throw a NoSuchElementException with an informative error message telling the user that the list is empty. When you are conducting testing for your DoublyLinkedList class, you can use the checkexception () method to test your exceptions. Feel free to look at IListTest in the source code for an example of this. 3

4 Problems 1 Double the Fun with Doubly-Linked Lists As a computer scientist, you will often be presented with a problem where it is easy to determine what functionality you require from a piece of code you are writing, but you do not yet know the best implementation. As you ve learned in CS 17/18, this situation calls for an interface. That way, you can decide on one implementation now, and later you can switch it out for a newer and better one without impacting your code base. In class you saw how to implement a list interface using linked lists. In the linked list implementation, each node refers to the next node in the list, and the list itself maintains references to the start and end of the list. A doubly-linked list is one in which each node refers to both the next node and the previous node, as shown in Figure 1. Can you imagine ways in which this implementation might have advantages over a singly-linked list (which we have seen in lecture)? A doubly-linked list maintains the following invariants: 1. When the linked list is empty, ˆ start is null ˆ end is null 2. When the linked list is nonempty, ˆ start refers to the first node of the list ˆ end refers to the last node of the list ˆ if the list contains exactly one node, then both start s and end s next and prev fields are null ˆ if the list contains more than one node, then only end.next and start.prev are null; no other node s next or prev fields are null Figure 1: The doubly-linked list (12, 99, 37). The goal of this problem is to extend the IList interface and the DoublyLinkedList class to include get, remove, reverse, removefirst, and removelast methods: ˆ The get method takes as input an index, say i, and returns the ith item in the list. You should assume 0-indexing, like in arrays, where the first item in the list has index 0. If there is an index that is too large, or if the list is empty, you should throw an exception. ˆ The remove method takes as input an item, the first instance of which it proceeds to remove from the list. It returns a boolean indicating whether or not the remove operation was successful: i.e., was the item successfully found in the list and removed or not? 4

5 ˆ The reverse method reverses the order of the items in the list that it is called on. It should take O(n) time and O(1) space (it should not create any new lists), where n is the number of items in the list. ˆ The removefirst method removes the first item in the list and returns it. If there are no items in the list, it throws an exception. ˆ The removelast method removes the last item in the list and returns it. If there are no items in the list, it throws an exception. What are the signatures of these five methods? That is, what should their arguments and return types be? Task: Extend the given IList interface to a new interface called IExtList that requires these five methods. Think about how this interface IExtList might be useful. Right now, we only are having you implement DoublyLinkedLists, but how might having this interface be important if you were to design a SinglyLinkedList class (or, more generally, a hierarchy of lists) as well? Task: Write a doubly-linked list class, DoublyLinkedList, with a static nested Node class. Your doubly-linked list class should implement your IExtList interface, meaning it should implement all the methods we implemented in class for (singly-)linked lists, as well as the ones presented above. Furthermore, your DoublyLinkedList should extend the AbsList abstract class provided in the support code. This class, given an iterator, implements tostring and equals. Consequently, if your DoublyLinkedList extends this class, then once you write an iterator (which you must, because IList, and hence IExtList, extends Iterable), you will inherit implementations of tostring and equals for free. Wow! Object-oriented programming is powerful! Task: Write an iterator for your DoublyLinkedList. Hint: You should model your solution after our implementation of singly-linked lists, found in Lecture 7. If you need to report an error, throw a NoSuchElementException, or an IndexOutOf- BoundsException, as relevant. As usual, you must exhaustively test your DoublyLinkedList methods! However, because we are working with mutable data, you should create a setup method in your test class. A setup method takes in nothing and returns an object that you will perform tests on; in this case, a DoublyLinkedList. You know the contents of this list, because the method makes a list, exactly as you want, and returns it. This allows you to safely perform tests. We use setup methods because we want our tests to pass regardless of what order the test methods are run in. If we were running tests on a DoublyLinkedList that was a global variable in our test class, switching the order of our testadd and testremove methods would be disastrous. But if we create a new DoublyLinkedList in each test method, we won t run into any issues! Here s an example of what a setup method could look like: /** * A setup method for a basic list a basic linked list */ public IExtList<Integer> setupbasiclist() { IExtList<Integer> dll = new DoublyLinkedList<Integer>(); 5

6 } dll.addfirst(1); dll.addfirst(5); dll.addfirst(10); return dll // A doubly linked list with elements 10,5,1, in that order // A method to test get public void testget(tester t) { IExtList<Integer> testlist = setupbasiclist(); t.checkexpect(testlist.get(0), 10);... } The contents of this list are up to you, but you should make several setup methods so that you can test methods such as remove and reverse. Remember to check edge cases! Task: Write a class to exhaustively test your DoublyLinkedList methods, including those methods found in the iterator (except the methods given to you in source code). Be sure to use at least one setup method to create DoublyLinkedLists for testing. Just for Fun: Can you figure out how to implement reverse in constant time? Consider trading off space for time. 2 SeatMap Word has gotten out about your CS skills, and as such, you have been contracted to help design a system for booking seats. Specifically, you are to design a SeatMap class. The constructor for this class should take in one parameter, an integer specifying the number of seats in the row as a whole. The class itself should contain the following: ˆ A single array of booleans, which represents the seat availability, where false represents a taken seat, and true represents an empty seat. Upon constructing a SeatMap object, every index in this array should be true (i.e. the row of seats should be entirely empty). ˆ The bookseats method, which takes the number of consecutive seats to reserve and the starting seat number and sets all the seats to reserve to false in the array. This method should assume that the seats it is supposed to book are open. ˆ The findblock method, which takes the number of (consecutive) seats that someone wants to find and a seat number from which to start searching. The method returns either (a) a seat number from which there are the requested number of consecutive seats available, or (b) throws an exception if there are no blocks of open seats at the requested size (more on this later). Task: Create the SeatMap.java class with the appropriate constructor, and implement the bookseats method. As you begin to think about the problem, you come to realize that there are many ways in which you can implement the findblock method, some better than others. You decide to start small, and go with the first method you can think of. 6

7 Task: In your SeatMap class, create the findblock1 method, which uses 2 for loops to find the the requested blocks of seats one to iterate across each seat, and another to iterate starting from a given seat, and checking each consecutive seat to see if it s open. For this part, don t use break, and don t worry about efficiency. Here, and for all future findblock methods, you don t have to worry about bad inputs (like a negative start seat). You successfully complete findblock1, but you have some reservations. In particular, you feel that this is inefficient. Despite the fact that the inner loop might find an occupied seat, you continue to iterate, which is wasteful. You decide to step it up, and make an even faster version. Task: Create a helper method checkseats, which takes the seat to start checking from and the number of seats to look for. It then returns a boolean indicating whether the requested number of seats is available from the given start seat. This method should return as soon as an occupied seat is found (i.e, as soon as you know that you can t find a block of the appropriate size starting from a given seat). Write this function without using loop operators, that is, in the CS 17 style of recursion. Task: Create a method findblock2, which takes the implementation of findblock1, but replaces the inner loop with your newly created checkseats method. You are making good progress, but feel weird that you re doing recursion in a homework about imperative programming. You decide a change needs to be made. Task: Create a helper method checkseats2, which performs the same task as checkseats (and uses the same type signature), but instead uses a while loop, rather than recursion. Task: Create a method findblock3, which takes the implementation of findblock2,but replaces checkseats with checkseats2. You are satisfied now that you are back in the land of imperative programming (though you do note that you haven t changed your efficiency much, as recursion is not necessarily more expensive given modern compilation techniques). You determine that there is another speedup you can make to your program, this time with the outer loop. This outer loop still checks seats that can t work, as it checks every seat. However, since you know the locations of filled seats, you can use this information to skip checking some seats. For example, if you just checked a seat and it didn t work, you can be sure that the seat next to it also won t work, as it is either occupied, or it is unoccupied, but is also eventually going to be broken up by the later occupied seat which caused the previous seat to fail (Figure 2). Task: Create a method findblock4, which does the following: ˆ Takes the logic from checkseats2 (that is, a while loop with stopping at the first occupied seat), and puts it in an inner loop ˆ Creates an outer loop with a while, that uses the info from the inner loop to cleverly skip over seats that don t need to be checked You are now happy that you have become efficient in both your outer and inner loop, and as such, have become an even better student of imperative programming. Task: Create the findblock method, which simply makes a call to your findblock4 method. Task: When all the seats in a row are filled or there are no consecutive seats available, you want to throw an exception explaining that there are no more seats available. When you reach a point in your solution when there are no seats available or not enough consecutive seats, throw a 7

8 Figure 2: Suppose you are looking for 3 consecutive seats. Seat 0 is occupied so you move onto seat 1. You check seats 1, 2, and 3, and find that seat 3 is occupied. Seat 1 will not work. After checking seat 1, you can skip over 2 and 3 (directly to seat 4), since you know seats 2 and 3 will not work either X X NoSuchElementException (throw new NoSuchElementException("No Seats Available")). When you are conducting testing for your SeatMap class, you can use the t.checkexception() method to test your exceptions. Task: Test all of your methods, and test them exhaustively. Additionally, since we are working with mutable data, be sure to create a setup method to use between your tests, the same way you did for DoublyLinkedList testing. 3 Memory Maps for Lists and Mutation For this final task, we want you to work with memory maps for linked lists in the presence of mutation. We also want to ask some questions about your general understanding of this concept (to help us assess the effectiveness of the way in which we are covering this material). Some tasks on this part of the assignment ask you to answer questions in Google forms. The forms questions are for our course diagnostics, and do not have incorrect answers for which you would lose points. Your grade for the form questions will be based on having answered the questions. Despite these not being graded for content, please to answer honestly as this is part of our assessment of whether CS18 activities are being effective. Task: Before you look at the rest of the problem, visit the following URL and answer the multiplechoice question in the form. Thor has decided to retire from his role as King of Asgard and open up a small online shop, which he s called the sthore. His shop maintains a catalog, which is a LinkedList of items, each with a description and price, and a LinkedList of open orders, each with the name of a customer and a LinkedList of items that they have ordered. You can find the source code for this under catalogs in your hw02 src directory. The shop already has a few items and open orders for you to manage! The shop has written two different functions to update the price of an item in the catalog; they are called updateprice1 and updateprice2. 8

9 Task: Inside Main.java, you ll find a sequence of calls to these update methods. Without running the program or tracing it in detail, predict what you believe the openorders will contain after the sequence of price updates. Record your answer in the form at the following url (this is again a diagnostic question for us): Task: (Graded for Correctness) Now, we want you to show us the contents of the heap (the objects area of the memory map) at each Memory Point that is marked with a comment in Main.java. To make this easier, we ve set up an initial objects heap with most of the objects and known names already filled in. You will copy and edit our initial diagram (within a Google Slides presentation) to produce your answers. Here are the detailed instructions for doing so: 1. Navigate to the following Google Slides page and make a copy of it (File Make a copy) Set the sharing on your copy so that anyone with the link at Brown can view (you will share the link with the staff at handin, but obviously don t distribute or publicize your link beyond the handin process, as that would violate the collaboration policy). 3. There are three slides: the first has some template objects (for LinkedLists and Items), and the second and third are identical copies of the initial object heap. The template slide has two templates for LinkedLists, one with the item field first and one with the next field first. Use whichever one is more convenient for connecting arrows to items in your diagram. 4. Edit slide 3 to create the object heap diagram for the first memory point (slide 2 is there as a backup in case you need a fresh copy on which to start over). Duplicate that diagram to create the next one, and so on. You should end up with 6 slides: the template, the backup, and one for each of the four memory points in Main.java (we will grade only the last four). As you can see in the starter slide (which you should have duplicated), we have already filled out some objects for Memory Point 1 in Main.java. Edit the duplicate so that the slide shows the object heap at Memory Point 1. Make it so that everything in the heap is represented in this slide and that this slide only contains things in the heap. This might include filling in some objects, removing objects, adding objects, moving arrows, adding arrows, removing arrows, etc.. We have started filling in Tony Stark s order as well as the openorders linked-list as examples of the kinds of connections we are expecting. We have started filling in the Shop object for you as well. Complete this object as well. Since this object s fields might span a lot of space, please change the dash of the arrows to make them easier to differentiate from more local arrows. When you have finished with the first memory point, duplicate this slide and start working on the next memory point. Please highlight the differences between two consecutive slides (memory points) by bolding the names of any fields that change in any object and by significantly thickening any arrows that change. If you change a field that has a value rather than an arrow, change the value and put it in bold (you can change the value by clicking on the current value, which brings up a box with the text). 9

10 To handin, fill out the following (final) Google form. The contents of your slides diagram will be graded, but the questions are diagostic for us. Additionally, be sure to make a.txt file with a link to your Google Slides, and turn that in with the rest of your code on the department machines. Make sure there is no identifying information (like name, login, etc) in your slides. 3.1 Google Sheet Tips (if needed) To create links/arrows between fields and objects in the map, you will use the line tool. You can click the drop-down arrow next to the line icon for line-drawing options the Curved Connector, Elbow Connector, and Arrow tools work well when items are close together. For objects that are farther apart or for areas that are particularly dense with arrows, the Curve tool might be better. Furthermore, if an arrow intersects many other others or covers a lot of space, feel free to change its color and its dash to differentiate it from others. To add more objects, either copy and paste from the template slide or duplicate already existing objects with Ctrl+D or Command+D. To delete objects, select them by dragging your mouse over their area. If you accidentally select too many things, click the things you do not want to select while holding Ctrl (or Command). You are welcome to practice with the line tool on the template slide, if you wish. Notice how you can change the color (select the pencil icon, not the bucket icon), the endings, the dash, and the thickness of the line. Knowing how to do these will be necessary to complete the assignment. 10

11 4 Appendix Here is a class diagram that depicts the structure that the source files and your solution files should have after you finish implementing doubly-linked lists: public interface IList extends Iterable<T> public boolean isempty(); public T getfirst(); public T getlast(); public void addfirst(t item); public void addlast(t item); implements extends public abstract class AbsList public String tostring(); public boolean equals(object o); public interface IExtList public T removefirst(); public T removelast(); public boolean remove(t item); public void reverse(); public T get(int index); extends implements public class DoublyLinkedList protected static class Node<S>; public DoublyLinkedList(); public boolean isempty(); public T getfirst(); public T getlast(); public void addfirst(t item); public void addlast(t item); public T removefirst(); public T removelast(); public boolean remove(t item); public void reverse(); public T get(int index); public Iterator<T> iterator(); Please let us know if you find any mistakes, inconsistencies, or confusing language in this or 11

12 any other CS18 document by filling out the anonymous feedback form: courses/cs018/feedback. 12

Homework 2: Imperative Due: 5:00 PM, Feb 15, 2019

Homework 2: Imperative Due: 5:00 PM, Feb 15, 2019 CS18 Integrated Introduction to Computer Science Fisler Homework 2: Imperative Due: 5:00 PM, Feb 15, 2019 Contents 1 Overview of Generic/Parameterized Types 2 2 Double the Fun with Doubly-Linked Lists

More information

Lecture 8: Iterators and More Mutation

Lecture 8: Iterators and More Mutation Integrated Introduction to Computer Science Fisler, Nelson Contents 1 Traversing Lists 1 2 Motivating Iterators 2 3 Writing an Iterator 3 4 Writing Sum with an Iterator 4 Objectives By the end of this

More information

Homework 4: Hash Tables Due: 5:00 PM, Mar 9, 2018

Homework 4: Hash Tables Due: 5:00 PM, Mar 9, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Contents Homework 4: Hash Tables Due: 5:00 PM, Mar 9, 2018 1 DIY Grep 2 2 Chaining Hash Tables 4 3 Hash Table Iterator 5 Objectives By the

More information

Homework 7: Subsets Due: 11:59 PM, Oct 23, 2018

Homework 7: Subsets Due: 11:59 PM, Oct 23, 2018 CS17 Integrated Introduction to Computer Science Klein Contents Homework 7: Subsets Due: 11:59 PM, Oct 23, 2018 1 Bookends (Practice) 2 2 Subsets 3 3 Subset Sum 4 4 k-subsets 5 5 k-subset Sum 5 Objectives

More information

Homework 5: Fun with Scala Due: 5:00 PM, Mar 16, 2018

Homework 5: Fun with Scala Due: 5:00 PM, Mar 16, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Contents Homework 5: Fun with Scala Due: 5:00 PM, Mar 16, 2018 1 Shopping Cart 2 2 Vote Counting 3 3 Earthquake 4 4 Arrays 5 Objectives By

More information

Lecture 5: Implementing Lists, Version 1

Lecture 5: Implementing Lists, Version 1 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 5: Implementing Lists, Version 1 Contents 1 Implementing Lists 1 2 Methods 2 2.1 isempty...........................................

More information

Lab 4: Imperative & Debugging 12:00 PM, Feb 14, 2018

Lab 4: Imperative & Debugging 12:00 PM, Feb 14, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lab 4: Imperative & Debugging 12:00 PM, Feb 14, 2018 Contents 1 Imperative Programming 1 1.1 Sky High Grades......................................

More information

Lecture 7: Implementing Lists, Version 2

Lecture 7: Implementing Lists, Version 2 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 7: Implementing Lists, Version 2 Contents 1 The Impact of addfirst on Lists 1 2 Mutating List Contents 2 2.1 The Basic List Classes...................................

More information

Homework 8: Matrices Due: 11:59 PM, Oct 30, 2018

Homework 8: Matrices Due: 11:59 PM, Oct 30, 2018 CS17 Integrated Introduction to Computer Science Klein Homework 8: Matrices Due: 11:59 PM, Oct 30, 2018 Contents 1 Reverse (Practice) 4 2 Main Diagonal (Practice) 5 3 Horizontal Flip 6 4 Vertical Flip

More information

Homework 6: Higher-Order Procedures Due: 10:00 PM, Oct 17, 2017

Homework 6: Higher-Order Procedures Due: 10:00 PM, Oct 17, 2017 Integrated Introduction to Computer Science Hughes Homework 6: Higher-Order Procedures Due: 10:00 PM, Oct 17, 2017 Contents 1 Fun with map (Practice) 2 2 Unfold (Practice) 3 3 Map2 3 4 Fold 4 5 All You

More information

Lab 5: Java IO 12:00 PM, Feb 21, 2018

Lab 5: Java IO 12:00 PM, Feb 21, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Contents Lab 5: Java IO 12:00 PM, Feb 21, 2018 1 The Java IO Library 1 2 Program Arguments 2 3 Readers, Writers, and Buffers 2 3.1 Buffering

More information

Lab 2: Object-Oriented Design 12:00 PM, Jan 31, 2018

Lab 2: Object-Oriented Design 12:00 PM, Jan 31, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Contents Lab 2: Object-Oriented Design 12:00 PM, Jan 31, 2018 1 Terminology 1 2 Class Hierarchy Diagrams 2 2.1 An Example: Animals...................................

More information

Announcements. Prelude (2) Prelude (1) Data Structures and Information Systems Part 1: Data Structures. Lecture 6: Lists.

Announcements. Prelude (2) Prelude (1) Data Structures and Information Systems Part 1: Data Structures. Lecture 6: Lists. Announcements MODULE WEB-SITE: http://www.csc.liv.ac.uk/ michele/teaching/comp102/comp102.html FIRST ASSIGNMENT DEADLINE: Wednesday, February 1st, 14.30, LAB 7 Boxes (late submissions to be left in the

More information

Homework 6: Heaps Due: 5:00 PM, Apr 9, 2018

Homework 6: Heaps Due: 5:00 PM, Apr 9, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Contents Homework 6: Heaps Due: 5:00 PM, Apr 9, 2018 1 Sifting Up and Down 2 2 Text Processing 3 3 Appendix 6 Objectives By the end of this

More information

Homework 3: Recursion Due: 11:59 PM, Sep 25, 2018

Homework 3: Recursion Due: 11:59 PM, Sep 25, 2018 CS17 Integrated Introduction to Computer Science Klein Homework 3: Recursion Due: 11:59 PM, Sep 25, 2018 Contents 1 Factorial 3 2 Fibonacci 4 3 Odds Only 5 4 Increment All 6 5 Frequency 6 6 Sublist 7 6.1

More information

CS 051 Homework Laboratory #2

CS 051 Homework Laboratory #2 CS 051 Homework Laboratory #2 Dirty Laundry Objective: To gain experience using conditionals. The Scenario. One thing many students have to figure out for the first time when they come to college is how

More information

Lab 1: Introduction to Java

Lab 1: Introduction to Java Lab 1: Introduction to Java Welcome to the first CS15 lab! In the reading, we went over objects, methods, parameters and how to put all of these things together into Java classes. It's perfectly okay if

More information

ITI Introduction to Computing II

ITI Introduction to Computing II index.pdf March 17, 2013 1 ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Version of March 17, 2013 Definitions A List is a linear abstract

More information

Lab 10: Sockets 12:00 PM, Apr 4, 2018

Lab 10: Sockets 12:00 PM, Apr 4, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lab 10: Sockets 12:00 PM, Apr 4, 2018 Contents 1 The Client-Server Model 1 1.1 Constructing Java Sockets.................................

More information

Lab 1: Setup 12:00 PM, Sep 10, 2017

Lab 1: Setup 12:00 PM, Sep 10, 2017 CS17 Integrated Introduction to Computer Science Hughes Lab 1: Setup 12:00 PM, Sep 10, 2017 Contents 1 Your friendly lab TAs 1 2 Pair programming 1 3 Welcome to lab 2 4 The file system 2 5 Intro to terminal

More information

Student Success Guide

Student Success Guide Student Success Guide Contents Like a web page, links in this document can be clicked and they will take you to where you want to go. Using a Mouse 6 The Left Button 6 The Right Button 7 The Scroll Wheel

More information

CS231 - Spring 2017 Linked Lists. ArrayList is an implementation of List based on arrays. LinkedList is an implementation of List based on nodes.

CS231 - Spring 2017 Linked Lists. ArrayList is an implementation of List based on arrays. LinkedList is an implementation of List based on nodes. CS231 - Spring 2017 Linked Lists List o Data structure which stores a fixed-size sequential collection of elements of the same type. o We've already seen two ways that you can store data in lists in Java.

More information

Lab 4: Super Sudoku Solver CSCI 2101 Fall 2017

Lab 4: Super Sudoku Solver CSCI 2101 Fall 2017 Due: Wednesday, October 18, 11:59 pm Collaboration Policy: Level 1 Group Policy: Pair-Optional Lab 4: Super Sudoku Solver CSCI 2101 Fall 2017 In this week s lab, you will write a program that can solve

More information

Lecture 1: Overview

Lecture 1: Overview 15-150 Lecture 1: Overview Lecture by Stefan Muller May 21, 2018 Welcome to 15-150! Today s lecture was an overview that showed the highlights of everything you re learning this semester, which also meant

More information

(Provisional) Lecture 08: List recursion and recursive diagrams 10:00 AM, Sep 22, 2017

(Provisional) Lecture 08: List recursion and recursive diagrams 10:00 AM, Sep 22, 2017 Integrated Introduction to Computer Science Hughes (Provisional) Lecture 08: List recursion and recursive diagrams 10:00 AM, Sep 22, 2017 Contents 1 Announcements 1 2 Evaluation Correction 1 3 Lists 2

More information

Lecture 16: HashTables 10:00 AM, Mar 2, 2018

Lecture 16: HashTables 10:00 AM, Mar 2, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 16: HashTables 10:00 AM, Mar 2, 2018 Contents 1 Speeding up Lookup 1 2 Hashtables 2 2.1 Java HashMaps.......................................

More information

Homework 1: Classes Due: 5:00 PM, Feb 9, 2018

Homework 1: Classes Due: 5:00 PM, Feb 9, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Homework 1: Classes Due: 5:00 PM, Feb 9, 2018 Contents 1 Shape-ology 2 1.1 Rectangle: Take 1..................................... 3 1.2 Triangle...........................................

More information

hw6, BFS, debugging CSE 331 Section 5 10/25/12 Slides by Kellen Donohue

hw6, BFS, debugging CSE 331 Section 5 10/25/12 Slides by Kellen Donohue hw6, BFS, debugging CSE 331 Section 5 10/25/12 Slides by Kellen Donohue Agenda hw4 being graded hw5 may be graded first, for feedback to be used on hw6 hw6 due next week Today hw6 BFS Debugging hashcode()

More information

Homework 6: Higher-Order Procedures Due: 11:59 PM, Oct 16, 2018

Homework 6: Higher-Order Procedures Due: 11:59 PM, Oct 16, 2018 Integrated Introduction to Computer Science Klein Homework 6: Higher-Order Procedures Due: 11:59 PM, Oct 16, 2018 Contents 1 Fun with map (Practice) 2 2 Unfold (Practice) 3 3 Map2 3 4 Fold 4 5 All You

More information

CSCI 200 Lab 3 Using and implementing sets

CSCI 200 Lab 3 Using and implementing sets CSCI 200 Lab 3 Using and implementing sets In this lab, you will write a program that manages a set of workers, using the Worker hierarchy you developed in Lab 2. You will also implement your own version

More information

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time) CSE 11 Winter 2017 Program Assignment #2 (100 points) START EARLY! Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time) PROGRAM #2: DoubleArray11 READ THE ENTIRE ASSIGNMENT BEFORE STARTING In lecture,

More information

Working with recursion. From definition to template. Readings: HtDP, sections 11, 12, 13 (Intermezzo 2).

Working with recursion. From definition to template. Readings: HtDP, sections 11, 12, 13 (Intermezzo 2). Working with recursion Readings: HtDP, sections 11, 12, 13 (Intermezzo 2). We can extend the idea of a self-referential definition to defining the natural numbers, which leads to the use of recursion in

More information

Working with recursion

Working with recursion Working with recursion Readings: HtDP, sections 11, 12, 13 (Intermezzo 2). We can extend the idea of a self-referential definition to defining the natural numbers, which leads to the use of recursion in

More information

Good Coding Practices Spring 2018

Good Coding Practices Spring 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Contents Good Coding Practices Spring 2018 1 Introduction 1 2 The Don ts 1 3 The Dos 4 4 CS 18-Specific Practices 5 5 Style 6 1 Introduction

More information

Lecture 23: Priority Queues, Part 2 10:00 AM, Mar 19, 2018

Lecture 23: Priority Queues, Part 2 10:00 AM, Mar 19, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 23: Priority Queues, Part 2 10:00 AM, Mar 19, 2018 Contents 1 Heap Implementation 1 1.1 Insert............................................

More information

Lab 9: More Sorting Algorithms 12:00 PM, Mar 21, 2018

Lab 9: More Sorting Algorithms 12:00 PM, Mar 21, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lab 9: More Sorting Algorithms 12:00 PM, Mar 21, 2018 Contents 1 Heapsort 2 2 Quicksort 2 3 Bubble Sort 3 4 Merge Sort 3 5 Mirror Mirror

More information

CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists

CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists Due on Tuesday February 24, 2015, 8:30 a.m. Marc Liberatore and John Ridgway Morrill I N375 Section 01 @ 10:00 Section 02 @ 08:30 1 CMPSCI

More information

CSE 143: Computer Programming II Summer 2017 HW5: Anagrams (due Thursday, August 3, :30pm)

CSE 143: Computer Programming II Summer 2017 HW5: Anagrams (due Thursday, August 3, :30pm) CSE 143: Computer Programming II Summer 2017 HW5: Anagrams (due Thursday, August 3, 2017 11:30pm) This assignment focuses on recursive backtracking. Turn in the following files using the link on the course

More information

Tips from the experts: How to waste a lot of time on this assignment

Tips from the experts: How to waste a lot of time on this assignment Com S 227 Spring 2018 Assignment 1 100 points Due Date: Friday, September 14, 11:59 pm (midnight) Late deadline (25% penalty): Monday, September 17, 11:59 pm General information This assignment is to be

More information

CSCI Lab 9 Implementing and Using a Binary Search Tree (BST)

CSCI Lab 9 Implementing and Using a Binary Search Tree (BST) CSCI Lab 9 Implementing and Using a Binary Search Tree (BST) Preliminaries In this lab you will implement a binary search tree and use it in the WorkerManager program from Lab 3. Start by copying this

More information

CS61BL Summer 2013 Midterm 2

CS61BL Summer 2013 Midterm 2 CS61BL Summer 2013 Midterm 2 Sample Solutions + Common Mistakes Question 0: Each of the following cost you.5 on this problem: you earned some credit on a problem and did not put your five digit on the

More information

Lab 7: OCaml 12:00 PM, Oct 22, 2017

Lab 7: OCaml 12:00 PM, Oct 22, 2017 CS17 Integrated Introduction to Computer Science Hughes Lab 7: OCaml 12:00 PM, Oct 22, 2017 Contents 1 Getting Started in OCaml 1 2 Pervasives Library 2 3 OCaml Basics 3 3.1 OCaml Types........................................

More information

CSE 143: Computer Programming II Spring 2015 HW2: HTMLManager (due Thursday, April 16, :30pm)

CSE 143: Computer Programming II Spring 2015 HW2: HTMLManager (due Thursday, April 16, :30pm) CSE 143: Computer Programming II Spring 2015 HW2: HTMLManager (due Thursday, April 16, 2015 11:30pm) This assignment focuses on using Stack and Queue collections. Turn in the following files using the

More information

Lecture 14: Exceptions 10:00 AM, Feb 26, 2018

Lecture 14: Exceptions 10:00 AM, Feb 26, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 14: Exceptions 10:00 AM, Feb 26, 2018 Contents 1 Exceptions and How They Work 1 1.1 Update to the Banking Example.............................

More information

1.00 Introduction to Computers and Engineering Problem Solving. Final Examination - May 19, 2004

1.00 Introduction to Computers and Engineering Problem Solving. Final Examination - May 19, 2004 1.00 Introduction to Computers and Engineering Problem Solving Final Examination - May 19, 2004 Name: E-mail Address: TA: Section: You have 3 hours to complete this exam. For coding questions, you do not

More information

Data Structures Brett Bernstein

Data Structures Brett Bernstein Data Structures Brett Bernstein Lecture 8: Iterators, Maps, and Hashtables Exercises 1. Show how to print out the elements of a doubly linked list in reverse order. 2. What are the Java API classes that

More information

CMSC 201 Spring 2018 Project 2 Battleship

CMSC 201 Spring 2018 Project 2 Battleship CMSC 201 Spring 2018 Project 2 Battleship Assignment: Project 2 Battleship Due Date: Design Document: Friday, April 13th, 2018 by 8:59:59 PM Project: Friday, April 20th, 2018 by 8:59:59 PM Value: 80 points

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

Introduction... 3 Introduction... 4

Introduction... 3 Introduction... 4 User Manual Contents Introduction... 3 Introduction... 4 Placing an Order... 5 Overview of the Order Sheet... 6 Ordering Items... 9 Customising your Orders... 11 Previewing and Submitting your Basket...

More information

Department of Electrical Engineering and Computer Sciences Fall 2000 Instructor: Dan Garcia CS 3 Final Exam

Department of Electrical Engineering and Computer Sciences Fall 2000 Instructor: Dan Garcia CS 3 Final Exam University of California, Berkeley College of Engineering Department of Electrical Engineering and Computer Sciences Fall 2000 Instructor: Dan Garcia 2000-12-15 CS 3 Final Exam Last name First name SID

More information

15-122: Principles of Imperative Computation, Fall 2015

15-122: Principles of Imperative Computation, Fall 2015 15-122 Programming 5 Page 1 of 10 15-122: Principles of Imperative Computation, Fall 2015 Homework 5 Programming: Clac Due: Thursday, October 15, 2015 by 22:00 In this assignment, you will implement a

More information

Java Review: Objects

Java Review: Objects Outline Java review Abstract Data Types (ADTs) Interfaces Class Hierarchy, Abstract Classes, Inheritance Invariants Lists ArrayList LinkedList runtime analysis Iterators Java references 1 Exam Preparation

More information

CSE332: Data Abstractions Lecture 22: Shared-Memory Concurrency and Mutual Exclusion. Tyler Robison Summer 2010

CSE332: Data Abstractions Lecture 22: Shared-Memory Concurrency and Mutual Exclusion. Tyler Robison Summer 2010 CSE332: Data Abstractions Lecture 22: Shared-Memory Concurrency and Mutual Exclusion Tyler Robison Summer 2010 1 Toward sharing resources (memory) So far we ve looked at parallel algorithms using fork-join

More information

Lesson 4: Introduction to the Excel Spreadsheet 121

Lesson 4: Introduction to the Excel Spreadsheet 121 Lesson 4: Introduction to the Excel Spreadsheet 121 In the Window options section, put a check mark in the box next to Formulas, and click OK This will display all the formulas in your spreadsheet. Excel

More information

CSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections. Tyler Robison Summer 2010

CSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections. Tyler Robison Summer 2010 CSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections Tyler Robison Summer 2010 1 Concurrency: where are we Done: The semantics of locks Locks in Java Using locks for mutual

More information

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists COMP-202B, Winter 2009, All Sections Due: Tuesday, April 14, 2009 (23:55) You MUST do this assignment individually and, unless otherwise

More information

Lecture 22: Garbage Collection 10:00 AM, Mar 16, 2018

Lecture 22: Garbage Collection 10:00 AM, Mar 16, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 22: Garbage Collection 10:00 AM, Mar 16, 2018 Contents 1 What is Garbage Collection? 1 1.1 A Concrete Example....................................

More information

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM Objectives Defining a wellformed method to check class invariants Using assert statements to check preconditions,

More information

First-Order Translation Checklist

First-Order Translation Checklist CS103 Winter 2019 First-Order Translation Checklist Cynthia Lee Keith Schwarz In this handout, we ve distilled five specific points that you should check in your first-order logic statements before submitting

More information

COMP 250 Winter generic types, doubly linked lists Jan. 28, 2016

COMP 250 Winter generic types, doubly linked lists Jan. 28, 2016 COMP 250 Winter 2016 5 generic types, doubly linked lists Jan. 28, 2016 Java generics In our discussion of linked lists, we concentrated on how to add or remove a node from the front or back of a list.

More information

An Introduction to Data Structures

An Introduction to Data Structures An Introduction to Data Structures Advanced Programming ICOM 4015 Lecture 17 Reading: Java Concepts Chapter 20 Fall 2006 Adapded from Java Concepts Companion Slides 1 Chapter Goals To learn how to use

More information

Repetition Through Recursion

Repetition Through Recursion Fundamentals of Computer Science I (CS151.02 2007S) Repetition Through Recursion Summary: In many algorithms, you want to do things again and again and again. For example, you might want to do something

More information

Lecture 11: In-Place Sorting and Loop Invariants 10:00 AM, Feb 16, 2018

Lecture 11: In-Place Sorting and Loop Invariants 10:00 AM, Feb 16, 2018 Integrated Introduction to Computer Science Fisler, Nelson Lecture 11: In-Place Sorting and Loop Invariants 10:00 AM, Feb 16, 2018 Contents 1 In-Place Sorting 1 2 Swapping Elements in an Array 1 3 Bubble

More information

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Fall 2016 Lab 09 Advanced Debugging CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working

More information

Classes Classes 2 / 36

Classes Classes 2 / 36 Classes 1 / 36 Classes Classes 2 / 36 Anatomy of a Class By the end of next lecture, you ll understand everything in this class definition. package edu. gatech. cs1331. card ; import java. util. Arrays

More information

CSE 143: Computer Programming II Winter 2019 HW6: AnagramSolver (due Thursday, Feb 28, :30pm)

CSE 143: Computer Programming II Winter 2019 HW6: AnagramSolver (due Thursday, Feb 28, :30pm) CSE 143: Computer Programming II Winter 2019 HW6: AnagramSolver (due Thursday, Feb 28, 2019 11:30pm) This assignment focuses on recursive backtracking. Turn in the following files using the link on the

More information

Express Yourself. Writing Your Own Classes

Express Yourself. Writing Your Own Classes Java Programming 1 Lecture 5 Defining Classes Creating your Own Classes Express Yourself Use OpenOffice Writer to create a new document Save the file as LastFirst_ic05 Replace LastFirst with your actual

More information

(Refer Slide Time 6:48)

(Refer Slide Time 6:48) Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology Madras Lecture - 8 Karnaugh Map Minimization using Maxterms We have been taking about

More information

CIS 121 Data Structures and Algorithms with Java Spring 2018

CIS 121 Data Structures and Algorithms with Java Spring 2018 CIS 121 Data Structures and Algorithms with Java Spring 2018 Homework 2 Thursday, January 18 Due Monday, January 29 by 11:59 PM 7 Required Problems (85 points), and Style and Tests (15 points) DO NOT modify

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

9/26/2018 Data Structure & Algorithm. Assignment04: 3 parts Quiz: recursion, insertionsort, trees Basic concept: Linked-List Priority queues Heaps

9/26/2018 Data Structure & Algorithm. Assignment04: 3 parts Quiz: recursion, insertionsort, trees Basic concept: Linked-List Priority queues Heaps 9/26/2018 Data Structure & Algorithm Assignment04: 3 parts Quiz: recursion, insertionsort, trees Basic concept: Linked-List Priority queues Heaps 1 Quiz 10 points (as stated in the first class meeting)

More information

Training Manual and Help File

Training Manual and Help File Training Manual and Help File 30.06.2011 Update Manage Grow Welcome to your new Juniper Website Management System with CMS Introduction The Juniper Website Management System with CMS (Website Content Management

More information

Welcome to... CS113: Introduction to C

Welcome to... CS113: Introduction to C Welcome to... CS113: Introduction to C Instructor: Erik Sherwood E-mail: wes28@cs.cornell.edu Course Website: http://www.cs.cornell.edu/courses/cs113/2005fa/ The website is linked to from the courses page

More information

CSE 143: Computer Programming II Summer 2015 HW6: 20 Questions (due Thursday, August 13, :30pm)

CSE 143: Computer Programming II Summer 2015 HW6: 20 Questions (due Thursday, August 13, :30pm) CSE 143: Computer Programming II Summer 2015 HW6: 20 Questions (due Thursday, August 13, 2015 11:30pm) This assignment focuses on binary trees and recursion. Turn in the following files using the link

More information

CMPSCI 187 / Spring 2015 Sorting Kata

CMPSCI 187 / Spring 2015 Sorting Kata Due on Thursday, April 30, 8:30 a.m Marc Liberatore and John Ridgway Morrill I N375 Section 01 @ 10:00 Section 02 @ 08:30 1 Contents Overview 3 Learning Goals.................................................

More information

CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer

CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer Assigned: Thursday, September 16, 2004 Due: Tuesday, September 28, 2004, at 11:59pm September 16, 2004 1 Introduction Overview In this

More information

CMPSCI 187 / Spring 2015 Hangman

CMPSCI 187 / Spring 2015 Hangman CMPSCI 187 / Spring 2015 Hangman Due on February 12, 2015, 8:30 a.m. Marc Liberatore and John Ridgway Morrill I N375 Section 01 @ 10:00 Section 02 @ 08:30 1 CMPSCI 187 / Spring 2015 Hangman Contents Overview

More information

Comp Intermediate Programming EXAM #1 February 16, 2004 Rice University - Instructors: Cox & Nguyen

Comp Intermediate Programming EXAM #1 February 16, 2004 Rice University - Instructors: Cox & Nguyen Instructions 1. This exam is conducted under the Rice Honor Code. It is a closed-notes, closed-book exam. 2. Fill in your name on every page of the exam. 3. If you forget the name of a Java class or method,

More information

Lecture 23: Priority Queues 10:00 AM, Mar 19, 2018

Lecture 23: Priority Queues 10:00 AM, Mar 19, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 23: Priority Queues 10:00 AM, Mar 19, 2018 Contents 1 Priority Queues 1 2 Binary Heaps 2 3 Heaps 4 4 Aside: The Ordered Trait 5 5

More information

Lecture 23: Priority Queues, Part 2 10:00 AM, Mar 19, 2018

Lecture 23: Priority Queues, Part 2 10:00 AM, Mar 19, 2018 CS8 Integrated Introduction to Computer Science Fisler, Nelson Lecture : Priority Queues, Part : AM, Mar 9, 8 Contents Sorting, Revisited Counting Sort Bucket Sort 4 Radix Sort 6 4. MSD Radix Sort......................................

More information

Software Design and Analysis for Engineers

Software Design and Analysis for Engineers Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 9 Date:

More information

ACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1

ACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1 ACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1 Due to CMS by Tuesday, February 14. Social networking has caused a return of the dot-com madness. You want in on the easy money, so you have decided to make

More information

Lab 1 Implementing a Simon Says Game

Lab 1 Implementing a Simon Says Game ECE2049 Embedded Computing in Engineering Design Lab 1 Implementing a Simon Says Game In the late 1970s and early 1980s, one of the first and most popular electronic games was Simon by Milton Bradley.

More information

Racket Style Guide Fall 2017

Racket Style Guide Fall 2017 CS17 Integrated Introduction to Computer Science Hughes Racket Style Guide Fall 2017 Contents 1 Introduction 1 2 Naming 1 3 Formatting 1 4 Equality 3 5 Conditionals 4 5.1 Prefer Cond to If......................................

More information

[2:3] Linked Lists, Stacks, Queues

[2:3] Linked Lists, Stacks, Queues [2:3] Linked Lists, Stacks, Queues Helpful Knowledge CS308 Abstract data structures vs concrete data types CS250 Memory management (stack) Pointers CS230 Modular Arithmetic !!!!! There s a lot of slides,

More information

Writeup for first project of CMSC 420: Data Structures Section 0102, Summer Theme: Threaded AVL Trees

Writeup for first project of CMSC 420: Data Structures Section 0102, Summer Theme: Threaded AVL Trees Writeup for first project of CMSC 420: Data Structures Section 0102, Summer 2017 Theme: Threaded AVL Trees Handout date: 06-01 On-time deadline: 06-09, 11:59pm Late deadline (30% penalty): 06-11, 11:59pm

More information

The compiler is spewing error messages.

The compiler is spewing error messages. Appendix B Debugging There are a few different kinds of errors that can occur in a program, and it is useful to distinguish between them in order to track them down more quickly. Compile-time errors are

More information

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently. The Science of Computing I Lesson 4: Introduction to Data Structures Living with Cyber Pillar: Data Structures The need for data structures The algorithms we design to solve problems rarely do so without

More information

Soda Machine Laboratory

Soda Machine Laboratory Soda Machine Laboratory Introduction This laboratory is intended to give you experience working with multiple queue structures in a familiar real-world setting. The given application models a soda machine

More information

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09 Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09 Hello, today we will create another application called a math quiz. This

More information

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet. Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that

More information

Laboratory 1: Eclipse and Karel the Robot

Laboratory 1: Eclipse and Karel the Robot Math 121: Introduction to Computing Handout #2 Laboratory 1: Eclipse and Karel the Robot Your first laboratory task is to use the Eclipse IDE framework ( integrated development environment, and the d also

More information

COMP 250 Winter stacks Feb. 2, 2016

COMP 250 Winter stacks Feb. 2, 2016 Stack ADT You are familiar with stacks in your everyday life. You can have a stack of books on a table. You can have a stack of plates on a shelf. In computer science, a stack is an abstract data type

More information

CS 151. Linked Lists, Recursively Implemented. Wednesday, October 3, 12

CS 151. Linked Lists, Recursively Implemented. Wednesday, October 3, 12 CS 151 Linked Lists, Recursively Implemented 1 2 Linked Lists, Revisited Recall that a linked list is a structure that represents a sequence of elements that are stored non-contiguously in memory. We can

More information

CS 61B Discussion 5: Inheritance II Fall 2014

CS 61B Discussion 5: Inheritance II Fall 2014 CS 61B Discussion 5: Inheritance II Fall 2014 1 WeirdList Below is a partial solution to the WeirdList problem from homework 3 showing only the most important lines. Part A. Complete the implementation

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 43 Dynamic Binding (Polymorphism): Part III Welcome to Module

More information

CMPSCI 187 / Spring 2015 Hanoi

CMPSCI 187 / Spring 2015 Hanoi Due on Thursday, March 12, 2015, 8:30 a.m. Marc Liberatore and John Ridgway Morrill I N375 Section 01 @ 10:00 Section 02 @ 08:30 1 Contents Overview 3 Learning Goals.................................................

More information

16 Multiple Inheritance and Extending ADTs

16 Multiple Inheritance and Extending ADTs Object-Oriented Design Lecture 16 CS 3500 Fall 2009 (Pucella) Tuesday, Nov 10, 2009 16 Multiple Inheritance and Extending ADTs We looked last time at inheritance and delegation as two ways to reuse implementation

More information

1 ICS 161: Design and Analysis of Algorithms Lecture notes for January 23, Bucket Sorting

1 ICS 161: Design and Analysis of Algorithms Lecture notes for January 23, Bucket Sorting 1 ICS 161: Design and Analysis of Algorithms Lecture notes for January 23, 1996 2 Bucket Sorting We ve seen various algorithms for sorting in O(n log n) time and a lower bound showing that O(n log n) is

More information

CS2112 Fall Assignment 4 Parsing and Fault Injection. Due: March 18, 2014 Overview draft due: March 14, 2014

CS2112 Fall Assignment 4 Parsing and Fault Injection. Due: March 18, 2014 Overview draft due: March 14, 2014 CS2112 Fall 2014 Assignment 4 Parsing and Fault Injection Due: March 18, 2014 Overview draft due: March 14, 2014 Compilers and bug-finding systems operate on source code to produce compiled code and lists

More information