Fa03Midterm2

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

This preview shows pages 1–3. Sign up to view the full content.

Points off 1 2 3 4 5 6 Total off Net Score CS 307 – Midterm 2 – Fall 2003 Name__________________________________________ UTEID login name _______________________________ Section Leader's Name ___________________________ Instructions: 1. There are 4 questions on this test. 2. You 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 except 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, 30 points total) Short answer. 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. Consider a Queue that is implemented using an ArrayList for its internal storage container. The ArrayList uses a native array of objects as its internal storage container. The first element of the List is always stored in element 0 of the native array. The Queue uses index 0 of the ArrayList as the front element of the queue and element listVar.size() – 1 as the back element. Given the above implementation of a Queue what is the average case Big O of the Queue's dequeue method? _____________________________________________________________________________ CS 307 – Midterm 2 – Fall 2003 1

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

View Full Document
B. Consider a Stack that is implemented using an ArrayList for its internal storage container. The ArrayList uses a native array of objects as its internal storage container. The first element of the List is always in element 0. When the container is full the ArrayList creates a new array that is 10 elements larger than the previous one and copies over elements. The Stack considers the last element in the List as its top item. Given the above implementation of a Queue what is the average case Big O of the Stack's push method? C. What is the average case Big O of the following code? N is a parameter and is guaranteed to be > 0. int total = 0; for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) for(int k = 0; k < N; k += 3) total += i + j + k; _____________________________________________________________________________ D. What is the average case Big O of the following code? N is a parameter and is guaranteed to be > 0. int total = 0;
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.

### Page1 / 11

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

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

View Full Document
Ask a homework question - tutors are online