Server: Discrete Event-Driven Simulations

Size: px
Start display at page:

Download "Server: Discrete Event-Driven Simulations"

Transcription

1 Professor Wittie CSCI 204 Introduction to Computer Science II Fall Objectives Use a Queue ADT Use an enum Use inheritance Design and execute a test plan Use version control Use Javadoc Write documentation Revise your work Comment your code Server: Discrete Event-Driven Simulations 2 Background Systems such as banks or webservers provide services to clients. The efficiency of a row of bank tellers or a set of processors for a webserver can be measured by how long the client had to wait before service began. These systems can be simulated to give us efficiency data so that the bank or webserver maintainers can improve the service if necessary. 3 Assignment Write a program to simulate the behavior of a web server with a waiting queue. The simulation here is a Discrete Event Driven Simulation. The simulation is based on events happening in the system over time. The waiting queue holds requests which have come in and have to wait for the server when it is too busy. 4 The Web Server The web server to simulate is called All-In-One-Server, or AIOS, which provides web service, ftp service, and service over the Internet. The AIOS waits for requests for service over the Internet. When a service request arrives, it can be one of three types, WEB, FTP, or . Each type of request uses a different amount of work-time (the time spent running in the server). A WEB service takes a random amount of time between 3 to 5 minutes to complete; an FTP service takes a random amount of time between 5 to 10 minutes to complete; while an service takes a random amount of time between 4 to 7 minutes to complete. The time between the start of requests is called the inter-arrival time. The inter-arrival times between the WEB, FTP and traffic are random values of 0 to 10 minutes. The FTP and do not generate other consecutive requests when they finish service. The WEB service, however, will generate a new WEB service request with a probability of 30%, a new FTP service request with a probability of 20%, and a new service request with a probability of 15%. Note that a second-round WEB service will not generate any further requests. You will need to make these two types of WEB events as different ones. The first type may generate further service request, let s call it WEB. The second type doesn t, let s call it WEB2. 1

2 The AIOS server can only service one request at a time. If the server is servicing a request while another request arrives, the newly arrived request has to be put into a waiting queue. When finishing serving a request, if any requests are waiting in the queue to be serviced, the web server takes the first one off the queue and continues to serve the requests. If the waiting queue is empty, the web server will be set idle. 4.1 Discrete Event Driven Simulation Discrete event driven simulation is based on the sequence of events that take place in the system. The basic idea is that the simulation maintains an event list that keeps the events in the order of their event time, the time the event is supposed to take place. The simulation proceeds by taking the event off the event list in order and processing it. When processing an event, a new event might be generated and inserted into the event list, depending on the type of the event being processed. The event list is typically implemented as a priority queue where the nodes in the list in the queue are ordered by event time. A simulation program can be initialized in different ways. In this project, we take the approach we discussed in the class. A sequence of initial events are first generated and placed in the event list. This sequence of events may include three types of events, WEB, FTP and . What you can do is first generate a sequence of initial WEB events, then a sequence of initial FTP events, followed by a sequence of events. Once these initial events are generated, the simulation starts the processing of these events until the simulation time is exhausted. While processing events, new events may be generated. The new events could be more of the request, e.g. a WEB-COMPLETE event may generate more FTP request; or the new events could be of the type completing a request, e.g. WEB-COMPLETE, FTP-COMPLETE, and -COMPLETE. If the current event is WEB2-COMPLETE, FTP- COMPLETE or -COMPLETE, no new events will be generated. The main simulation loop will look (approximately) as follows. generate 5,000 initial events (requests) and insert these events into the event list; while (the event list is not empty) { retrieve the first event from the event list; set the simulation time to be the event time; remove the first event from the event list; switch event type case WEB : processwebevent; case WEB2: processweb2event; case FTP : processftpevent; case process event; case WEB_CMPL: processwebcomplete; case WEB2_CMPL: processweb2complete; case FTP_CMPL: processftpcomplete; case _CMPL: process complete; end switch end while } 2

3 When processing a new request event, the program checks to see if the server is busy. If the server is not busy, the newly arrived request will receive service right away. Schedule a completion event for this request on the event queue to happen when this event will actually finish. Note when inserting the completing event into the event list, there could be many requesting events that are already scheduled to take place on this list. So the newly generated departure event would have to find a proper place to insert in the event list so that the list is ordered strictly by the time of event happening. If a completing event and a requesting event are scheduled to take place at the same time (e.g. both a WEB-COMPLETE event and an FTP request event take place at time 55), put the completing event before the requesting event. When processing a completing event, the simulation does several things. First, it calculates the time this event spent in the waiting queue. (You know initial request time and current time. A little math gives you the waiting time). Any other packet statistics you need can also be calculated now. Second, it finds the current length of the waiting queue. Third, the program then checks if any requests are in the waiting queue. If any, the front event should be removed from the waiting queue, receive service, and the simulation should schedule an event accordingly. The code to run your simulation must be in a class named WebServer. Your main method may not contain more than the following public static void main(string[] args) { WebServer s = new WebServer(); s.generateevents(); s.runserver(); s.printstats(); } You do not have to name your methods as I show here. Your WebServer constructor may generate the events if you want. You may not begin running the server in your constructor. 4.2 The Event Class As seen from previous description, there are a number of types of events in this simulation. These events have some common features. They all have event time. They have some differences as well, for example, the event type is different. Requesting events have a service time length while the completing events don t. You must create a class named Event. Then a number of different events will inherit this parent class: RequestEvent, and CompleteEvent. Within the two child classes, you must use an enum to represent different types of requests and completions. The enum can be in its own class. Why? Your event and waiting queues must be full of one type of Object...an Event Object will do the trick. By using an enum to tell WEB, FTP, etc.. events apart, you can use a switch statement. This gives you practice using inheritance, enums, and switch statements. 4.3 The EventQueue Class The whole simulation is based on the event behaviors. The event queue is a central piece of any event-driven simulation. An event queue is a priority queue sorted according to the event start times. It holds all the events that will occur as time passes. Both RequestEvents and CompleteEvents will go on this queue. You should implement the event queue as an efficient data type which has all the behaviors needed, no excess behaviors, and is fast. Explain and defend your choice in your technical specification. You must provide a Big-O analysis of the run time for all queue methods. You must write this class yourself and cannot use one of the Queue classes in the Java libraries. You must name this class EventQueue. Why? This proves you understand the queue ADT well enough to make your own. You may use code from 204 labs and lectures and readings. 4.4 The WaitingQueue Class The waiting queue holds events which have entered the system (their start time has happened) and are waiting to run. This queue behaves like a standard FIFO queue. Only RequestEvents go on this queue. 3

4 You may use code from class, lab, the readings, or the Java libraries for this class or you may write it yourself. Explain and defend your choices in your technical specification. You must provide a Big-O analysis of the run time for all queue methods. Be aware that you d better be able to say why the Java library implementation is fast if you go that route. If you write the class yourself, you must name it WaitingQueue. If you use a class provided by Java, this is not necessary. 4.5 Testing This project has many parts which must all work together. 1. You must develop a testplan for both queue classes to make certain all of the functions work correctly. If your WaitingQueue is provided by Java, the Java API documentation will suffice. See the main method of the List, Stack, and Queue labs for an example (Warning: I do not promise these are tests of the full class. However, they do test the newly added features). 2. You must develop a testplan for the initial request creation generated by WEB events. This plan must show that the correct number of initial tests is actually generated and that WEB, FTP, and s each make up a third of those requests. You should also check on the inter-arrival times and the length of each request type. (Min, max, and average of each of these should give you sufficient information.) 3. You must develop a testplan for the secondary requests generated by completed WEB events. For the secondary requests, you must test that a reasonable number of secondary requests are produced and that the number of each type matches the percentages given above. 4. You must develop a testplan to show that the overall running of the server goes as plans. This might be simplest to show by printing the queue contents repeatedly as the server runs on a very small number of requests. 5. Lastly, you must have a testplan to make sure the simulator is indeed run on 5000 events plus an extra secondary events. Carefully explain all testplans and show the actual results. See the CSCI 203 testplan guide for help. Remember that a good test plan could be carried out by a third party who is not looking at your code. They check off the items in your test plan one by one to make sure the project works. Here are good and bad examples of items in a test plan: 1. bad: useless Test that the event queue works. 2. bad: inspecific Stuff gets added to the event queue. 3. good items added to the event queue appear in sorted order by the arrival time. For normal events, this is the start time. For completion events, this is the completion time. Example: Event Queue Type WEBC FTP WEB FTP WEB FTP Time Length Note that the items are all sorted by time. 4. good Items come off the front (left) end of the event queue. Example: before Event Queue and after Event Queue Type WEBC FTP WEB FTP WEB FTP Time Length Type WEBC FTP WEB FTP WEB FTP Time Length

5 4.6 Running the Simulator You will run your simulator on 5000 requests. (And the WEB requests may generate additional requests). To see the efficiency of the server on the 5000 requests, print out the average waiting time (average time a request spent in the waiting queue) and the minimum and maximum waiting times (the shortest and longest waits had). You must have the option to print out the contents of the queues each round and the option not to. This can be as simple as a parameter to the WebServer constructor. The easier this is on the user, the better the design. You will need to print out information on how many of each event was initially generated and how many were finally processed. This information could be printed in a small table at the end. You should also print out the initial size of the EventQueue and the overall number of events generated. This information could also be printed in the above mentioned table. When necessary, test runs should show both queues printing repeatedly as they run. To save sanity, it is perfectly reasonable to do the test for the EventQueue (items 1 and 2) with only a few events (perhaps 5-10). You can seperatly show that the EventQueue indeed filled with 5000 initial events by printing its size but not the actual queue. This is why your webserver needs noisy and quiet modes. 4.7 Simulator Example Here is an example of the simulator in action. Your event queue and waiting queue begin empty. Your simulation first generates a bunch of random events into the event queue. I ve shown all data for each event so you can track them. The Time is the time the request occurs. For a request event, this is the time the request comes in. For a complete event, this is the time the completion happens. The Length is the length of time the request will spend running in the server. Events which have just moved or changed are shown in boldface. Event Queue Waiting Queue Server: free Time: 0 Type Web FTP WEB FTP WEB FTP Time Length Type Time Length When the system begins to run, we serve the first event in the Event Queue. It will complete at current time + work time (2+4=6). Type WebC FTP WEB FTP WEB FTP Event Queue Time Length Waiting Queue Type Time Length Server: Event Web, time 2, length 4 Time: 2 Next time flies and we get the WEBC event. Lets say it generates a new WEB event occurring at time 9 with length 6. Type WEB2 FTP WEB FTP WEB FTP Event Queue Time Length

6 Waiting Queue Server: free Time: 6 Type Time Length Then we get the event. The current time is 6 so it will end at 10. Type WEB2 FTP C WEB FTP WEB FTP Event Queue Time Length Waiting Queue Type Time Length Server: Event , time 6, length 4 Time: 6 Then we get the WEB2 event but the server is currently busy and it must go on the waiting queue. Type FTP C WEB FTP WEB FTP Event Queue Time Length Type Web2 Waiting Queue Time 9 Length 6 Server: Event , time 6, length 4 Time: 9 Then the FTP event and the server is still busy. Type C WEB FTP WEB FTP Event Queue Time Length Type Web2 FTP Waiting Queue Time 9 9 Length 6 8 Server: Event , time 6, length 4 Time: 9 Then we get the C event and the server becomes free. It s time 10. This event was suposed to occur at 6 and take 4 minutes. How long did it have to wait? We immediately let the first waiting event get served and the server becomes busy again. Type WEB WEB2C FTP WEB FTP Event Queue Time Length Type FTP Waiting Queue Time 9 Length 8 Server: Event WEB2, time 9, length 6 6

7 Time: 10 The simulation continues on from here. It will end when all queues are empty and the server is free. 5 What To Hand In You will need to produce Javadoc for this assignment. As always you need appropriate comments. You must use Eclipse and Subversion for this project. 5.1 Phase 0 - The day it is assigned For this project, you will work alone. Why? To show me that what you learned this term. Your project should go in your labs folder on the Subversion server. 5.2 Phase 1 Due Project Description CRC and UML Technical specification in Javadoc Testplans Do not wait for my input before beginning the next phase. 5.3 Phase 2 Due The WebServer, Event and EventQueue classes as well as all the children of the Event and the enum for event types. All things must be appropriately commented using Javadoc comments and internal comments. I plan to grade the Event, Event kids, enum, and EventQueue classes now and not have to look at them again. All EventQueue methods must have a Big-O analysis in their Javadoc comment. Copy testruns into a file. These test runs must match your test plan for the EventQueue (item 1) and for filling the EventQueue (item 2) with the initial 5000 items. I expect that your EventQueue can fill with appropriate events and your test runs show that the original event generation and event queue usage are all working. The WebServer must fill the EventQueue with events but processing can be limited to simply removing the events one by one. Your code should follow the Style Guide posted on the CSCI 204 web site Do not wait for my input before beginning the next phase. 7

8 5.4 Phase 3 Your code should follow the Style Guide posted on the CSCI 204 web site Due User manual Technical specification in Javadoc Testplans Completed code. This includes comments and Big-O analysis. Copy testruns into a file. These test runs must match your entire test plan and include all items in the testing section above. (Note: item 1 must be done for both the EventQueue and the WaitingQueue). Clearly seperate each test case from the next one. Also include the output mentioned in the section on running the simulator. 8

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class CS112 Lecture: Defining Classes Last revised 2/3/06 Objectives: 1. To describe the process of defining an instantiable class Materials: 1. BlueJ SavingsAccount example project 2. Handout of code for SavingsAccount

More information

CSE332: Data Abstractions Lecture 4: Priority Queues; Heaps. James Fogarty Winter 2012

CSE332: Data Abstractions Lecture 4: Priority Queues; Heaps. James Fogarty Winter 2012 CSE332: Data Abstractions Lecture 4: Priority Queues; Heaps James Fogarty Winter 2012 Administrative Eclipse Resources HW 1 Due Friday Discussion board post regarding HW 1 Problem 2 Project 1A Milestone

More information

Problem 1: Building and testing your own linked indexed list

Problem 1: Building and testing your own linked indexed list CSCI 200 Lab 8 Implementing a Linked Indexed List In this lab, you will be constructing a linked indexed list. You ll then use your list to build and test a new linked queue implementation. Objectives:

More information

(Refer Slide Time: 01.26)

(Refer Slide Time: 01.26) Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture # 22 Why Sorting? Today we are going to be looking at sorting.

More information

Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi

Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 20 Priority Queues Today we are going to look at the priority

More information

CSC148H Week 3. Sadia Sharmin. May 24, /20

CSC148H Week 3. Sadia Sharmin. May 24, /20 CSC148H Week 3 Sadia Sharmin May 24, 2017 1/20 Client vs. Developer I For the first couple of weeks, we have played the role of class designer I However, you are also often in the opposite role: when a

More information

CS112 Lecture: Defining Instantiable Classes

CS112 Lecture: Defining Instantiable Classes CS112 Lecture: Defining Instantiable Classes Last revised 2/3/05 Objectives: 1. To describe the process of defining an instantiable class 2. To discuss public and private visibility modifiers. Materials:

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 80 points Due Date: Friday, February 2, 11:59 pm (midnight) Late deadline (25% penalty): Monday, February 5, 11:59 pm General information This assignment is to be done

More information

CSE 2123: Collections: Priority Queues. Jeremy Morris

CSE 2123: Collections: Priority Queues. Jeremy Morris CSE 2123: Collections: Priority Queues Jeremy Morris 1 Collections Priority Queue Recall: A queue is a specific type of collection Keeps elements in a particular order We ve seen two examples FIFO queues

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

Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi.

Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi. Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 18 Tries Today we are going to be talking about another data

More information

Priority Queues and Binary Heaps

Priority Queues and Binary Heaps Yufei Tao ITEE University of Queensland In this lecture, we will learn our first tree data structure called the binary heap which serves as an implementation of the priority queue. Priority Queue A priority

More information

Binary Trees Due Sunday March 16, 2014

Binary Trees Due Sunday March 16, 2014 Problem Description Binary Trees Due Sunday March 16, 2014 Recall that a binary tree is complete if all levels in the tree are full 1 except possibly the last level which is filled in from left to right.

More information

CSIS 10B Lab 2 Bags and Stacks

CSIS 10B Lab 2 Bags and Stacks CSIS 10B Lab 2 Bags and Stacks Part A Bags and Inheritance In this part of the lab we will be exploring the use of the Bag ADT to manage quantities of data of a certain generic type (listed as T in the

More information

CSE 332: Data Structures & Parallelism Lecture 3: Priority Queues. Ruth Anderson Winter 2019

CSE 332: Data Structures & Parallelism Lecture 3: Priority Queues. Ruth Anderson Winter 2019 CSE 332: Data Structures & Parallelism Lecture 3: Priority Queues Ruth Anderson Winter 201 Today Finish up Intro to Asymptotic Analysis New ADT! Priority Queues 1/11/201 2 Scenario What is the difference

More information

The smallest element is the first one removed. (You could also define a largest-first-out priority queue)

The smallest element is the first one removed. (You could also define a largest-first-out priority queue) Priority Queues Priority queue A stack is first in, last out A queue is first in, first out A priority queue is least-first-out The smallest element is the first one removed (You could also define a largest-first-out

More information

Binary heaps (chapters ) Leftist heaps

Binary heaps (chapters ) Leftist heaps Binary heaps (chapters 20.3 20.5) Leftist heaps Binary heaps are arrays! A binary heap is really implemented using an array! 8 18 29 20 28 39 66 Possible because of completeness property 37 26 76 32 74

More information

CSCI 200 Lab 11 A Heap-Based Priority Queue

CSCI 200 Lab 11 A Heap-Based Priority Queue CSCI 200 Lab 11 A Heap-Based Priority Queue Preliminaries Part of today s lab will focus on implementing a heap-based priority queue using an ArrayListlike class called ZHExtensibleArrayStructure. Recall

More information

1.00 Lecture 7. Classes

1.00 Lecture 7. Classes 1.00 Lecture 7 Java Classes and Objects Reading for next time: Big Java: sections 2.6-2.11 Classes A class is a pattern or template from which objects are made You may have many birds in a simulation One

More information

Agenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java

Agenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors Agenda

More information

CPS221 Lecture: Threads

CPS221 Lecture: Threads Objectives CPS221 Lecture: Threads 1. To introduce threads in the context of processes 2. To introduce UML Activity Diagrams last revised 9/5/12 Materials: 1. Diagram showing state of memory for a process

More information

lecture notes September 2, How to sort?

lecture notes September 2, How to sort? .30 lecture notes September 2, 203 How to sort? Lecturer: Michel Goemans The task of sorting. Setup Suppose we have n objects that we need to sort according to some ordering. These could be integers or

More information

CS121/IS223. Object Reference Variables. Dr Olly Gotel

CS121/IS223. Object Reference Variables. Dr Olly Gotel CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors CS121/IS223

More information

Readings. Priority Queue ADT. FindMin Problem. Priority Queues & Binary Heaps. List implementation of a Priority Queue

Readings. Priority Queue ADT. FindMin Problem. Priority Queues & Binary Heaps. List implementation of a Priority Queue Readings Priority Queues & Binary Heaps Chapter Section.-. CSE Data Structures Winter 00 Binary Heaps FindMin Problem Quickly find the smallest (or highest priority) item in a set Applications: Operating

More information

Write for your audience

Write for your audience Comments Write for your audience Program documentation is for programmers, not end users There are two groups of programmers, and they need different kinds of documentation Some programmers need to use

More information

Virtual Memory. ICS332 Operating Systems

Virtual Memory. ICS332 Operating Systems Virtual Memory ICS332 Operating Systems Virtual Memory Allow a process to execute while not completely in memory Part of the address space is kept on disk So far, we have assumed that the full address

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

Course: Honors AP Computer Science Instructor: Mr. Jason A. Townsend

Course: Honors AP Computer Science Instructor: Mr. Jason A. Townsend Course: Honors AP Computer Science Instructor: Mr. Jason A. Townsend Email: jtownsend@pkwy.k12.mo.us Course Description: The material for this course is the equivalent of one to two semesters of an entry

More information

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently. Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently. User Request: Create a simple magazine data system. Milestones:

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 21

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 21 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2018 Lecture 21 LAST TIME: UNIX PROCESS MODEL Began to explore the implementation of the UNIX process model The user API is very simple: fork() creates a

More information

CSCI 136 Data Structures & Advanced Programming. Lecture 22 Fall 2018 Instructor: Bills

CSCI 136 Data Structures & Advanced Programming. Lecture 22 Fall 2018 Instructor: Bills CSCI 136 Data Structures & Advanced Programming Lecture 22 Fall 2018 Instructor: Bills Last Time Lab 7: Two Towers Array Representations of (Binary) Trees Application: Huffman Encoding 2 Today Improving

More information

Summer Final Exam Review Session August 5, 2009

Summer Final Exam Review Session August 5, 2009 15-111 Summer 2 2009 Final Exam Review Session August 5, 2009 Exam Notes The exam is from 10:30 to 1:30 PM in Wean Hall 5419A. The exam will be primarily conceptual. The major emphasis is on understanding

More information

CS103 Handout 29 Winter 2018 February 9, 2018 Inductive Proofwriting Checklist

CS103 Handout 29 Winter 2018 February 9, 2018 Inductive Proofwriting Checklist CS103 Handout 29 Winter 2018 February 9, 2018 Inductive Proofwriting Checklist In Handout 28, the Guide to Inductive Proofs, we outlined a number of specifc issues and concepts to be mindful about when

More information

CSC207 Week 3. Larry Zhang

CSC207 Week 3. Larry Zhang CSC207 Week 3 Larry Zhang 1 Announcements Readings will be posted before the lecture Lab 1 marks available in your repo 1 point for creating the correct project. 1 point for creating the correct classes.

More information

Principles of Autonomy and Decision Making

Principles of Autonomy and Decision Making Massachusetts Institute of Technology 16.410-13 Principles of Autonomy and Decision Making Problem Set #2 Objective You will implement in Java the following search algorithms: 1. Depth-first 2. Breadth-first.

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

Classes, interfaces, & documentation. Review of basic building blocks

Classes, interfaces, & documentation. Review of basic building blocks Classes, interfaces, & documentation Review of basic building blocks Objects Data structures literally, storage containers for data constitute object knowledge or state Operations an object can perform

More information

(Refer Slide Time: 02.06)

(Refer Slide Time: 02.06) Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 27 Depth First Search (DFS) Today we are going to be talking

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: 2 Date:

More information

Lecture 11 Unbounded Arrays

Lecture 11 Unbounded Arrays Lecture 11 Unbounded Arrays 15-122: Principles of Imperative Computation (Spring 2018) Rob Simmons, Frank Pfenning Arrays have efficient O(1) access to elements given an index, but their size is set at

More information

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. CMSC 131: Chapter 28 Final Review: What you learned this semester The Big Picture Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. Java

More information

Binary Heaps. COL 106 Shweta Agrawal and Amit Kumar

Binary Heaps. COL 106 Shweta Agrawal and Amit Kumar Binary Heaps COL Shweta Agrawal and Amit Kumar Revisiting FindMin Application: Find the smallest ( or highest priority) item quickly Operating system needs to schedule jobs according to priority instead

More information

COMP 110/L Lecture 19. Kyle Dewey

COMP 110/L Lecture 19. Kyle Dewey COMP 110/L Lecture 19 Kyle Dewey Outline Inheritance extends super Method overriding Automatically-generated constructors Inheritance Recap -We talked about object-oriented programming being about objects

More information

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit. Com S 227 Fall 2018 Miniassignment 1 40 points Due Date: Friday, October 12, 11:59 pm (midnight) Late deadline (25% penalty): Monday, October 15, 11:59 pm General information This assignment is to be done

More information

CMPSCI 187: Programming With Data Structures. Review for Final Exam David Mix Barrington 10 December 2012

CMPSCI 187: Programming With Data Structures. Review for Final Exam David Mix Barrington 10 December 2012 CMPSCI 187: Programming With Data Structures Review for Final Exam David Mix Barrington 10 December 2012 Exam Overview Thursday 13 December, 1:30-3:30 p.m., Marcus 131 Format is the same as the Fall 2011

More information

CSCI-1200 Data Structures Spring 2016 Lecture 22 Priority Queues, part II (& Functors)

CSCI-1200 Data Structures Spring 2016 Lecture 22 Priority Queues, part II (& Functors) CSCI-1200 Data Structures Spring 2016 Lecture 22 Priority Queues, part II (& Functors) Review from Lecture 21 What s a Priority Queue? Definition of a Binary Heap: A binary tree where: The value at each

More information

Compuer Science 62 Assignment 10

Compuer Science 62 Assignment 10 Compuer Science 62 Assignment 10 Due 11:59pm on Thursday, April 22, 2010 This assignment is the C++ version of the animal game. The program will have three parts, which have been carefully specified. You

More information

And Even More and More C++ Fundamentals of Computer Science

And Even More and More C++ Fundamentals of Computer Science And Even More and More C++ Fundamentals of Computer Science Outline C++ Classes Friendship Inheritance Multiple Inheritance Polymorphism Virtual Members Abstract Base Classes File Input/Output Friendship

More information

Computer Programming II Python

Computer Programming II Python EXAM INFORMATION Items 32 Points 33 Prerequisites SECONDARY MATH I COMPUTER PROGRAMMING I Grade Level 10-12 Course Length ONE YEAR DESCRIPTION This is an advanced course in computer programming/software

More information

Advanced Database Systems

Advanced Database Systems Lecture IV Query Processing Kyumars Sheykh Esmaili Basic Steps in Query Processing 2 Query Optimization Many equivalent execution plans Choosing the best one Based on Heuristics, Cost Will be discussed

More information

Implement an ADT while using Subversion

Implement an ADT while using Subversion 1 Objectives Learn to use Subversion Implement an ADT while using Subversion In this lab, you learn about the version control tool called Subversion and you will implement a Java class given an interface.

More information

Stacks and Queues

Stacks and Queues Stacks and Queues 2-25-2009 1 Opening Discussion Let's look at solutions to the interclass problem. Do you have any questions about the reading? Do you have any questions about the assignment? Minute Essays

More information

Computer Science 385 Design and Analysis of Algorithms Siena College Spring Lab 8: Greedy Algorithms Due: Start of your next lab session

Computer Science 385 Design and Analysis of Algorithms Siena College Spring Lab 8: Greedy Algorithms Due: Start of your next lab session Computer Science 385 Design and Analysis of Algorithms Siena College Spring 2017 Lab 8: Greedy Algorithms Due: Start of your next lab session You will be assigned groups of size 2 or 3 for this lab. Only

More information

COMP251: Algorithms and Data Structures. Jérôme Waldispühl School of Computer Science McGill University

COMP251: Algorithms and Data Structures. Jérôme Waldispühl School of Computer Science McGill University COMP251: Algorithms and Data Structures Jérôme Waldispühl School of Computer Science McGill University About Me Jérôme Waldispühl Associate Professor of Computer Science I am conducting research in Bioinformatics

More information

Some Extra Information on Graph Search

Some Extra Information on Graph Search Some Extra Information on Graph Search David Kempe December 5, 203 We have given basic definitions of graphs earlier in class, and talked about how to implement them. We had also already mentioned paths,

More information

Learning Goals. CS221: Algorithms and Data Structures Lecture #3 Mind Your Priority Queues. Today s Outline. Back to Queues. Priority Queue ADT

Learning Goals. CS221: Algorithms and Data Structures Lecture #3 Mind Your Priority Queues. Today s Outline. Back to Queues. Priority Queue ADT CS: Algorithms and Data Structures Lecture # Mind Your Priority Queues Steve Wolfman 0W Learning Goals Provide examples of appropriate applications for priority queues. Describe efficient implementations

More information

Priority Queues. Lecture15: Heaps. Priority Queue ADT. Sequence based Priority Queue

Priority Queues. Lecture15: Heaps. Priority Queue ADT. Sequence based Priority Queue Priority Queues (0F) Lecture: Heaps Bohyung Han CSE, POSTECH bhhan@postech.ac.kr Queues Stores items (keys) in a linear list or array FIFO (First In First Out) Stored items do not have priorities. Priority

More information

Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore

Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore Lecture 04 Software Test Automation: JUnit as an example

More information

CSCI-1200 Data Structures Fall 2018 Lecture 23 Priority Queues II

CSCI-1200 Data Structures Fall 2018 Lecture 23 Priority Queues II Review from Lecture 22 CSCI-1200 Data Structures Fall 2018 Lecture 23 Priority Queues II Using STL s for_each, Function Objects, a.k.a., Functors STL s unordered_set (and unordered_map) Hash functions

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 2017 Assignment 1 80 points Due Date: Thursday, February 2, 11:59 pm (midnight) Late deadline (25% penalty): Friday, February 3, 11:59 pm General information This assignment is to be done

More information

Massachusetts Institute of Technology Dept. of Electrical Engineering and Computer Science Fall Semester, Introduction to EECS 2

Massachusetts Institute of Technology Dept. of Electrical Engineering and Computer Science Fall Semester, Introduction to EECS 2 Massachusetts Institute of Technology Dept. of Electrical Engineering and Computer Science Fall Semester, 2006 6.082 Introduction to EECS 2 Lab #9: Link-state Routing Goal: Using a network simulator written

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

Computer Systems Assignment 4: Scheduling and I/O

Computer Systems Assignment 4: Scheduling and I/O Autumn Term 018 Distributed Computing Computer Systems Assignment : Scheduling and I/O Assigned on: October 19, 018 1 Scheduling The following table describes tasks to be scheduled. The table contains

More information

Queuing Systems. 1 Lecturer: Hawraa Sh. Modeling & Simulation- Lecture -4-21/10/2012

Queuing Systems. 1 Lecturer: Hawraa Sh. Modeling & Simulation- Lecture -4-21/10/2012 Queuing Systems Queuing theory establishes a powerful tool in modeling and performance analysis of many complex systems, such as computer networks, telecommunication systems, call centers, manufacturing

More information

13 th Windsor Regional Secondary School Computer Programming Competition

13 th Windsor Regional Secondary School Computer Programming Competition SCHOOL OF COMPUTER SCIENCE 13 th Windsor Regional Secondary School Computer Programming Competition Hosted by The School of Computer Science, University of Windsor WORKSHOP I [ Overview of the Java/Eclipse

More information

Operating Systems Comprehensive Exam. Fall Student ID # 10/31/2013

Operating Systems Comprehensive Exam. Fall Student ID # 10/31/2013 Operating Systems Comprehensive Exam Fall 2013 Student ID # 10/31/2013 You must complete all of Section I You must complete two of the problems in Section II If you need more space to answer a question,

More information

Chapter 6 Heaps. Introduction. Heap Model. Heap Implementation

Chapter 6 Heaps. Introduction. Heap Model. Heap Implementation Introduction Chapter 6 Heaps some systems applications require that items be processed in specialized ways printing may not be best to place on a queue some jobs may be more small 1-page jobs should be

More information

HEAPS & PRIORITY QUEUES

HEAPS & PRIORITY QUEUES HEAPS & PRIORITY QUEUES Lecture 13 CS2110 Spring 2018 Announcements 2 A4 goes out today! Prelim 1: regrades are open a few rubrics have changed No Recitations next week (Fall Break Mon & Tue) We ll spend

More information

CSE030 Fall 2012 Final Exam Friday, December 14, PM

CSE030 Fall 2012 Final Exam Friday, December 14, PM CSE030 Fall 2012 Final Exam Friday, December 14, 2012 3-6PM Write your name here and at the top of each page! Name: Select your lab session: Tuesdays Thursdays Paper. If you have any questions or need

More information

Software Design Models, Tools & Processes. Lecture 6: Transition Phase Cecilia Mascolo

Software Design Models, Tools & Processes. Lecture 6: Transition Phase Cecilia Mascolo Software Design Models, Tools & Processes Lecture 6: Transition Phase Cecilia Mascolo UML Component diagram Component documentation Your own classes should be documented the same way library classes are.

More information

COSC243 Part 2: Operating Systems

COSC243 Part 2: Operating Systems COSC243 Part 2: Operating Systems Lecture 16: Threads and data sharing Zhiyi Huang Dept. of Computer Science, University of Otago Zhiyi Huang (Otago) COSC243 Lecture 16 1 / 24 Overview Last lecture: Hierarchical

More information

Midterm Exam Solutions Amy Murphy 28 February 2001

Midterm Exam Solutions Amy Murphy 28 February 2001 University of Rochester Midterm Exam Solutions Amy Murphy 8 February 00 Computer Systems (CSC/56) Read before beginning: Please write clearly. Illegible answers cannot be graded. Be sure to identify all

More information

CS4450. Computer Networks: Architecture and Protocols. Lecture 11 Rou+ng: Deep Dive. Spring 2018 Rachit Agarwal

CS4450. Computer Networks: Architecture and Protocols. Lecture 11 Rou+ng: Deep Dive. Spring 2018 Rachit Agarwal CS4450 Computer Networks: Architecture and Protocols Lecture 11 Rou+ng: Deep Dive Spring 2018 Rachit Agarwal 2 Goals for Today s Lecture Learning about Routing Protocols Link State (Global view) Distance

More information

Binary Heaps. CSE 373 Data Structures Lecture 11

Binary Heaps. CSE 373 Data Structures Lecture 11 Binary Heaps CSE Data Structures Lecture Readings and References Reading Sections.1-. //0 Binary Heaps - Lecture A New Problem Application: Find the smallest ( or highest priority) item quickly Operating

More information

CmpSci 187: Programming with Data Structures Spring 2015

CmpSci 187: Programming with Data Structures Spring 2015 CmpSci 187: Programming with Data Structures Spring 2015 Lecture #13, Concurrency, Interference, and Synchronization John Ridgway March 12, 2015 Concurrency and Threads Computers are capable of doing more

More information

Lesson 10B Class Design. By John B. Owen All rights reserved 2011, revised 2014

Lesson 10B Class Design. By John B. Owen All rights reserved 2011, revised 2014 Lesson 10B Class Design By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Encapsulation Inheritance and Composition is a vs has a Polymorphism Information Hiding Public

More information

Spring, 2014 CIT 590. Programming Languages and Techniques Homework 7

Spring, 2014 CIT 590. Programming Languages and Techniques Homework 7 Spring, 2014 CIT 590 Programming Languages and Techniques Homework 7 Mar 21, 2014; Due Mar 28, 2014, before first recitation This homework deals with the following topics * Getting started with Java *

More information

Program development plan

Program development plan Appendix A Program development plan If you are spending a lot of time debugging, it is probably because you do not have an effective program development plan. A typical, bad program development plan goes

More information

OOP- 5 Stacks Individual Assignment 35 Points

OOP- 5 Stacks Individual Assignment 35 Points OOP-5-Stacks-HW.docx CSCI 2320 Initials P a g e 1 If this lab is an Individual assignment, you must do all coded programs on your own. You may ask others for help on the language syntax, but you must organize

More information

BAD BAD BAD! This doesn t work! REVIEW: define the animal class. CS61A Lecture 15. dogs inherit from animals (& can call parent methods) Inheritance

BAD BAD BAD! This doesn t work! REVIEW: define the animal class. CS61A Lecture 15. dogs inherit from animals (& can call parent methods) Inheritance CS61A Lecture 15 2011-07-14 Colleen Lewis REVIEW: define the animal class STk> (define animal1 (instantiate animal 'fred)) animal1 STk> (ask animal1 'age) 0 STk> (ask animal1 'eat) yum STk> (ask animal1

More information

CS355 Hw 4. Interface. Due by the end of day Tuesday, March 20.

CS355 Hw 4. Interface. Due by the end of day Tuesday, March 20. Due by the end of day Tuesday, March 20. CS355 Hw 4 User-level Threads You will write a library to support multiple threads within a single Linux process. This is a user-level thread library because the

More information

Lecture 21: Red-Black Trees

Lecture 21: Red-Black Trees 15-150 Lecture 21: Red-Black Trees Lecture by Dan Licata April 3, 2012 Last time, we talked about the signature for dictionaries: signature ORDERED = sig type t val compare : t * t -> order signature DICT

More information

Processes, PCB, Context Switch

Processes, PCB, Context Switch THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering EIE 272 CAOS Operating Systems Part II Processes, PCB, Context Switch Instructor Dr. M. Sakalli enmsaka@eie.polyu.edu.hk

More information

Programming Assignment #3 Event Driven Simulation

Programming Assignment #3 Event Driven Simulation CS-2303, System Programming Concepts, A-term 2012 Project 3 (45 points) Assigned: Friday, September 7, 2012 Due: Friday, September 14, 2012, 11:59 PM Abstract Programming Assignment #3 Event Driven Simulation

More information

Introduction to Algorithms November 17, 2011 Massachusetts Institute of Technology Fall 2011 Professors Erik Demaine and Srini Devadas Quiz 2

Introduction to Algorithms November 17, 2011 Massachusetts Institute of Technology Fall 2011 Professors Erik Demaine and Srini Devadas Quiz 2 Introduction to Algorithms November 17, 2011 Massachusetts Institute of Technology 6.006 Fall 2011 Professors Erik Demaine and Srini Devadas Quiz 2 Quiz 2 Do not open this quiz booklet until directed to

More information

OOP-8-DLList-1-HW.docx CSCI 2320 Initials Page 1

OOP-8-DLList-1-HW.docx CSCI 2320 Initials Page 1 OOP-8-DLList-1-HW.docx CSCI 2320 Initials Page 1 If this lab is an Individual assignment, you must do all coded programs on your own. You may ask others for help on the language syntax, but you must organize

More information

the gamedesigninitiative at cornell university Lecture 12 Architecture Design

the gamedesigninitiative at cornell university Lecture 12 Architecture Design Lecture 12 Take Away for Today What should lead programmer do? How do CRC cards aid software design? What goes on each card? How do you lay m out? What properties should y have? How do activity diagrams

More information

Print out this PDF double-sided, staple pages in order, and write your answers on these pages neatly.

Print out this PDF double-sided, staple pages in order, and write your answers on these pages neatly. 15-122 : Principles of Imperative Computation, Fall 2015 Written Homework 5 Due: Monday, October 5, 2015 by 6PM Name: Andrew ID: Section: This written homework covers big-o notation, some reasoning about

More information

CS112 Lecture: Extending Classes and Defining Methods

CS112 Lecture: Extending Classes and Defining Methods Objectives: CS112 Lecture: Extending Classes and Defining Methods Last revised 1/9/04 1. To introduce the idea of extending existing classes to add new methods 2. To introduce overriding of inherited methods

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

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment

More information

Lecture 5: Performance Analysis I

Lecture 5: Performance Analysis I CS 6323 : Modeling and Inference Lecture 5: Performance Analysis I Prof. Gregory Provan Department of Computer Science University College Cork Slides: Based on M. Yin (Performability Analysis) Overview

More information

Principles of Algorithm Design

Principles of Algorithm Design Principles of Algorithm Design When you are trying to design an algorithm or a data structure, it s often hard to see how to accomplish the task. The following techniques can often be useful: 1. Experiment

More information

CSCI 204 Introduction to Computer Science II. Lab 6: Stack ADT

CSCI 204 Introduction to Computer Science II. Lab 6: Stack ADT CSCI 204 Introduction to Computer Science II 1. Objectives In this lab, you will practice the following: Learn about the Stack ADT Implement the Stack ADT using an array Lab 6: Stack ADT Use a Stack to

More information

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 1: Overview http://courses.cs.cornell.edu/cs2110 1 Course Staff Instructor Thorsten Joachims (tj@cs.cornell.edu)

More information

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5.

6.170 Laboratory in Software Engineering Java Style Guide. Overview. Descriptive names. Consistent indentation and spacing. Page 1 of 5. Page 1 of 5 6.170 Laboratory in Software Engineering Java Style Guide Contents: Overview Descriptive names Consistent indentation and spacing Informative comments Commenting code TODO comments 6.170 Javadocs

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

Introduction to Algorithms: Massachusetts Institute of Technology 7 October, 2011 Professors Erik Demaine and Srini Devadas Problem Set 4

Introduction to Algorithms: Massachusetts Institute of Technology 7 October, 2011 Professors Erik Demaine and Srini Devadas Problem Set 4 Introduction to Algorithms: 6.006 Massachusetts Institute of Technology 7 October, 2011 Professors Erik Demaine and Srini Devadas Problem Set 4 Problem Set 4 Both theory and programming questions are due

More information

Computer Programming II C++ (830)

Computer Programming II C++ (830) DESCRIPTION This is an advanced course in computer programming/software engineering and applications. It reviews and builds on the concepts introduced in CP I. It introduces students to dynamic data structures,

More information

Unit #2: Priority Queues

Unit #2: Priority Queues Unit #2: Priority Queues CPSC 221: Algorithms and Data Structures Will Evans 201W1 Unit Outline Rooted Trees, Briefly Priority Queue ADT Heaps Implementing Priority Queue ADT Focus on Create: Heapify Brief

More information