CSE 143 Sp03 Final Exam Sample Solution Page 1 of 13

Size: px
Start display at page:

Download "CSE 143 Sp03 Final Exam Sample Solution Page 1 of 13"

Transcription

1 CSE 143 Sp03 Final Exam Sample Solution Page 1 of 13 Question 1. (3 points) Java classifies exceptions as either checked or unchecked. For each of the following, indicate whether it is checked or unchecked by circling the correct answer. NullPointerException checked unchecked IOException checked unchecked IllegalArgumentException checked unchecked Question 2. (4 points) Both quicksort and mergesort have an expected time of O(n log n) to sort a list containing n items. However, in the worst case, quicksort can require O(n 2 ) time, while mergesort s worst case running time is the same as its expected time, O(n log n). (a) What accounts for the difference in worst case times? How is it that quicksort can require O(n 2 ) time, while mergesort always guarantees O(n log n)? Mergesort always divides the list in half, resulting in two subproblems of size n/2 and a maximum recursion depth of log n, giving a total running time of O(n log n). If quicksort s partition function also divides the list in half each time, the running time will be the same as mergesort O(n log n) but if it repeatedly picks either the largest or smallest element in the list as the pivot, there will be n recursive calls, resulting in a total running time of O(n 2 ). (b) Given that mergesort s worst case time is better than quicksort s, why bother ever to use quicksort at all? (i.e., why is quicksort so commonly used in practice?) Quicksort s advantage is that it can sort a list in place, while mergesort needs a second list to merge the results of the subproblems. Since it is possible in practice to pick a good pivot value and get quicksort to run in O(n log n), the fact that it doesn t need the extra space makes it the method of choice.

2 CSE 143 Sp03 Final Exam Sample Solution Page 2 of 13 Question 3. (4 points) Class Object contains a hashcode() method that is either inherited or overridden by every Java class. (a) Suppose we have a hash table that contains nbuckets buckets (initialized somewhere else). Complete the following line of code so it returns the bucket in which the given object should be stored. int nbuckets; // number of buckets (initialized elsewhere) // return the bucket number for obj public int bucketnumber(object obj) { return obj.hashcode() % nbuckets ; (b) When a Java class is defined, if it overrides method hashcode() by giving a new definition for that method, the class should normally also override equals(). What should be true about the relationship between the values returned by these two methods? If, for two objects o1 and o2, the result of o1.equals(o2) is true, then o1.hashcode() should be the same as o2.hashcode(). [Reason: two objects that are equal should hash to the same bucket. Note that the converse need not be true. o1.hashcode() == o2.hashcode() does not necessarily imply that o1.equals(o2). o1 and o2 might be two different objects with the same hash code a collision.] Question 4. (4 points) Draw a balanced binary search tree containing the following strings: cat, dog, bird, cow, pig, rat, ferret. Use normal alphabetical (dictionary) ordering to decide where to put the words in the tree. dog cat pig bird cow ferret rat (This is the only tree that got full credit. Trees that were not balanced or were not quite binary search trees received some partial credit.)

3 CSE 143 Sp03 Final Exam Sample Solution Page 3 of 13 Question 5. (6 points) During the quarter we ve looked at several different ways of storing a collection of objects, in particular: Lists based on arrays Single- and double-linked lists Trees, particularly binary search trees Hash tables For each of the following applications, indicate which data structure would be most appropriate and give a brief explanation justifying your choice in a technical way using, among other possibilities, the O() times needed to perform various operations. (a) Online telephone directory. Lookups by last name are extremely frequent hundreds per second. Insert and delete operations are less frequent, but there still are many per minute. Once each year the entire directory needs to be printed out in alphabetical order by last name. A hash table would be best since it can perform lookup, insert, and delete in O(1) time (assuming a good hash function and a large enough table). It will take O(n log n) time to produce a sorted copy of the directory, but that is done so infrequently that it doesn t need to be particularly fast. (Answers that recommended a binary search tree received partial credit. This data structure can search, insert, and delete in O(log n) time, and produce a sorted list in O(n) time.) (b) List of students in a class during registration. Students add and drop fairly frequently, and compulsive instructors insist on being able to get up-to-date, sorted alphabetically, class lists via whenever a student adds or drops. The operations that need to be fast are add, delete, and traversing the list in order. A binary search tree can implement all of these operations in O(log n) time, so it would be the best choice. (c) Computerized waiting line at the Department of Licensing driver s license examination station. Employees at the reception desk need to be able to record the names of people as they arrive, then call out their names when they get to the head of the line. The appropriate data structure for this is a queue (an ordered list), and the operations that need to be fast are adding a new name at the rear of the queue and removing a name from the front. A linked list or circular array implementation can perform both operations in O(1) time, either of these would be the best choice.

4 CSE 143 Sp03 Final Exam Sample Solution Page 4 of 13 Question 6. (12 points) Consider the following class definitions: public class Alpha { public Alpha() { System.out.println("Alpha constructor"); public void one(){ System.out.println("Alpha one"); public void two(){ System.out.println("Alpha two"); public class Beta extends Alpha { public Beta() { System.out.println("Beta Constructor"); public void one() { System.out.println("Beta one"); public void iii() { System.out.println("Beta iii"); two(); public class Gamma extends Beta { public Gamma() { super(); System.out.println("Gamma constructor"); public void two() { System.out.println("Gamma two"); public void iii() { System.out.println("Gamma iii"); two(); super.iii(); In each of the question parts on the next page, indicate the output produced when the group of statements in that part is typed into a DrJava interactions window. Assume that each group of statements starts with an empty, newly reset interactions window. If a statement results in either a compile-time or runtime error, show all of the output that would be produced prior to that statement, then describe the error. Hint: Be sure you notice that there are println statements in the constructors this time. You can tear out this page if you want so you can refer to it without having to flip back and forth while answering the questions.

5 CSE 143 Sp03 Final Exam Sample Solution Page 5 of 13 (a) Beta b = new Beta(); b.one(); Alpha constructor Beta constructor Beta one b.iii(); Beta iii Alpha two (b) Alpha a = new Beta(); Alpha constructor Beta constructor a.one(); Beta one a.iii(); Error: no iii method in class Alpha (c) Beta b = new Gamma(); Alpha constructor Beta constructor Gamma constructor b.one(); Beta one (d) b.iii(); Beta b = new Alpha(); b.one(); Gamma iii Gamma two Beta iii Gamma two Error: incompatible types in assignment [not executed] b.iii(); [not executed]

6 CSE 143 Sp03 Final Exam Sample Solution Page 6 of 13 Question 7. (6 points) Consider the following method definitions. public void going(int n) { int j = 0; int k = n; while (j < k) { System.out.println("*"); j++; k--; public void bythree(int n) { int k = 1; while (k < n) { System.out.println("*"); k = k*3; public void gone(int n) { for (int i = 0; i < n; i++) { for (int j = i; j > 0; j--) { going(n); For each of the following statements, give the running time as a function of n using O( )- notation. (a) going(n); O(n) (b) gone(n); O(n 3 ) (c) for (int k = 0; k < n; k++) { bythree(n); O(n log n)

7 CSE 143 Sp03 Final Exam Sample Solution Page 7 of 13 Question 8. (15 points) Another Blast From The Past! For this problem, we re returning to the iterator class for doubly-linked lists from the 2 nd midterm. Recall that an iterator provides a constructor and methods hasnext(), next(), and remove(). It turns out that iterators for linked lists also provide a method add(), which you are to implement for this problem. When add(obj) is called, the given object is inserted in the list between the most recent object returned by next() and the following object, which is the one that will be returned by next() when it is called again. add() can be called as many times as desired between successive calls to next(). If it is called two or more times in a row, each new call to add() inserts its argument between the last object added to the list and the one that will be returned by the next call to next(). One consequence of this definition is that executing add() doesn t change the result of future calls to next() or hasnext(). Example: Suppose the list L contains the following strings: rat cow we execute the following sequence of statements: monkey. If Iterator iter = L.iterator(); Object first = iter.next(); iter.add( cat ); iter.add( dog ); // sets first to rat then the resulting list is rat cat dog cow monkey, and the next time next() is called it will return cow, as it would have done even if nothing had been added. End of example. If add() is called after the iterator is created but before the first call to next(), then the new object is added at the beginning of the list. Similarly, if add() is called after next() has returned the last item in the original list (i.e., when hasnext()==false), then the new object is added to the end of the list and hasnext() still returns false if it is called. The code for the doubly-linked list nodes and the SimpleLinkedListIterator class is given below and on the next page. Complete the definition of method add() on the page after that. This code taken directly from the sample solution to midterm 2, with only one difference: method remove() and associated variables are not included, since they are not relevant for this question. Feel free to tear out these pages for reference. public class DLink { public Object item; public DLink next; public DLink prev; // one node in a double-linked list // data associated with this link // next link in the list; null if none // previous link; null if none /** Construct a new node referring to the given object */ public DLink(Object item, DLink next, DLink prev) {...

8 CSE 143 Sp03 Final Exam Sample Solution Page 8 of 13 /** A simple List class */ public class SimpleLinkedList { // instance variables private DLink first; // first item in the list, or // null if the list is empty private DLink last; // last item in the list, or // null if the list is empty... other methods and constructors omitted... /** Iterator for SimpleLinkedList class (nested class) */ private class SimpleLinkedListIterator implements Iterator { // instance variables private DLink nextlink; /** Construct a new iterator */ public SimpleLinkedListIterator() { nextlink = first; // link to next object to be // returned by this iterator, or // null if all objects returned /** Return true if this iterator has more elements */ public boolean hasnext() { return (nextlink!= null); /** Return the next element in the iteration NoSuchElementException if the iteration has * no more elements */ public Object next() throws NoSuchElementException { if (!hasnext()) { throw new NoSuchElementException(); // get next element, advance, and return its value Object result = nextlink.item; nextlink = nextlink.next; return result;... (continued next page)

9 CSE 143 Sp03 Final Exam Sample Solution Page 9 of 13 Question 8. (concluded) Complete the definition of method add() below. For full credit, you may not change the implementation of the existing methods, and you must use the linked list and iterator data structures and instance variables as defined on the previous pages. You may, of course, add additional instance variables or methods if you need them to implement add(). Hint: Draw some pictures to visualize the situation before/while writing code. // Declare any additional instance variables you need here // nothing needed /** Add the given object to the list between the last object * returned by next() and the next object that will be * returned by next(). obj The object to be added. */ public void add(object obj) { // there are three cases to consider: // - adding a new link at the beginning of the list // (two subcases: adding a link to an empty list // and adding a link before the original first link) // - adding a new link at the end of the list, which // occurs if hasnext() returns false (nextlink==null) // - adding a link somewhere in the middle (general case) if (first == nextlink) { // new link at the beginning of the list DLink p = new DLink(obj, first, null); if (first == null) { last = p; else { first.prev = p; first = p; else if (nextlink == null) { // new link at the end of the list; list not empty DLink p = new DLink(obj, null, last); last.next = p; last = p; else { // general case add in middle. We know that // nextlink!= null and nextlink.prev!= null. DLink p = new DLink(obj, nextlink, nextlink.prev); nextlink.prev.next = p; nextlink.prev = p; // end of method add // end of SimpleLinkedListIterator class // end of SimpleLinkedList class

10 CSE 143 Sp03 Final Exam Sample Solution Page 10 of 13 The next two questions concern Binary Search Trees containing integer values in their nodes. The nodes are defined by the following Java class. public class IntBSTNode { // one node an integer BST public int value; // data associated with this node public IntBSTNode left; // left subtree; null if empty public IntBSTNode right; // right subtree; null if empty // no constructor, since we don t need it Question 9. (7 points) The height of a binary tree is defined to be 0 for an empty tree, 1 for a tree consisting of a single node, 2 for a tree consisting of a root node with one or two children that are leaf nodes, etc. Complete the definition of method height() below so it returns the height of the tree whose root is given as its argument. (Hint: recursion is your friend.) // return the height of the binary search tree with root r public int height(intbstnode r) { if (r == null) { return 0; else { int leftheight = height(r.left); int rightheight = height(r.right); if (leftheight >= rightheight) { return leftheight + 1; else { return rightheight + 1; A more compact solution: // return the height of the binary search tree with root r public int height(intbstnode r) { if (r == null) { return 0; else { return 1 + Math.max(height(r.left), height(r.right)); (Notice that neither solution actually uses the fact that the binary tree is a binary search tree. The code works equally well for an arbitrary binary tree.)

11 CSE 143 Sp03 Final Exam Sample Solution Page 11 of 13 (IntBSTNode definition repeated here to reduce the need for page flipping.) public class IntBSTNode { // one node an integer BST public int value; // data associated with this node public IntBSTNode left; // left subtree; null if empty public IntBSTNode right; // right subtree; null if empty // no constructor Question 10. (6 points) Complete the definition of method max() below so it returns the largest value stored in any node in the tree. You should assume that the initial tree in the first call to max has at least one node, but you may not make any other assumptions about the number of nodes in the tree or the values stored in them. For full credit, your method must not visit any more nodes in the tree than are actually necessary (Hint: recursion may be your friend.) // return the largest value in the binary search tree // with root r public int max(intbstnode r) { // precondition: r!= null (true initially because we can // assume that the original tree is not empty, and we will // not call max recursively for an empty tree) if (r.right == null) { // rightmost node; its value is the max value return r.value; else { // not a leaf get max of non-empty right subtree return max(r.right); This can also be done cleanly with a simple loop that chases down the right subtrees until it finds the rightmost node. public int max(intbstnode r) { // precondition: r!= null while (r.right!= null) { r = r.right; return r.value; (Solutions that returned the correct answer but visited more nodes than necessary received partial credit.)

12 CSE 143 Sp03 Final Exam Sample Solution Page 12 of 13 Question 11. (10 points) Parsing. (Yup, you knew it was coming, didn t you?) The expression/term/factor grammar, as extended for Project 3, handled expressions containing addition, subtraction, multiplication, and division. One possible implementation of the corresponding parser would be to have each parser method return the value of the expression or sub-expression that it parses. Here is a summary of the grammar and the methods of the parser. (The grammar only includes integer constants, no variables). expression ::= expression + term expression term term term ::= term * factor term / factor factor factor ::= integerconstant ( expression ) /** Parser to return the value of simple arithmetic expressions */ public class Parser {... tokenizer and delimiters omitted to save space... // parser state private String nexttoken; // next token from input to be // parsed, or (0-length // string) if no input remains // advance nexttoken to next token in the input private void advance() {... // parser methods // Parse expression ::= term {+- term... // and return the value of the expression that was parsed private int expression() {... // Parse term ::= factor {*/ factor... // and return the value of the term that was parsed private int term() {... // Parse factor ::= integerconstant ( expression ) // and return the value of the factor that was parsed private int factor() {... For this question, we want to modify the grammar and the parser to support exponentiation with the correct precedence and associativity. The syntax x^y means x raised to the y power. Exponentiation is a binary operation like +-*/, with one difference: it is rightassociative, not left-associative, unlike the other binary operations. In other words, x^y^z means x^(y^z), not (x^y)^z. Implementation detail: to calculate z = x^y in Java, use the Math.pow function and cast the result of Math.pow from double to int, e.g., int z = (int)math.pow(x,y);. (continued next page)

13 CSE 143 Sp03 Final Exam Sample Solution Page 13 of 13 Question 11. (cont) Here is the expression grammar modified to include exponentiation with the correct precedence (higher than * and /) and associativity (right associative). expression ::= expression + term expression term term term ::= term * power term / power power power ::= factor ^ power factor factor ::= integerconstant ( expression ) (a) (3 points) Assuming that we introduce a method power() to parse the grammar rule for power and return the value of the power that was parsed, what change(s) are needed to the existing parser methods for expression, term, and factor so they will work correctly with power() to handle arithmetic expressions that include exponentiation? (Just describe the changes that would be needed, you don t need to give an implementation.) The only changes that would be needed are in method term(), where all calls to method factor() should be replaced by calls to power(). (b) (7 points) Complete the implementation of method power() so it will correctly parse exponentiation and return the value of the power sub-expression it has parsed. (Hint: think about how you want to handle x ^ y ^ z ^.... A simple iteration might or might not produce the right result.) // Parse power ::= factor {^ factor... // (i.e., power ::= factor factor ^ power) // and return the value of the power that was parsed private int power() { int left = factor(); if (nexttoken.equals("^")) { advance(); int right = power(); return (int)math.pow(left, right); else { return left; (The difference between this method and the ones for expression/term/factor is that we need to ensure that ^ is treated as a right associative operator. So instead of a loop that parses the subexpressions to the right of ^ one at a time using individual calls to factor(), we call power() recursively to parse and return the value of all of the remaining exponential operators to the right.)

CSE 143 Au03 Final Exam Page 1 of 15

CSE 143 Au03 Final Exam Page 1 of 15 CSE 143 Au03 Final Exam Page 1 of 15 Reference information about many standard Java classes appears at the end of the test. You might want to tear off those pages to make them easier to refer to while

More information

CSE 143 Sp04 Final Exam Sample Solution Page 1 of 12

CSE 143 Sp04 Final Exam Sample Solution Page 1 of 12 CSE 143 Sp04 Final Exam Sample Solution Page 1 of 12 Reference information about many standard Java classes appears at the end of the test. You might want to tear off those pages to make them easier to

More information

About this exam review

About this exam review Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review

More information

CSE 143 Sp03 Midterm 2 Sample Solution Page 1 of 7. Question 1. (2 points) What is the difference between a stream and a file?

CSE 143 Sp03 Midterm 2 Sample Solution Page 1 of 7. Question 1. (2 points) What is the difference between a stream and a file? CSE 143 Sp03 Midterm 2 Sample Solution Page 1 of 7 Question 1. (2 points) What is the difference between a stream and a file? A stream is an abstraction representing the flow of data from one place to

More information

Question 1. (2 points) What is the difference between a stream and a file?

Question 1. (2 points) What is the difference between a stream and a file? CSE 143 Sp03 Midterm 2 Page 1 of 7 Question 1. (2 points) What is the difference between a stream and a file? Question 2. (2 points) Suppose we are writing an online dictionary application. Given a word

More information

CSE 413 Final Exam. June 7, 2011

CSE 413 Final Exam. June 7, 2011 CSE 413 Final Exam June 7, 2011 Name The exam is closed book, except that you may have a single page of hand-written notes for reference plus the page of notes you had for the midterm (although you are

More information

Suppose that the following is from a correct C++ program:

Suppose that the following is from a correct C++ program: 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

Part I: Short Answer (12 questions, 65 points total)

Part I: Short Answer (12 questions, 65 points total) CSE 143 Sp01 Final Exam Sample Solution page 1 of 14 Part I: Short Answer (12 questions, 65 points total) Answer all of the following questions. READ EACH QUESTION CAREFULLY. Answer each question in the

More information

CSE 373 Final Exam 3/14/06 Sample Solution

CSE 373 Final Exam 3/14/06 Sample Solution Question 1. (6 points) A priority queue is a data structure that supports storing a set of values, each of which has an associated key. Each key-value pair is an entry in the priority queue. The basic

More information

Review. CSE 143 Java. A Magical Strategy. Hash Function Example. Want to implement Sets of objects Want fast contains( ), add( )

Review. CSE 143 Java. A Magical Strategy. Hash Function Example. Want to implement Sets of objects Want fast contains( ), add( ) Review CSE 143 Java Hashing Want to implement Sets of objects Want fast contains( ), add( ) One strategy: a sorted list OK contains( ): use binary search Slow add( ): have to maintain list in sorted order

More information

EXAMINATIONS 2016 TRIMESTER 2

EXAMINATIONS 2016 TRIMESTER 2 T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2016 TRIMESTER 2 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS

More information

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

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer) COSC 2007 Data Structures II Final Exam Thursday, April 13 th, 2006 This is a closed book and closed notes exam. There are total 3 parts. Please answer the questions in the provided space and use back

More information

EXAMINATIONS 2015 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS

EXAMINATIONS 2015 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS T E W H A R E W Ā N A N G A O T E Student ID:....................... Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2015 TRIMESTER 2 COMP103 INTRODUCTION

More information

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

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Name: Email address: CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial

More information

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

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators) Name: Email address: Quiz Section: CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will

More information

CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed) Name: Email address: CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial

More information

CS134 Spring 2005 Final Exam Mon. June. 20, 2005 Signature: Question # Out Of Marks Marker Total

CS134 Spring 2005 Final Exam Mon. June. 20, 2005 Signature: Question # Out Of Marks Marker Total CS134 Spring 2005 Final Exam Mon. June. 20, 2005 Please check your tutorial (TUT) section from the list below: TUT 101: F 11:30, MC 4042 TUT 102: M 10:30, MC 4042 TUT 103: M 11:30, MC 4058 TUT 104: F 10:30,

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

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

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Name: Email address: CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial

More information

CSE 413 Final Exam Spring 2011 Sample Solution. Strings of alternating 0 s and 1 s that begin and end with the same character, either 0 or 1.

CSE 413 Final Exam Spring 2011 Sample Solution. Strings of alternating 0 s and 1 s that begin and end with the same character, either 0 or 1. Question 1. (10 points) Regular expressions I. Describe the set of strings generated by each of the following regular expressions. For full credit, give a description of the sets like all sets of strings

More information

1.00/1.001 Introduction to Computers and Engineering Problem Solving. Final Exam

1.00/1.001 Introduction to Computers and Engineering Problem Solving. Final Exam 1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Exam Name: Email Address: TA: Section: You have three hours to complete this exam. For coding questions, you do not need to include

More information

Section 05: Solutions

Section 05: Solutions Section 05: Solutions 1. Asymptotic Analysis (a) Applying definitions For each of the following, choose a c and n 0 which show f(n) O(g(n)). Explain why your values of c and n 0 work. (i) f(n) = 5000n

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

1. AVL Trees (10 Points)

1. AVL Trees (10 Points) CSE 373 Spring 2012 Final Exam Solution 1. AVL Trees (10 Points) Given the following AVL Tree: (a) Draw the resulting BST after 5 is removed, but before any rebalancing takes place. Label each node in

More information

Computer Science E-22 Practice Final Exam

Computer Science E-22 Practice Final Exam name Computer Science E-22 This exam consists of three parts. Part I has 10 multiple-choice questions that you must complete. Part II consists of 4 multi-part problems, of which you must complete 3, and

More information

DO NOT. UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N.

DO NOT. UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. CS61B Fall 2013 UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division Test #2 Solutions DO NOT P. N. Hilfinger REPRODUCE 1 Test #2 Solution 2 Problems

More information

Second Examination Solution

Second Examination Solution University of Illinois at Urbana-Champaign Department of Computer Science Second Examination Solution CS 225 Data Structures and Software Principles Fall 2007 7p-9p, Thursday, November 8 Name: NetID: Lab

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

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

Prelim 2. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader

Prelim 2. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader Prelim 2 CS 2110, November 19, 2015, 7:30 PM 1 2 3 4 5 6 Total Question True Short Complexity Searching Trees Graphs False Answer Sorting Invariants Max 20 15 13 14 17 21 100 Score Grader The exam is closed

More information

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

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators) Name: Email address: Quiz Section: CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will

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

Section 05: Solutions

Section 05: Solutions Section 05: Solutions 1. Memory and B-Tree (a) Based on your understanding of how computers access and store memory, why might it be faster to access all the elements of an array-based queue than to access

More information

CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL

CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL MINUTIAE Feedback for P1p1 should have gone out before class Grades on canvas tonight Emails went to the student who submitted the assignment If you did not receive

More information

Prelim 2 Solution. CS 2110, November 19, 2015, 5:30 PM Total. Sorting Invariants Max Score Grader

Prelim 2 Solution. CS 2110, November 19, 2015, 5:30 PM Total. Sorting Invariants Max Score Grader Prelim 2 CS 2110, November 19, 2015, 5:30 PM 1 2 3 4 5 6 Total Question True Short Complexity Searching Trees Graphs False Answer Sorting Invariants Max 20 15 13 14 17 21 100 Score Grader The exam is closed

More information

Prelim 2 Solution. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader

Prelim 2 Solution. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader Prelim 2 CS 2110, November 19, 2015, 7:30 PM 1 2 3 4 5 6 Total Question True Short Complexity Searching Trees Graphs False Answer Sorting Invariants Max 20 15 13 14 17 21 100 Score Grader The exam is closed

More information

CSE373 Winter 2014, Final Examination March 18, 2014 Please do not turn the page until the bell rings.

CSE373 Winter 2014, Final Examination March 18, 2014 Please do not turn the page until the bell rings. CSE373 Winter 2014, Final Examination March 18, 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 promptly

More information

CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators)

CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators) _ UWNetID: Lecture Section: A CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will give

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

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad - 500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name Course Code Class Branch DATA STRUCTURES ACS002 B. Tech

More information

CSE373 Fall 2013, Second Midterm Examination November 15, 2013

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

More information

ext Total Score /20 /20 /15 /20 /25 /5 Grader

ext Total Score /20 /20 /15 /20 /25 /5 Grader NAME: NETID: CS2110 Fall 2013 Prelim 2 November 21, 2013 Write your name and Cornell netid. There are 5 questions plus one extra-credit question on 10 numbered pages. Check now that you have all the pages.

More information

CSE wi Midterm Exam 2/8/18. Name UW ID #

CSE wi Midterm Exam 2/8/18. Name UW ID # Name UW ID # There are 11 questions worth a total of 120 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,

More information

XC Total Max Score Grader

XC Total Max Score Grader NAME: NETID: CS2110 Fall 2013, Prelim 1 Thursday Oct 10, 2013 (7:30-9:00p) The exam is closed book and closed notes. Do not begin until instructed. You have 90 minutes. Good luck! Write your name and Cornell

More information

Prelim 2, CS2110. SOLUTION

Prelim 2, CS2110. SOLUTION Prelim 2, CS2110. SOLUTION 7:30 PM, 25 April 2017 1. Name (1 point) Write your name and NetID at the top of every page of this exam. 2. Short Answer (26 points.) (a) Asymptotic complexity. 8 points. Be

More information

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the elements may locate at far positions

More information

void insert( Type const & ) void push_front( Type const & )

void insert( Type const & ) void push_front( Type const & ) 6.1 Binary Search Trees A binary search tree is a data structure that can be used for storing sorted data. We will begin by discussing an Abstract Sorted List or Sorted List ADT and then proceed to describe

More information

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

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

More information

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

Prelim 2 SOLUTION. 5:30 PM, 25 April Total Question Name Short Search/ Collections Trees Graphs Prelim 2 SOLUTION 5:30 PM, 25 April 2017 1 2 3 4 5 6 Total Question Name Short Search/ Collections Trees Graphs answer sort stuff Max 1 26 18 15 20 20 100 Score Grader 1. Name (1 point) Write your name

More information

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

York University AK/ITEC INTRODUCTION TO DATA STRUCTURES. Final Sample II. Examiner: S. Chen Duration: Three hours York University AK/ITEC 262 3. INTRODUCTION TO DATA STRUCTURES Final Sample II Examiner: S. Chen Duration: Three hours This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g.

More information

CS 307 Final Spring 2009

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

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

CSE373 Winter 2014, Final Examination March 18, 2014 Please do not turn the page until the bell rings.

CSE373 Winter 2014, Final Examination March 18, 2014 Please do not turn the page until the bell rings. CSE373 Winter 2014, Final Examination March 18, 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 promptly

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

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

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Name: Email address: Quiz Section: CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will

More information

CSE 373 Spring Midterm. Friday April 21st

CSE 373 Spring Midterm. Friday April 21st CSE 373 Spring 2006 Data Structures and Algorithms Midterm Friday April 21st NAME : Do all your work on these pages. Do not add any pages. Use back pages if necessary. Show your work to get partial credit.

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

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

CSC 421: Algorithm Design & Analysis. Spring 2015

CSC 421: Algorithm Design & Analysis. Spring 2015 CSC 421: Algorithm Design & Analysis Spring 2015 Divide & conquer divide-and-conquer approach familiar examples: merge sort, quick sort other examples: closest points, large integer multiplication tree

More information

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

CSE 143 Final Exam Part 1 - August 18, 2011, 9:40 am CSE 143 Final Exam Part 1 - August 18, 2011, 9:40 am Name Student ID # Section TA Name The exam is closed book, closed notes, closed devices, except that you may have a 5x8 card with handwritten notes

More information

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course : Advanced Java Concepts + Additional Questions from Earlier Parts of the Course 1. Given the following hierarchy: class Alpha {... class Beta extends Alpha {... class Gamma extends Beta {... In what order

More information

COMP Data Structures

COMP Data Structures COMP 2140 - Data Structures Shahin Kamali Topic 5 - Sorting University of Manitoba Based on notes by S. Durocher. COMP 2140 - Data Structures 1 / 55 Overview Review: Insertion Sort Merge Sort Quicksort

More information

SOLUTIONS. COMP103 Introduction to Data Structures and Algorithms

SOLUTIONS. COMP103 Introduction to Data Structures and Algorithms T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2011 MID YEAR COMP103 Introduction to Data

More information

CS171 Final Practice Exam

CS171 Final Practice Exam CS171 Final Practice Exam Name: You are to honor the Emory Honor Code. This is a closed-book and closed-notes exam. You have 150 minutes to complete this exam. Read each problem carefully, and review your

More information

CSE373 Fall 2013, Final Examination December 10, 2013 Please do not turn the page until the bell rings.

CSE373 Fall 2013, Final Examination December 10, 2013 Please do not turn the page until the bell rings. CSE373 Fall 2013, Final Examination December 10, 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 promptly

More information

Spring 2018 Mentoring 8: March 14, Binary Trees

Spring 2018 Mentoring 8: March 14, Binary Trees CSM 6B Binary Trees Spring 08 Mentoring 8: March 4, 08 Binary Trees. Define a procedure, height, which takes in a Node and outputs the height of the tree. Recall that the height of a leaf node is 0. private

More information

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures Final Examination (17 pages) Instructor: Douglas Harder April 14, 2004 9:00-12:00 Name (last,

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

Sorting. CSE 143 Java. Insert for a Sorted List. Insertion Sort. Insertion Sort As A Card Game Operation. CSE143 Au

Sorting. CSE 143 Java. Insert for a Sorted List. Insertion Sort. Insertion Sort As A Card Game Operation. CSE143 Au CSE 43 Java Sorting Reading: Ch. 3 & Sec. 7.3 Sorting Binary search is a huge speedup over sequential search But requires the list be sorted Slight Problem: How do we get a sorted list? Maintain the list

More information

ECE242 Data Structures and Algorithms Fall 2008

ECE242 Data Structures and Algorithms Fall 2008 ECE242 Data Structures and Algorithms Fall 2008 2 nd Midterm Examination (120 Minutes, closed book) Name: Student ID: Question 1 (10) 2 (20) 3 (25) 4 (10) 5 (15) 6 (20) Score NOTE: Any questions on writing

More information

Solution to CSE 250 Final Exam

Solution to CSE 250 Final Exam Solution to CSE 250 Final Exam Fall 2013 Time: 3 hours. December 13, 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

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

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

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

CSE 143, Winter 2009 Final Exam Thursday, March 19, 2009 CSE 143, Winter 2009 Final Exam Thursday, March 19, 2009 Personal Information: Name: Section: Student ID #: TA: You have 110 minutes to complete this exam. You may receive a deduction if you keep working

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

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

Quiz 1 Solutions. (a) f(n) = n g(n) = log n Circle all that apply: f = O(g) f = Θ(g) f = Ω(g)

Quiz 1 Solutions. (a) f(n) = n g(n) = log n Circle all that apply: f = O(g) f = Θ(g) f = Ω(g) Introduction to Algorithms March 11, 2009 Massachusetts Institute of Technology 6.006 Spring 2009 Professors Sivan Toledo and Alan Edelman Quiz 1 Solutions Problem 1. Quiz 1 Solutions Asymptotic orders

More information

Binary Trees: Practice Problems

Binary Trees: Practice Problems Binary Trees: Practice Problems College of Computing & Information Technology King Abdulaziz University CPCS-204 Data Structures I Warmup Problem 1: Searching for a node public boolean recursivesearch(int

More information

2.2 Syntax Definition

2.2 Syntax Definition 42 CHAPTER 2. A SIMPLE SYNTAX-DIRECTED TRANSLATOR sequence of "three-address" instructions; a more complete example appears in Fig. 2.2. This form of intermediate code takes its name from instructions

More information

Prelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer

Prelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer Prelim 2 CS 2110, November 20, 2014, 7:30 PM 1 2 3 4 5 Extra Total Question True/False Short Answer Complexity Induction Trees Graphs Extra Credit Max 20 10 15 25 30 5 100 Score Grader The exam is closed

More information

COMP3121/3821/9101/ s1 Assignment 1

COMP3121/3821/9101/ s1 Assignment 1 Sample solutions to assignment 1 1. (a) Describe an O(n log n) algorithm (in the sense of the worst case performance) that, given an array S of n integers and another integer x, determines whether or not

More information

CS 125 Practice Final Exam Solutions SOLUTION SET

CS 125 Practice Final Exam Solutions SOLUTION SET SOLUTION SET Practice exam questions are intended to represent the types and difficulty level of questions you should expect to encounter on the real final exam. However, since one of the main goals of

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

COMP 250 Fall recurrences 2 Oct. 13, 2017

COMP 250 Fall recurrences 2 Oct. 13, 2017 COMP 250 Fall 2017 15 - recurrences 2 Oct. 13, 2017 Here we examine the recurrences for mergesort and quicksort. Mergesort Recall the mergesort algorithm: we divide the list of things to be sorted into

More information

TREES Lecture 10 CS2110 Spring2014

TREES Lecture 10 CS2110 Spring2014 TREES Lecture 10 CS2110 Spring2014 Readings and Homework 2 Textbook, Chapter 23, 24 Homework: A thought problem (draw pictures!) Suppose you use trees to represent student schedules. For each student there

More information

Computer Science E-119 Fall Problem Set 4. Due prior to lecture on Wednesday, November 28

Computer Science E-119 Fall Problem Set 4. Due prior to lecture on Wednesday, November 28 Computer Science E-119 Fall 2012 Due prior to lecture on Wednesday, November 28 Getting Started To get the files that you will need for this problem set, log into nice.harvard.edu and enter the following

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 #17, Implementing Binary Search Trees John Ridgway April 2, 2015 1 Implementing Binary Search Trees Review: The BST Interface Binary search

More information

Test 2: CPS 103 Owen Astrachan November 19, 1993 Name: Honor code acknowledgement (signature) Problem 1 value 9 pts. grade Problem 2 12 pts. Problem 3

Test 2: CPS 103 Owen Astrachan November 19, 1993 Name: Honor code acknowledgement (signature) Problem 1 value 9 pts. grade Problem 2 12 pts. Problem 3 Test 2: CPS 103 Owen Astrachan November 19, 1993 Name: Honor code acknowledgement (signature) Problem 1 value 9 pts. grade Problem 2 12 pts. Problem 3 6 pts. Problem 4 12 pts. Problem 5 12 pts. Problem

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

EXAMINATIONS 2005 END-YEAR. COMP 103 Introduction to Data Structures and Algorithms

EXAMINATIONS 2005 END-YEAR. COMP 103 Introduction to Data Structures and Algorithms T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I ÎÍÏ V I C T O R I A UNIVERSITY OF WELLINGTON EXAMINATIONS 2005 END-YEAR COMP 103 Introduction to Data Structures and Algorithms Time Allowed:

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

CSE 332 Winter 2018 Final Exam (closed book, closed notes, no calculators)

CSE 332 Winter 2018 Final Exam (closed book, closed notes, no calculators) Name: Sample Solution Email address (UWNetID): CSE 332 Winter 2018 Final Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering.

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

Lecture 15 Binary Search Trees

Lecture 15 Binary Search Trees Lecture 15 Binary Search Trees 15-122: Principles of Imperative Computation (Fall 2017) Frank Pfenning, André Platzer, Rob Simmons, Iliano Cervesato In this lecture, we will continue considering ways to

More information

COMP 103 Introduction to Data Structures and Algorithms

COMP 103 Introduction to Data Structures and Algorithms T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:..................... EXAMINATIONS 2005 END-YEAR COMP 103 Introduction to Data

More information

CS 315 Data Structures Spring 2012 Final examination Total Points: 80

CS 315 Data Structures Spring 2012 Final examination Total Points: 80 CS 315 Data Structures Spring 2012 Final examination Total Points: 80 Name This is an open-book/open-notes exam. Write the answers in the space provided. Answer for a total of 80 points, including at least

More information

Question 0. (1 point) Write the correct ID of the section you normally attend on the cover page of this exam if you have not already done so.

Question 0. (1 point) Write the correct ID of the section you normally attend on the cover page of this exam if you have not already done so. CSE 143 Sp04 Midterm 2 Page 1 of 10 Reference information about some standard Java library classes appears on the last pages of the test. You can tear off these pages for easier reference during the exam

More information

Data Structures in Java

Data Structures in Java Data Structures in Java Lecture 9: Binary Search Trees. 10/7/015 Daniel Bauer 1 Contents 1. Binary Search Trees. Implementing Maps with BSTs Map ADT A map is collection of (key, value) pairs. Keys are

More information

Question Points Score

Question Points Score CS 453 Introduction to Compilers Midterm Examination Spring 2009 March 12, 2009 75 minutes (maximum) Closed Book You may use one side of one sheet (8.5x11) of paper with any notes you like. This exam has

More information