{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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.
Image of page 1

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

View Full Document Right 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 .
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern