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

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 – Fall 2002 Name____________________________________ Last 4 digits of SSN / Student ID ______________ Class Unique ID ___________________________ Instructions: 1. There are 5 questions on this test. 2. You have 3 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, expect where noted. 6. Efficiency is not graded except where noted. 7. Ensure your answers are legible. 8. 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. Recall that when asked for Big O your answer should be the most precise Big O function. For example Selection Sort has an average case Big O of O(N^2), but per the formal definition of Big O it is technically correct to say Selection Sort also has a Big O of O(N^3). On this test I want the most precise Big O function. (Closest without going under.) A. What is the Big O of the following code in terms of N? methodA has a Big O proportional to the magnitude of the argument it is sent. for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) methodA(N); _____________________________________________________________________________ CS 307 – Midterm 2 – Fall 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
B. What is the Big O of the following code in terms of N? int sum = 0; for(int i = 1; i < N; i = i * 2) for(int j = 0; j < N; j++) sum++; C. What is the Big O of the following code in terms of N? methodC always takes the same amount of time to complete. for(int i = N; i >= 0; i--) for(int j = i; j < N; j++) methodC(); _____________________________________________________________________________ D. Consider a Linked List class that uses doubly linked nodes and has a reference to the head and tail nodes. What is the average case Big O of removing the tail node of the Linked List? _____________________________________________________________________________ E. Given an ArrayList Class that uses a native array of objects, what is the average case Big O for removing an arbitrary element from the List? What does N in the Big O function represent? _____________________________________________________________________________ CS 307 – Midterm 2 – Fall 2002 2
Background image of page 2
F. Consider a Priority Queue. Each element inserted is given a priority and is placed in front of all items already in the queue that have a lower priority, but behind all items already in the queue that have a higher or equal priority. The Priority Queue is implemented using a Linked List. What is the average case Big O for enqueueing an item to the Priority Queue? What does N in the Big O function represent? _____________________________________________________________________________ G.
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 / 13

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

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