Sp10m2 - Exam Number: Points off 1 2 3 4 5 Total off Net...

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

View Full Document Right Arrow Icon
CS 307 – Midterm 2 – Spring 2010 1 Exam Number: Points off 1 2 3 4 5 Total off Net Score CS 307 – Midterm 2 – Spring 2010 Name__________________________________________ UTEID login name _______________________________ TA's Name: Guillermo Reza Shyamala (Circle One) Instructions: 1. Please turn off your cell phones and other electronic devices. 2. There are 5 questions on this test. 3. You have 2 hours to complete the test. 4. You may not use a calculator on the test. 5. When code is required, write Java code. 6. When writing methods, assume the preconditions of the method are met. Do not write code to check the preconditions. 7. On coding question you may add helper methods if you wish. 8. After completing the test please turn it in to one of the test proctors and show them your UTID. 1. (2 points each, 30 points total) Short answer. Place you answers on the attached answer sheet. If the code contains a syntax error or other compile error, answer “compile error”. If the code would result in a runtime error / exception answer “Runtime error”. If the code results in an infinite loop answer “Infinite loop”. Recall that when asked for Big O your answer should be the most restrictive correct 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 correct to say Selection Sort also has a Big O of O(N 3 ) or O(N 4 ). I want the most restrictive correct Big O function. (Closest without going under.) A. Allen Rabinovich of Yahoo was a guest speaker in our class. What did Allen recommend about commenting code and programs you write for your own use? What was the basis of his recommendation? B. Allen is the Senior Architect for the Yahoo User Interface (YUI), a library of utilities and controls for building interactive web applications. The library is open source, meaning the source code is available for all programmers to use and extend in any way they wish . Allen made the claim that making YUI open source was actually a selfish thing for Yahoo to do. Explain, according to Allen, why making YUI open source is actually a selfish thing to do.
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS 307 – Midterm 2 – Spring 2010 2 C. What is returned by method c(5) ? public int c(int x){ if(x <= 0) return 3; else return x + c(x - 2); } D. What is output by the method call d("leakey") ? Recall the substring method: public String substring (int beginIndex) Returns a new string that is a substring of this string. The substring begins with the character at the specified index and extends to the end of this string. public void d(String s){ if(s.length() <= 2) System.out.print(s); else{ System.out.print(s.charAt(0)); d(s.substring(2)); System.out.print(s.charAt(s.length() - 1)); } } E. What is returned by the method call e(6); public int e(int x){ if(x <= 3) return x; else return 2 * x + e(x - 1) + e(x - 3); } F. What is the Big O of method f ? N = list.length . public int f(int[] list){
Background image of page 2
Image of page 3
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 / 17

Sp10m2 - Exam Number: Points off 1 2 3 4 5 Total off Net...

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

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