{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Sp06Final - Points off 1 2 3 4 5 Total off Net Score CS 307...

Info icon This 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 Total off Net Score CS 307 – Final – Spring 2006 Name__________________________________________ UTEID login name _______________________________ Circle your TA’s name: Chendi Vinod Instructions: 1. Please turn off your cell phones. 2. There are 5 questions on this test. The are 120 points on the test. 3. You have 3 hours to complete the test. 4. You may not use a calculator on the test. 5. When code is required, write Java code. 6. Ensure your answers are legible. 7. You may add helper methods if you wish when answering coding questions. 8. When answering coding questions assume the preconditions of the methods are met. 1. (2 points each, 40 points total) Short answer. Place you answers on the attached answer sheet. For questions that ask what is the output: If the code contains a syntax error or other compile error, answer “Compiler error”. If the code would result in a runtime error or exception answer “Runtime error”. If the code results in an infinite loop answer “Infinite loop”. On questions that ask for the Big O of a method or algorithm, recall that when asked for Big O your answer should be the most restrictive Big O function. For example Selection Sort has an expected 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). Give the most restrictive Big O function. (Closest without going under.) A. The following numbers are inserted, one at a time, in the order shown, into a binary search tree with no checks to ensure or maintain balance. (i.e. the traditional naïve insertion algorithm.) The tree is initially empty. Draw the resulting tree. 2, 4, 8, 16, 7 CS 307 – Final – Spring 2006 1
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
For parts B - E consider the following binary tree. For each question assume when a node is processed the value in the node is printed out by the statement: System.out.print( currentNode.getData() + " " ); B. What is the output of a preorder traversal of the above tree? C. What is the output of an inorder traversal of the above tree? D. What is the output of a postorder traversal of the above tree? E. Is the binary tree shown above a binary search tree? F. If 1000 elements are inserted one at a time into a binary search tree with no checks to ensure or maintain balance (i.e. the traditional naïve insertion algorithm.) what is the worst case height of the resulting tree? The actual number, not a Big O function. (The height of a tree is the number of links from the root to the deepest leaf. The height of the tree on this page is 2.) CS 307 – Final – Spring 2006 2 root of tree 10 5 39 12 5 51
Image of page 2
G. N elements are inserted one at a time into a Red Black tree. What is the worst case Big O of inserting all N items? H. In class we discussed the two ways Java allows the creation of generic data structures. The first method involves storing variables of type Object and relying on the fact that all objects are descendants of the Object class. The second method relies on parameterized data types, declaring the data type a particular data structure will hold when it is declared.
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
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