CS 10, Fall 2015, Professor Prasad Jayanti

Size: px
Start display at page:

Download "CS 10, Fall 2015, Professor Prasad Jayanti"

Transcription

1 Problem Solving and Data Structures CS 10, Fall 2015, Professor Prasad Jayanti Midterm Practice Problems We will have a review session on Monday, when I will solve as many of these problems as possible. To prepare for the test, you should attempt to solve these problems on your own before Monday. 1. What is the distinction between an ADT and its implementation? What features does Java provide to realize the distinction between an ADT and its implementation? What is abstraction? What features does Java provide to realize abstraction? 2. Consider an ADT whose state is a collection of integers. The ADT supports two operations, specified as follows: /* adds e to the collection of integers. */ public void insert(int e); /* if e is present in the collection, one instance of e is removed from the collection. */ public void delete(int e); Give an efficient implementation of this ADT. Make sure that your implementation is as efficient as possible both in terms of running time and in terms of space. Hint: Exploit the fact that the above two operations are the only operations that the ADT supports. Consider an ADT whose state is a collection of integers. The ADT supports two operations, specified as follows: /* adds e to the collection of integers. */ public void insert(int e); /* if the collection is nonempty, returns the smallest integer in the collection; else returns -1 */ public int minimum(); Define a class that efficiently implements this ADT. State the running times of your methods in asymptotic notation. (It is not enough for the implementation to be correct: very little credit is awarded unless the implementation is as efficient as possible both in terms of running time and in terms of space.) 3. Consider the following interface for a stack ADT. public interface StackADT<E> { /* pushes e on to the top of the stack. */ public void push(e e) 1

2 /* if the stack is empty, returns null; otherwise, removes and returns the top item of the stack.*/ public E pop() Let us say that our goal is to implement the StackADT using the ListADT, where you should assume that the ListADT E supports only the following methods: addfirst(ee), which adds the item e to the front of the list addlast(ee), which adds the item e to the rear of the list isempty(), which returns true if the list is empty, and false otherwise removefirst(), which is legal to invoke if and only if the list is nonempty and, when legal, removes and returns the first element of the list removelast(), which is legal to invoke if and only if the list is nonempty and, when legal, removes and returns the last element of the list Assume that the class ListImpl<E> implements ListADT E with the following performance: addfirst(ee) runs in O(1) time addlast(ee) runs in O(1) time isempty() runs in O(1) time removefirst() runs in O(1) time removelast() runs in Θ(n) time, where n is the length of the list Write a class StackImpl E that implements StackADT E using the class ListImpl E such that all operations of run in O(1) time. 4. In the class I explained how to implement a queue using a circular array and allocating a bigger array whenever we run out of space in the current array. Using these ideas, write a class that implements a queue, where the items in the queue are known to be integers. 5. Suppose that we have a class S to maintain a sequence of integers, where we represent the sequence using a singly linked list with sentinel. Each node of the linked list belongs to an inner class E (of S) that has two public instance variables data (of type int) and next (of type E). Assume that the class S has a single instance variable sentinel that references the sentinel node. For the class S, write the method public void removefirstoccurrence(int x) that removes the first occurrence of x from the sequence (maintained by S). In asymptotic notation, what is the run time of your method? 6. Redo the previous problem assuming that the designer of the class S changed her mind and represented the sequence using a singly linked list without a sentinel. 7. A complete binary tree is a binary tree where all leaves have the same depth. In the class that implements the BinaryTree methods, write the method public boolean iscompletebinarytree() that returns true if and only if this (i.e., the tree on which the method is invoked) is a complete binary tree. 2

3 8. Given a binary tree T and a node x in the tree, consider the path from T s root to the node x. This path is a sequence of edges, some of which are left edges and the others right edges (note that this sequence is empty if x is T s root). Each time a left edge is immediately followed by a right edge or a right edge is immediately followed by a left edge, we say the path takes a turn. Thus, the path can take zero or more turns. For example, the path LLLL takes 0 turns, the path R takes 0 turns, the empty sequence takes 0 turns, and the path LLLRRRLLRL takes four turns. If T is a tree and l is a leaf of T, et n(l, T ) denote the number of turns that a path from T s root to l takes; and let n(t ) denote the sum, over all leaves l of T, of n(l, T ). In the class that implements the BinaryTree methods, write the method public int sumofturnsofleaves() that returns n(t ), where T is this (the tree on which the method is invoked). 9. Why is the distinction between an ADT and its implementation important? Be sure you know about inheritance, polymorphism, and dynamic binding. 10. Consider the following two class definitions: // *****************Definition of the class CourseGrade************************ public class CourseGrade { private String coursename; private int points; // name of the course // regular points earned in the course // Constructor, takes the name and points public CourseGrade (String name, int pts) { coursename = name; points = pts; // increases the points by n public void increasepoints (int n) { points = points + n; // returns points public int getpoints () { return points; // returns if the grade should be A or not public boolean gota() { return (getpoints() >= 93); // prints points public void printpoints() { System.out.println("Points = " + points); // end of the class CourseGrade Turn to the next page for the definition of the second class. 3

4 // ****************Definition of the class CS25Grade*********************** public class CS25Grade extends CourseGrade { private int extracredit; // extra credit points earned in CS 25 // Constructor, takes course name, regular points earned, and // extra credit points earned public class CS25Grade (String name, int regpoints, int ecpoints) { // increases regular points by m and extra credit points by n public void increasepoints (int m, int n) { // overrides the inherited method and returns total points earned in // the course, i.e., the sum of regular points and extra credit points public int getpoints () { // prints total points earned, overrides the inherited method public void printpoints() { System.out.println("Points = " + getpoints()); // end of the class CS25Grade NOTE: When answering the following questions, you are not allowed to introduce any new instance variables or methods in either of the above two classes. (a) Of the two classes defined above, which is the superclass and which is the subclass? (b) Based on the code and the accompanying comments given above, fill in the code for the constructor of the CS25Grade class (in the space provided under the header of the constructor). (c) Fill in the code for the getpoints() method in the CS25Grade class. (d) Fill in the code for the increasepoints(int m, int n) method in the CS25Grade class. (e) What does the following code print? Briefly explain your answer. (Notice that g is declared to be a reference to CourseGrade but is assigned a reference to CS25Grade.) 4

5 CourseGrade g = new CS25Grade("CS 25", 90, 5); if (g.gota()) System.out.prinln("I got A"); else System.out.println("I did not get A"); 11. This problem requires you to write an applet that can respond to mouse events and timer events. Most importantly, it requires you to think carefully about what instance variables to use in the applet and how to properly update them as events occur. Here is the description of how your applet must behave. When the applet first comes into being, it should display nothing. When the user clicks on the applet, it starts a clock and displays the value of this clock in seconds. This display is simply a number, which is updated every second. For example, 10 seconds after the clock is created (in response to the user s first click on the applet), the number displayed will be 10. When the user clicks on the applet the second time, your program should create a second clock and start displaying the values of both clocks. The value of the second clock is simply the number of seconds since its creation. For example, in a scenario where the second click comes 20 seconds after the first click, immediately after the second click the applet s window should display As before, the display should be updated each second, showing the current values of the two clocks. For instance, in the previous example, 50 seconds after the second clock is born, the display will show If there are already two clocks when the user clicks on the applet window, the click should have no effect (i.e., a third clock is not created). When the mouse exits the applet window, the display should go blank, i.e., it should show nothing. (From a conceptual point of view, any clocks that were there until then simply die ). Later, if the user clicks on the applet once more, a clock will be born again, starting once more with a value of 0. As before, a second click will give birth to a second clock, but the subsequent clicks will have no effect. Thus, at any point in time, the applet window displays the values of two clocks, or one clock, or none at all. Based on the description above, write your applet. Here is some useful information that you already know, but I am repeating to help you recall. The constructor for the Timer class takes two parameters an integer and a reference to an ActionListener object. For instance, if r is a variable that holds a reference to an ActionListener object, the call new Timer(100, r) creates a timer object with two guarantees: (i) once the timer is turned on, it goes off every 100 milliseconds, and (ii) every time the timer goes off, r.actionperformed() gets called. The Timer class supports start(), stop(), isrunning() methods. You might need only some of these methods. You can display a string s on the applet window starting at point (x, y) using the call page.drawstring(s, x, y) You must call repaint() after you make changes to the representation of what appears in the Applet window. 5

Dartmouth College Computer Science 10, Fall 2015 Midterm Exam

Dartmouth College Computer Science 10, Fall 2015 Midterm Exam Dartmouth College Computer Science 10, Fall 2015 Midterm Exam 6.00-9.00pm, Monday, October 19, 2015 105 Dartmouth Hall Professor Prasad Jayanti Print your name: Print your section leader name: If you need

More information

CS171 Midterm Exam. October 29, Name:

CS171 Midterm Exam. October 29, Name: CS171 Midterm Exam October 29, 2012 Name: You are to honor the Emory Honor Code. This is a closed-book and closed-notes exam. You have 50 minutes to complete this exam. Read each problem carefully, and

More information

Data Structure (CS301)

Data Structure (CS301) WWW.VUPages.com http://forum.vupages.com WWW.VUTUBE.EDU.PK Largest Online Community of VU Students Virtual University Government of Pakistan Midterm Examination Spring 2003 Data Structure (CS301) StudentID/LoginID

More information

Dartmouth College Computer Science 10, Winter 2012 Solution to Midterm Exam

Dartmouth College Computer Science 10, Winter 2012 Solution to Midterm Exam Dartmouth College Computer Science 10, Winter 2012 Solution to Midterm Exam Thursday, February 9, 2012 Professor Drysdale Print your name: If you need more space to answer a question than we give you,

More information

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIFTH SEMESTER FINAL EXAMINATION, 2014/2015 SESSION PSD2023 ALGORITHM & DATA STRUCTURE DSEW-E-F-2/13 25 MAY 2015 9.00 AM

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

Computer Science 62. Bruce/Mawhorter Fall 16. Midterm Examination. October 5, Question Points Score TOTAL 52 SOLUTIONS. Your name (Please print)

Computer Science 62. Bruce/Mawhorter Fall 16. Midterm Examination. October 5, Question Points Score TOTAL 52 SOLUTIONS. Your name (Please print) Computer Science 62 Bruce/Mawhorter Fall 16 Midterm Examination October 5, 2016 Question Points Score 1 15 2 10 3 10 4 8 5 9 TOTAL 52 SOLUTIONS Your name (Please print) 1. Suppose you are given a singly-linked

More information

Largest Online Community of VU Students

Largest Online Community of VU Students WWW.VUPages.com http://forum.vupages.com WWW.VUTUBE.EDU.PK Largest Online Community of VU Students MIDTERM EXAMINATION SEMESTER FALL 2003 CS301-DATA STRUCTURE Total Marks:86 Duration: 60min Instructions

More information

Computer Science 302 Spring 2007 Practice Final Examination: Part I

Computer Science 302 Spring 2007 Practice Final Examination: Part I Computer Science 302 Spring 2007 Practice Final Examination: Part I Name: This practice examination is much longer than the real final examination will be. If you can work all the problems here, you will

More information

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

CS 61B, Summer 2001 Midterm Exam II Professor Michael Olan CS 61B, Summer 2001 Midterm Exam II Professor Michael Olan Problem 1 (8 points - 1 pt each parts a.-e., 2 pts part f.) a. Consider the following proof: Suppose f(n) is O(g(n)). From this we know that g(n)

More information

CS 367: Introduction to Data Structures Midterm Sample Questions

CS 367: Introduction to Data Structures Midterm Sample Questions LAST NAME (PRINT): FIRST NAME (PRINT): CS 367: Introduction to Data Structures Midterm Sample Questions Friday, July 14 th 2017. 100 points (26% of final grade) Instructor: Meena Syamkumar 1. Fill in these

More information

In addition to the correct answer, you MUST show all your work in order to receive full credit.

In addition to the correct answer, you MUST show all your work in order to receive full credit. In addition to the correct answer, you MUST show all your work in order to receive full credit. Questions Mark: Question1) Multiple Choice Questions /10 Question 2) Binary Trees /15 Question 3) Linked

More information

COS 226 Algorithms and Data Structures Fall Midterm

COS 226 Algorithms and Data Structures Fall Midterm COS 226 Algorithms and Data Structures Fall 2017 Midterm This exam has 10 questions (including question 0) worth a total of 55 points. You have 0 minutes. This exam is preprocessed by a computer, so please

More information

CIS Fall Data Structures Midterm exam 10/16/2012

CIS Fall Data Structures Midterm exam 10/16/2012 CIS 2168 2012 Fall Data Structures Midterm exam 10/16/2012 Name: Problem 1 (30 points) 1. Suppose we have an array implementation of the stack class, with ten items in the stack stored at data[0] through

More information

Largest Online Community of VU Students

Largest Online Community of VU Students WWW.VUPages.com WWW.VUTUBE.EDU.PK http://forum.vupages.com Largest Online Community of VU Students MIDTERM EXAMINATION SEMESTER FALL 2003 CS301-DATA STRUCTURE Total Marks:86 Duration: 60min Instructions

More information

Computer Science 62. Midterm Examination

Computer Science 62. Midterm Examination Computer Science 62 Bruce/Mawhorter Fall 16 Midterm Examination October 5, 2016 Question Points Score 1 15 2 10 3 10 4 8 5 9 TOTAL 52 Your name (Please print) 1. Suppose you are given a singly-linked list

More information

Csci 102: Sample Exam

Csci 102: Sample Exam Csci 102: Sample Exam Duration: 65 minutes Name: NetID: Student to your left: Student to your right: DO NOT OPEN THIS EXAM UNTIL INSTRUCTED Instructions: Write your full name and your NetID on the front

More information

Largest Online Community of VU Students

Largest Online Community of VU Students WWW.VUPages.com WWW.VUTUBE.EDU.PK http://forum.vupages.com Largest Online Community of VU Students MIDTERM EXAMINATION SEMESTER FALL 2003 CS301-DATA STRUCTURE Total Marks:86 Duration: 60min Instructions

More information

Lists. ordered lists unordered lists indexed lists 9-3

Lists. ordered lists unordered lists indexed lists 9-3 The List ADT Objectives Examine list processing and various ordering techniques Define a list abstract data type Examine various list implementations Compare list implementations 9-2 Lists A list is a

More information

CS 216 Exam 1 Fall SOLUTION

CS 216 Exam 1 Fall SOLUTION CS 216 Exam 1 Fall 2004 - SOLUTION Name: Lab Section: Email Address: Student ID # This exam is closed note, closed book. You will have an hour and fifty minutes total to complete the exam. You may NOT

More information

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor. 3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.

More information

Midterm Exam (REGULAR SECTION)

Midterm Exam (REGULAR SECTION) Data Structures (CS 102), Professor Yap Fall 2014 Midterm Exam (REGULAR SECTION) October 28, 2014 Midterm Exam Instructions MY NAME:... MY NYU ID:... MY EMAIL:... Please read carefully: 0. Do all questions.

More information

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

Computer Science Foundation Exam. Dec. 19, 2003 COMPUTER SCIENCE I. Section I A. No Calculators! KEY Computer Science Foundation Exam Dec. 19, 2003 COMPUTER SCIENCE I Section I A No Calculators! Name: KEY SSN: Score: 50 In this section of the exam, there are Three (3) problems You must do all of them.

More information

Name: I. 20 II. 20 III. 20 IV. 40. CMSC 341 Section 01 Fall 2016 Data Structures Exam 1. Instructions: 1. This is a closed-book, closed-notes exam.

Name: I. 20 II. 20 III. 20 IV. 40. CMSC 341 Section 01 Fall 2016 Data Structures Exam 1. Instructions: 1. This is a closed-book, closed-notes exam. CMSC 341 Section 01 Fall 2016 Data Structures Exam 1 Name: Score Max I. 20 II. 20 III. 20 IV. 40 Instructions: 1. This is a closed-book, closed-notes exam. 2. You have 75 minutes for the exam. 3. Calculators,

More information

Computer Science CS221 Test 2 Name. 1. Give a definition of the following terms, and include a brief example. a) Big Oh

Computer Science CS221 Test 2 Name. 1. Give a definition of the following terms, and include a brief example. a) Big Oh Computer Science CS221 Test 2 Name 1. Give a definition of the following terms, and include a brief example. a) Big Oh b) abstract class c) overriding d) implementing an interface 10/21/1999 Page 1 of

More information

CIS 120 Midterm II November 16, 2012 SOLUTIONS

CIS 120 Midterm II November 16, 2012 SOLUTIONS CIS 120 Midterm II November 16, 2012 SOLUTIONS 1 1. Java vs. OCaml (22 points) a. In OCaml, the proper way to check whether two string values s and t are structurally equal is: s == t s = t s.equals(t)

More information

Inheritance. Transitivity

Inheritance. Transitivity Inheritance Classes can be organized in a hierarchical structure based on the concept of inheritance Inheritance The property that instances of a sub-class can access both data and behavior associated

More information

First Examination. CS 225 Data Structures and Software Principles Spring p-9p, Tuesday, February 19

First Examination. CS 225 Data Structures and Software Principles Spring p-9p, Tuesday, February 19 Department of Computer Science First Examination CS 225 Data Structures and Software Principles Spring 2008 7p-9p, Tuesday, February 19 Name: NetID: Lab Section (Day/Time): This is a closed book and closed

More information

CSE373 Fall 2013, Midterm Examination October 18, 2013

CSE373 Fall 2013, Midterm Examination October 18, 2013 CSE373 Fall 2013, Midterm Examination October 18, 2013 Please do not turn the page until the bell rings. Rules: The exam is closed-book, closed-note, closed calculator, closed electronics. Please stop

More information

Top of the Stack. Stack ADT

Top of the Stack. Stack ADT Module 3: Stack ADT Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Stack ADT Features (Logical View) A List that

More information

Computer Science 136 Exam 2

Computer Science 136 Exam 2 Computer Science 136 Exam 2 Sample exam Show all work. No credit will be given if necessary steps are not shown or for illegible answers. Partial credit for partial answers. Be clear and concise. Write

More information

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc. Chapter 13 Object Oriented Programming Contents 13.1 Prelude: Abstract Data Types 13.2 The Object Model 13.4 Java 13.1 Prelude: Abstract Data Types Imperative programming paradigm Algorithms + Data Structures

More information

Data Structures. BSc in Computer Science University of New York, Tirana. Assoc. Prof. Marenglen Biba 1-1

Data Structures. BSc in Computer Science University of New York, Tirana. Assoc. Prof. Marenglen Biba 1-1 Data Structures BSc in Computer Science University of New York, Tirana Assoc. Prof. Marenglen Biba 1-1 General info Course : Data Structures (3 credit hours) Instructor : Assoc. Prof. Marenglen Biba Office

More information

Prelim CS410, Summer July 1998 Please note: This exam is closed book, closed note. Sit every-other seat. Put your answers in this exam. The or

Prelim CS410, Summer July 1998 Please note: This exam is closed book, closed note. Sit every-other seat. Put your answers in this exam. The or Prelim CS410, Summer 1998 17 July 1998 Please note: This exam is closed book, closed note. Sit every-other seat. Put your answers in this exam. The order of the questions roughly follows the course presentation

More information

CPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues

CPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues CPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues Alan J. Hu (Slides borrowed from Steve Wolfman) Be sure to check course webpage! http://www.ugrad.cs.ubc.ca/~cs221 1 Lab 1 is available.

More information

Midterm Exam 2 CS 455, Spring 2011

Midterm Exam 2 CS 455, Spring 2011 Name: USC loginid (e.g., ttrojan): Midterm Exam 2 CS 455, Spring 2011 March 31, 2011 There are 6 problems on the exam, with 50 points total available. There are 7 pages to the exam, including this one;

More information

Multiple choice questions. Answer on Scantron Form. 4 points each (100 points) Which is NOT a reasonable conclusion to this sentence:

Multiple choice questions. Answer on Scantron Form. 4 points each (100 points) Which is NOT a reasonable conclusion to this sentence: Multiple choice questions Answer on Scantron Form 4 points each (100 points) 1. Which is NOT a reasonable conclusion to this sentence: Multiple constructors for a class... A. are distinguished by the number

More information

CMSC 331 Second Midterm Exam

CMSC 331 Second Midterm Exam 1 20/ 2 80/ 331 First Midterm Exam 11 November 2003 3 20/ 4 40/ 5 10/ CMSC 331 Second Midterm Exam 6 15/ 7 15/ Name: Student ID#: 200/ You will have seventy-five (75) minutes to complete this closed book

More information

CMSC351 - Fall 2014, Homework #2

CMSC351 - Fall 2014, Homework #2 CMSC351 - Fall 2014, Homework #2 Due: October 8th at the start of class Name: Section: Grades depend on neatness and clarity. Write your answers with enough detail about your approach and concepts used,

More information

Computer Science 302 Spring 2017 (Practice for) Final Examination, May 10, 2017

Computer Science 302 Spring 2017 (Practice for) Final Examination, May 10, 2017 Computer Science 302 Spring 2017 (Practice for) Final Examination, May 10, 2017 Name: The entire practice examination is 1005 points. 1. True or False. [5 points each] The time to heapsort an array of

More information

CS 455 Midterm 2 Fall 2017 [Bono] Nov. 7, 2017

CS 455 Midterm 2 Fall 2017 [Bono] Nov. 7, 2017 Name: USC NetID (e.g., ttrojan): CS 455 Midterm 2 Fall 2017 [Bono] Nov. 7, 2017 There are 6 problems on the exam, with 62 points total available. There are 10 pages to the exam (5 pages double-sided),

More information

CMSC 202 Final May 19, Name: UserID: (Circle your section) Section: 101 Tuesday 11: Thursday 11:30

CMSC 202 Final May 19, Name: UserID: (Circle your section) Section: 101 Tuesday 11: Thursday 11:30 CMSC 202 Final May 19, 2005 Name: UserID: (Circle your section) Section: 101 Tuesday 11:30 102 Thursday 11:30 Directions 103 Tuesday 12:30 104 Thursday 12:30 105 Tuesday 1:30 106 Thursday 1:30 This is

More information

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 The data of the problem is of 2GB and the hard disk is of 1GB capacity, to solve this problem we should Use better data structures

More information

double d0, d1, d2, d3; double * dp = new double[4]; double da[4];

double d0, d1, d2, d3; double * dp = new double[4]; double da[4]; All multiple choice questions are equally weighted. You can generally assume that code shown in the questions is intended to be syntactically correct, unless something in the question or one of the answers

More information

CS 1316 Exam 2 Summer 2009

CS 1316 Exam 2 Summer 2009 1 / 8 Your Name: I commit to uphold the ideals of honor and integrity by refusing to betray the trust bestowed upon me as a member of the Georgia Tech community. CS 1316 Exam 2 Summer 2009 Section/Problem

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

University of Palestine. Final Exam 2 nd semester 2014/2015 Total Grade: 50

University of Palestine. Final Exam 2 nd semester 2014/2015 Total Grade: 50 First Question Q1 B1 Choose the best Answer: No. of Branches (1) (10/50) 1) 2) 3) 4) Suppose we start with an empty stack and then perform the following operations: Push (A); Push (B); Pop; Push (C); Top;

More information

csci 210: Data Structures Stacks and Queues

csci 210: Data Structures Stacks and Queues csci 210: Data Structures Stacks and Queues 1 Summary Topics Stacks and Queues as abstract data types ( ADT) Implementations arrays linked lists Analysis and comparison Applications: searching with stacks

More information

CS2 Practical 1 CS2A 22/09/2004

CS2 Practical 1 CS2A 22/09/2004 CS2 Practical 1 Basic Java Programming The purpose of this practical is to re-enforce your Java programming abilities. The practical is based on material covered in CS1. It consists of ten simple programming

More information

CIS 120 Midterm II November 8, 2013 SOLUTIONS

CIS 120 Midterm II November 8, 2013 SOLUTIONS CIS 120 Midterm II November 8, 2013 SOLUTIONS 1 1. Facts about OCaml and Java (15 points) For each part, circle true or false. a. T F The.equals method in Java is roughly similar to OCaml s = operator.

More information

Top of the Stack. Stack ADT

Top of the Stack. Stack ADT Module 3: Stack ADT Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Stack ADT Features (Logical View) A List that

More information

Chapter 1: Object-Oriented Programming Using C++

Chapter 1: Object-Oriented Programming Using C++ Chapter 1: Object-Oriented Programming Using C++ Objectives Looking ahead in this chapter, we ll consider: Abstract Data Types Encapsulation Inheritance Pointers Polymorphism Data Structures and Algorithms

More information

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

CPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001 CPSC 211, Sections 201 203: Data Structures and Implementations, Honors Final Exam May 4, 2001 Name: Section: Instructions: 1. This is a closed book exam. Do not use any notes or books. Do not confer with

More information

CIS 120 Midterm II November 8, Name (printed): Pennkey (login id):

CIS 120 Midterm II November 8, Name (printed): Pennkey (login id): CIS 120 Midterm II November 8, 2013 Name (printed): Pennkey (login id): My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in completing

More information

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

University of Illinois at Urbana-Champaign Department of Computer Science. Second Examination University of Illinois at Urbana-Champaign Department of Computer Science Second Examination CS 225 Data Structures and Software Principles Spring 2014 7-10p, Tuesday, April 8 Name: NetID: Lab Section

More information

namibia UniVERSITY OF SCIEnCE AnD TECHnOLOGY

namibia UniVERSITY OF SCIEnCE AnD TECHnOLOGY namibia UniVERSITY OF SCIEnCE AnD TECHnOLOGY Faculty of Computing and Informatics Department of Computer Science QUALIFICATION: Bachelor of Computer Science, Bachelor of Informatics, Bachelor of Engineering

More information

CSE 250 Final Exam. Fall 2013 Time: 3 hours. Dec 11, No electronic devices of any kind. You can open your textbook and notes

CSE 250 Final Exam. Fall 2013 Time: 3 hours. Dec 11, No electronic devices of any kind. You can open your textbook and notes CSE 250 Final Exam Fall 2013 Time: 3 hours. Dec 11, 2013 Total points: 100 14 pages Please use the space provided for each question, and the back of the page if you need to. Please do not use any extra

More information

JAVA MOCK TEST JAVA MOCK TEST II

JAVA MOCK TEST JAVA MOCK TEST II http://www.tutorialspoint.com JAVA MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your

More information

Decaf Language Reference Manual

Decaf Language Reference Manual Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented

More information

182 review 1. Course Goals

182 review 1. Course Goals Course Goals 182 review 1 More experience solving problems w/ algorithms and programs minimize static methods use: main( ) use and overload constructors multiple class designs and programming solutions

More information

Introduction to Computing II (ITI 1121) Final Examination

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

More information

Computer Science 136. Midterm Examination

Computer Science 136. Midterm Examination Computer Science 136 Bruce - Spring 04 Midterm Examination March 10, 2004 Question Points Score 1 12 2 10 3 11 4 18 5 8 TOTAL 59 Your name (Please print) I have neither given nor received aid on this examination.

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

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

Points off Total off Net Score. CS 314 Final Exam Spring 2016 Points off 1 2 3 4 5 6 Total off Net Score CS 314 Final Exam Spring 2016 Your Name Your UTEID Instructions: 1. There are 6 questions on this test. 100 points available. Scores will be scaled to 300 points.

More information

COMP 250 Midterm #2 March 11 th 2013

COMP 250 Midterm #2 March 11 th 2013 NAME: STUDENT ID: COMP 250 Midterm #2 March 11 th 2013 - This exam has 6 pages - This is an open book and open notes exam. No electronic equipment is allowed. 1) Questions with short answers (28 points;

More information

Introduction to Linked Data Structures

Introduction to Linked Data Structures Introduction to Linked Data Structures A linked data structure consists of capsules of data known as nodes that are connected via links Links can be viewed as arrows and thought of as one way passages

More information

CS 61B (Clancy, Yelick) Solutions and grading standards for exam 2 Spring 2001 Exam information

CS 61B (Clancy, Yelick) Solutions and grading standards for exam 2 Spring 2001 Exam information Exam information 345 students took the exam. Scores ranged from 3 to 25, with a median of 19 and an average of 18.1. There were 176 scores between 19 and 25, 125 between 12.5 and 18.5, 42 between 6 and

More information

CS 307 Final Fall 2009

CS 307 Final Fall 2009 Points off 1 2 3 4 5 6 Total off Net Score CS 307 Final Fall 2009 Name UTEID login name Instructions: 1. Please turn off your cell phones. 2. There are 6 questions on this test. 3. You have 3 hours to

More information

CSE373 Winter 2014, Midterm Examination January 29, 2014

CSE373 Winter 2014, Midterm Examination January 29, 2014 CSE373 Winter 2014, Midterm Examination January 29, 2014 Please do not turn the page until the bell rings. Rules: The exam is closed-book, closed-note, closed calculator, closed electronics. Please stop

More information

Review sheet for Final Exam (List of objectives for this course)

Review sheet for Final Exam (List of objectives for this course) Review sheet for Final Exam (List of objectives for this course) Please be sure to see other review sheets for this semester Please be sure to review tests from this semester Week 1 Introduction Chapter

More information

CS164: Midterm Exam 2

CS164: Midterm Exam 2 CS164: Midterm Exam 2 Fall 2004 Please read all instructions (including these) carefully. Write your name, login, and circle the time of your section. Read each question carefully and think about what

More information

Computer Science II Fall 2009

Computer Science II Fall 2009 Name: Computer Science II Fall 2009 Exam #2 Closed book and notes. This exam should have five problems and six pages. Problem 0: [1 point] On a scale of 0 5, where 5 is highest, I think I deserve a for

More information

CS2110 Assignment 3 Inheritance and Trees, Summer 2008

CS2110 Assignment 3 Inheritance and Trees, Summer 2008 CS2110 Assignment 3 Inheritance and Trees, Summer 2008 Due Sunday July 13, 2008, 6:00PM 0 Introduction 0.1 Goals This assignment will help you get comfortable with basic tree operations and algorithms.

More information

CS 314 Exam 2 Spring

CS 314 Exam 2 Spring Points off 1 2 3 4 5 Total off CS 314 Exam 2 Spring 2017 Your Name Your UTEID Instructions: 1. There are 5 questions on this test. 100 points available. Scores will be scaled to 200 points. 2. You have

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 07: Linked Lists MOUNA KACEM mouna@cs.wisc.edu Spring 2019 Linked Lists 2 Introduction Linked List Abstract Data Type SinglyLinkedList ArrayList Keep in Mind Introduction:

More information

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism Block 1: Introduction to Java Unit 4: Inheritance, Composition and Polymorphism Aims of the unit: Study and use the Java mechanisms that support reuse, in particular, inheritance and composition; Analyze

More information

FINAL EXAMINATION. COMP-250: Introduction to Computer Science - Fall 2011

FINAL EXAMINATION. COMP-250: Introduction to Computer Science - Fall 2011 STUDENT NAME: STUDENT ID: McGill University Faculty of Science School of Computer Science FINAL EXAMINATION COMP-250: Introduction to Computer Science - Fall 2011 December 13, 2011 2:00-5:00 Examiner:

More information

MIDTERM EXAM (HONORS SECTION)

MIDTERM EXAM (HONORS SECTION) Data Structures Course (V22.0102.00X) Professor Yap Fall 2010 MIDTERM EXAM (HONORS SECTION) October 19, 2010 SOLUTIONS Problem 1 TRUE OR FALSE QUESTIONS (4 Points each) Brief justification is required

More information

Use the scantron sheet to enter the answer to questions (pages 1-6)

Use the scantron sheet to enter the answer to questions (pages 1-6) Use the scantron sheet to enter the answer to questions 1-100 (pages 1-6) Part I. Mark A for True, B for false. (1 point each) 1. Abstraction allow us to specify an object regardless of how the object

More information

Lab 10: Inheritance (I)

Lab 10: Inheritance (I) CS2370.03 Java Programming Spring 2005 Dr. Zhizhang Shen Background Lab 10: Inheritance (I) In this lab, we will try to understand the concept of inheritance, and its relation to polymorphism, better;

More information

University of Massachusetts Amherst, Electrical and Computer Engineering

University of Massachusetts Amherst, Electrical and Computer Engineering University of Massachusetts Amherst, Electrical and Computer Engineering ECE 122 Midterm Exam 1 Makeup Answer key March 2, 2018 Instructions: Closed book, Calculators allowed; Duration:120 minutes; Write

More information

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive) Final Exam Exercises Chapters 1-7 + 11 Write C++ code to: l Determine if a number is odd or even CS 2308 Fall 2016 Jill Seaman l Determine if a number/character is in a range - 1 to 10 (inclusive) - between

More information

Prelim One Solution. CS211 Fall Name. NetID

Prelim One Solution. CS211 Fall Name. NetID Name NetID Prelim One Solution CS211 Fall 2005 Closed book; closed notes; no calculators. Write your name and netid above. Write your name clearly on each page of this exam. For partial credit, you must

More information

Tree: non-recursive definition. Trees, Binary Search Trees, and Heaps. Tree: recursive definition. Tree: example.

Tree: non-recursive definition. Trees, Binary Search Trees, and Heaps. Tree: recursive definition. Tree: example. Trees, Binary Search Trees, and Heaps CS 5301 Fall 2013 Jill Seaman Tree: non-recursive definition Tree: set of nodes and directed edges - root: one node is distinguished as the root - Every node (except

More information

This examination has 11 pages. Check that you have a complete paper.

This examination has 11 pages. Check that you have a complete paper. MARKING KEY The University of British Columbia MARKING KEY Computer Science 252 2nd Midterm Exam 6:30 PM, Monday, November 8, 2004 Instructors: K. Booth & N. Hutchinson Time: 90 minutes Total marks: 90

More information

Section 1: True / False (2 points each, 30 pts total)

Section 1: True / False (2 points each, 30 pts total) Section 1: True / False (2 points each, 30 pts total) Circle the word TRUE or the word FALSE. If neither is circled, both are circled, or it impossible to tell which is circled, your answer will be considered

More information

CPSC 221: Algorithms and Data Structures ADTs, Stacks, and Queues

CPSC 221: Algorithms and Data Structures ADTs, Stacks, and Queues CPSC 221: Algorithms and Data Structures ADTs, Stacks, and Queues Alan J. Hu (Slides borrowed from Steve Wolfman) Be sure to check course webpage! http://www.ugrad.cs.ubc.ca/~cs221 1 Lab 1 available very

More information

Generics in Java. EECS2030: Advanced Object Oriented Programming Fall 2017 CHEN-WEI WANG

Generics in Java. EECS2030: Advanced Object Oriented Programming Fall 2017 CHEN-WEI WANG Generics in Java EECS2030: Advanced Object Oriented Programming Fall 2017 CHEN-WEI WANG Motivating Example: A Book of Objects 1 class Book { 2 String[] names; 3 Object[] records; 4 /* add a name-record

More information

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014 Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class

More information

Motivating Example: Observations (1) Generics in Java. Motivating Example: A Book of Objects. Motivating Example: Observations (2)

Motivating Example: Observations (1) Generics in Java. Motivating Example: A Book of Objects. Motivating Example: Observations (2) Motivating Example: Observations (1) Generics in Java EECS2030: Advanced Object Oriented Programming Fall 2017 CHEN-WEI WANG In the Book class: By declaring the attribute Object[] records We meant that

More information

Object-Oriented Design Lecture 14 CSU 370 Fall 2007 (Pucella) Friday, Nov 2, 2007

Object-Oriented Design Lecture 14 CSU 370 Fall 2007 (Pucella) Friday, Nov 2, 2007 Object-Oriented Design Lecture 14 CSU 370 Fall 2007 (Pucella) Friday, Nov 2, 2007 (These notes are very rough, and differ somewhat from what I presented in class; I am posting them here to supplemental

More information

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today Introduction to Linked Lists Stacks and Queues using Linked Lists Next Time Iterative Algorithms on Linked Lists Reading:

More information

Code Reuse: Inheritance

Code Reuse: Inheritance Object-Oriented Design Lecture 14 CSU 370 Fall 2008 (Pucella) Tuesday, Nov 4, 2008 Code Reuse: Inheritance Recall the Point ADT we talked about in Lecture 8: The Point ADT: public static Point make (int,

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Interface Abstract data types Version of January 26, 2013 Abstract These lecture notes are meant

More information

CMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are "built" on top of that.

CMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are built on top of that. CMSC131 Inheritance Object When we talked about Object, I mentioned that all Java classes are "built" on top of that. This came up when talking about the Java standard equals operator: boolean equals(object

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

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures MIDTERM EXAMINATION Spring 2010 CS301- Data Structures Question No: 1 Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the

More information

Subclassing for ADTs Implementation

Subclassing for ADTs Implementation Object-Oriented Design Lecture 8 CS 3500 Fall 2009 (Pucella) Tuesday, Oct 6, 2009 Subclassing for ADTs Implementation An interesting use of subclassing is to implement some forms of ADTs more cleanly,

More information

CS/ENGRD 2110 SPRING 2018

CS/ENGRD 2110 SPRING 2018 CS/ENGRD 2110 SPRING 2018 Lecture 7: Interfaces and http://courses.cs.cornell.edu/cs2110 1 2 St Valentine s Day! It's Valentines Day, and so fine! Good wishes to you I consign.* But since you're my students,

More information

Instructions. Definitions. Name: CMSC 341 Fall Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII.

Instructions. Definitions. Name: CMSC 341 Fall Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII. CMSC 341 Fall 2013 Data Structures Final Exam B Name: Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII. /12 TOTAL: /100 Instructions 1. This is a closed-book, closed-notes exam. 2. You

More information