CS2102, D15 Exam 1. Name:

Similar documents
CS2102, B11 Exam 1. Name:

CS2102, B11 Exam 2. Name:

CS 2102 Exam 2 D-Term 2017

CS 216 Exam 1 Fall SOLUTION

CS2013 Course Syllabus Spring 2018 Lecture: Mon/Wed 2:00 P.M. 2:50 P.M. SH C259 Lab: Mon/Wed 2:50 P.M. 4:00 P.M. SH C259

CSE 333 Midterm Exam 2/14/14

Prelim 2, CS2110. SOLUTION

CS3360 Design and Implementation of Programming Languages Final Exam May 16, pm to 12:45pm (2 hour and 40 minutes) NAME:

CS2013 Course Syllabus Spring 2017 Lecture: Friday 8:00 A.M. 9:40 A.M. Lab: Friday 9:40 A.M. 12:00 Noon

Prelim 2 SOLUTION. 5:30 PM, 25 April Total Question Name Short Search/ Collections Trees Graphs

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid. Fall 2018

CS2102, B15 Exam 2. Name:

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

Arrays: Higher Dimensional Arrays. CS0007: Introduction to Computer Programming

CS 61B, Summer 2001 Midterm Exam II Professor Michael Olan

EECS168 Exam 3 Review

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

CS 3114 Data Structures and Algorithms Test 1 READ THIS NOW!

For Teacher's Use Only Q No Total Q No Q No

Introduction to Programming System Design CSCI 455x (4 Units)

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

Exam Data structures DAT036/DAT037/DIT960

Section 4 SOLUTION: AVL Trees & B-Trees

About this exam review

Lab 8: Ordered Search Results

Computer Science II Fall 2009

CS4411 Intro. to Operating Systems Exam 1 Fall points 9 pages

CSE 143 Final Exam Part 1 - August 18, 2011, 9:40 am

San José State University Computer Science Department CS49J, Section 3, Programming in Java, Fall 2015

York University AS/AK/ITEC INTRODUCTION TO DATA STRUCTURES. Midterm Sample I. Examiner: S. Chen Duration: One Hour and 30 Minutes

CGS 2405 Advanced Programming with C++ Course Justification

Second Examination Solution

* Due 11:59pm on Sunday 10/4 for Monday lab and Tuesday 10/6 Wednesday Lab

OF VICTORIA EXAMINATIONS- DECEMBER 2010 CSC

Prelim 1. Solution. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer

University of Illinois at Urbana-Champaign Department of Computer Science. Second Examination

Comp Intermediate Programming EXAM #2 April 02, 2003 Rice University - Instructors: Cox & Nguyen

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

Final Exam CS 152, Computer Programming Fundamentals May 9, 2014

Code No: R Set No. 1

CS 2102 Exam 1 D-Term 2014

CS 314 Exam 2 Spring 2018

CISC 3130 Data Structures Fall 2018

CS61BL: Data Structures & Programming Methodology Summer 2014

CS 314 Final Fall 2012

CS210 (161) with Dr. Basit Qureshi Final Exam Weight 40%

CS 374 Fall 2014 Homework 2 Due Tuesday, September 16, 2014 at noon

COMP 250 Midterm #2 March 11 th 2013

Spring 2003 Instructor: Dr. Shahadat Hossain. Administrative Matters Course Information Introduction to Programming Techniques

CS 450 Exam 2 Mon. 11/7/2016

Comp Intermediate Programming EXAM #2 March 30, 2005 Rice University - Instructors: Cox & Nguyen

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

Introduction to Data Structures

Week 2. CS 400 Programming III. Read: Module 2 readings before lecture

Core Competency DOO (Design Object-Oriented)

CSC2100-Data Structures

Largest Online Community of VU Students

CS 223: Data Structures and Programming Techniques. Exam 2

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

York University AK/ITEC INTRODUCTION TO DATA STRUCTURES. Final Sample II. Examiner: S. Chen Duration: Three hours

Exam Data structures DAT036/DAT037/DIT960

Computer Science Foundation Exam

CS2110 Assignment 3 Inheritance and Trees, Summer 2008

(the bubble footer is automatically inserted in this space)

- Alan Perlis. Topic 24 Heaps

CS 170 Java Programming 1. Week 12: Creating Your Own Types

(the bubble footer is automatically inserted into this space)

Computer Architecture I Midterm I

Csci 102: Sample Exam

Data Structures and Algorithms

CPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001

CS143 Final Spring 2016

Points off Total off Net Score. CS 314 Final Exam Fall 2016

Prelim 2, CS :30 PM, 25 April Total Question Name Short Search/ Collections Trees Graphs

CSE 100: C++ TEMPLATES AND ITERATORS

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

Week 2. TA Lab Consulting - See schedule (cs400 home pages) Peer Mentoring available - Friday 8am-12pm, 12:15-1:30pm in 1289CS

Prelim 2. CS 2110, April 26, 2016, 5:30 PM Total Question True/False Complexity Heaps Trees Graphs Max Score Grader

CSE 143, Winter 2009 Final Exam Thursday, March 19, 2009

Name: Pennkey: CIS 120 Midterm II November 18, 2011

Prelim 2 Solution. CS 2110, April 26, 2016, 5:30 PM

COT 6405: Analysis of Algorithms. Giri Narasimhan. ECS 389; Phone: x3748

University of Illinois at Urbana-Champaign Department of Computer Science. Second Examination

Name: Username: I. 20. Section: II. p p p III. p p p p Total 100. CMSC 202 Section 06 Fall 2015

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)

CS2102, B10 Exam 2. Problem Points Score Total. Name:

Problem Set 5 Due: Friday, November 2

DATA STRUCTURES AND ALGORITHMS. Hierarchical data structures: AVL tree, Bayer tree, Heap

Midterm Exam 2 CS 455, Spring 2015

CIS 120 Midterm II November 8, 2013 SOLUTIONS

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT)

CS 216 Fall 2007 Final Exam Page 1 of 10 Name: ID:

CSE030 Fall 2012 Final Exam Friday, December 14, PM

UW CSE 351, Winter 2013 Final Exam

BINARY SEARCH TREES CS 200 RECITATION 7

BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE. Sample Final Exam

Computer Science Foundation Exam. Dec. 19, 2003 COMPUTER SCIENCE I. Section I A. No Calculators! KEY

Project 1 Balanced binary

Transcription:

CS2102, D15 Exam 1 Name: You have 50 minutes to complete the problems on the following pages. There should be sufficient space provided for your answers. If a problem asks you to create a class hierarchy, we are looking for the interfaces, classes, and abstract classes that you would create for the problem. In particular: Include implements and extends statements Include field names and types Include method headers (names, return type, and input parameter types) Full credit requires that all types and implements/extends relationships are clear. Be sure your work is clear if you use class diagrams instead of Java syntax. You may omit constructors You may omit method bodies You may omit the Examples class (examples of data and test cases) unless a question asks otherwise 1

Grading Summary Exam starts on the next page Topic Max Points Score Q1: Data structures 36 Q2: Java programming 40 Q3: Program Design 40 (Each of these is a separate score in the corresponding course theme) (exam starts on the next page) 2

1. Topic: Data Structures (a) (18 points) Consider the following two binary trees. For each data structure listed in the table, either say yes if the tree satisfies the requirements of the data structure, or write the number that starts the smallest subtree that violates the requirements for that data structure. BST AVL Tree Heap (b) (18 points) You are building software to manage orders at a fast-food restaurants. Orders should get filled in the order that they were placed. You need to select a data structure for organizing the orders. In the first row of the following table, put a mark (x, check, etc) under each data structure that is appropriate (structurally) for managing orders. In the second row, mark the ONE data structure that you prefer for this problem. Justify your preference (and non-preferences from the appropriate structures) in a few words. Appropriate for Problem Stack Queue BST AVL tree Heap Prefer for Problem Justification: 3

2. Topic: Class Hierarchies (Classes, Abstract Classes, Interfaces) and Access Modifiers (This starts from the same code as question 3 start with the code afresh for this question, ignoring any edits you made for question 3). You are writing a course scheduling tool that helps students search for classes with open seats. Your current code is as follows: // captures hour when a course starts, how many hours it lasts, and a term. // A one hour class starting at 3pm in A-term, is new TimeSlot(3, 1, "A") class TimeSlot { int starthour; int duration; String term; // a Course in the registration system class Course { String dept; int number; TimeSlot when; int seatsleft; class Scheduler { private LinkedList<Course> catalog; private LinkedList<TimeSlot> alltimes; // return list of courses that start after given hour in given term // and that have seats available LinkedList<Course> availableafter(int hour, String interm) { LinkedList<Course> result = new LinkedList<Course>(); for (Course c : catalog) { if (c.when.starthour >= hour && c.when.term.equals(interm) && c.seatsleft() > 0) { result.addfirst(c); return result; Your current scheduler does not handle Labs. Each lab has the course it is part of, the TimeSlot in which it is offered, and the number of seats remaining in the course. (a) (30 points) Edit the class hierarchy and code to allow the catalog to contain both courses and labs. Your class hierarchy should share fields and methods where appropriate. You may add (abstract) classes and interfaces (define interfaces in full, define classes at the level of detail of TimeSlot and Course). You do not need to add any features, methods, or encapsulation just make the edit requested in this problem. Mark edits on the original code, using the space around the code and on the next page for any new classes/interfaces. 4

(space for answer to part (a)) (b) (10 points) Assume you are writing an Examples class for the Scheduler, along the following lines: class Examples { LinkedList<Course> catalog2015 = new LinkedList<Course>(); catalog2015.addfirst(new Course(...)); Scheduler S = new Scheduler(catalog2015); int spots = catalog2015.getfirst().seatsleft; i. Will the line that defines S compile without error, given the type of catalog2015 and the edits you made in part (a)? Why or why not? ii. Will the line that defines spots compile without error, given that catalog is private in the Scheduler class? Why or why not? 5

3. Topic: Encapsulation (This starts from the same code as question 2 start with the code afresh for this question, ignoring any edits you made for question 2). You are writing a course scheduling tool that helps students search for classes with open seats. Your current code is as follows: // captures hour when a course starts, how many hours it lasts, and a term. // A one hour class starting at 3pm in A-term, is new TimeSlot(3, 1, "A") class TimeSlot { int starthour; int duration; String term; // a Course in the registration system class Course { String dept; int number; TimeSlot when; int seatsleft; class Scheduler { private LinkedList<Course> catalog; private LinkedList<TimeSlot> alltimes; // return list of courses that start after given hour in given term // and that have seats available LinkedList<Course> availableafter(int hour, String interm) { LinkedList<Course> result = new LinkedList<Course>(); for (Course c : catalog) { if (c.when.starthour >= hour && c.when.term.equals(interm) && c.seatsleft() > 0) { result.addfirst(c); return result; (a) (10 points) On the code itself, box off the code fragments that need to change in order to let you encapsulate (change) the data structure used for the catalog in the Scheduler class. You only need to draw boxes to answer this part. 6

(b) (20 points) Provide classes and/or interfaces you would add in order to encapsulate the catalog data. Provide complete interfaces. For classes, provide variables and headers (names and input/output types) for methods that are not required by their interface. Include only variables and method headers needed to encapsulate the code on the previous page (don t add new features). You do not need to copy chunks of code from the previous page: a good method name will indicate the corresponding code. (c) (10 points) Should any specific code that is currently in the availableafter method move to the Course or TimeSlot classes? Either identify code that should move (and tell us where to), or justify why no changes are necessary. You do not need to write or edit new code. (end of exam) 7