midterm2Spring02 - Points off 1 2 3 4 5 6 Total off Net...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Points off 1 2 3 4 5 6 Total off Net Score CS 307 – Midterm 2 – Spring 2002 Name____________________________________ Last 4 digits of SSN / Student ID ______________ Class Unique ID ___________________________ Instructions: 1. There are 6 questions on this test. 2. You will have 2 hours to complete the test. 3. You may not use a calculator on the test. 4. When code is required, write Java code. 5. The style guide is not in effect. 6. Ensure your answers are legible. 7. When writing code you may not use any methods or classes from the Java Standard Library except as noted and the System.out.print, System.out.println, and the equals method. 1. (2 points each, 20 points total) Java Mechanics and theory. If an error would occur answer "syntax error" or "runtime error" depending on what type of error it would be. A. What is the average case Big O for inserting N items into an initially empty Linked List that is to be maintained in sorted order? _____________________________________________________________________________ B. What is the Big O for deleting a node from the end of a singly linked list that has a head and tail reference? _____________________________________________________________________________ CS 307 – Midterm 2 – Spring 2002 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
C. Consider the following code from class M2: public static int stone(int n) { if(n <= 0) return 3; else return n + stone( n – 2); } What is printed out by the following code? System.out.println( M2.stone(8) ); _____________________________________________________________________________ D. Consider the following code from class M2: public static int mav(int m) { if(m <= 0) return 2; else return 2 + mav(m – 1) + mav(m – 2); } What is printed out by the following code? System.out.println( M2.mav(5) ); _____________________________________________________________________________ E. Given a positive integer N, what is the Big O of M2.mav( N ) from question 1.D? _____________________________________________________________________________ CS 307 – Midterm 2 – Spring 2002 2
Background image of page 2
F. Consider a queue of ints that uses a native array of ints, myContainer , to store the elements of the queue. myContainer starts with a capacity of 5. It is resized only when necessary. The queue uses wraparound as discussed in class. Draw myContainer and show its contents after the following code is executed. Be sure to clearly label the front and back elements of the queue . Queue q = new Queue();
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/30/2010 for the course CS 307 taught by Professor Scott during the Spring '08 term at University of Texas at Austin.

Page1 / 12

midterm2Spring02 - Points off 1 2 3 4 5 6 Total off Net...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online