Fa04Final - Points off 1 2 3 4 5 Total off Net Score Exam...

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 Exam # CS 307 – Final – Fall 2004 Name__________________________________________ UTEID login name _______________________________ Section Leader's Name ___________________________ Instructions: 1. Please turn off your cell phones. 2. There are 5 questions on this 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. The style guide is not in effect except where noted. 7. Efficiency is not graded except where noted. 8. Ensure your answers are legible. 9. 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, the equals method, and native arrays of primitives, Strings and other data types allowed by the question. 10. You may add helper methods if you wish when answering coding questions. 11. When answering coding questions assume the preconditions of the methods are met 1. (2 points each, 30 points total) Short answer. Place your answers on the attached answer sheet at the end of the exam. If the code has a syntax error answer syntax error. If the code would result in a runtime error answer runtime error. If the code will not complete due to an infinite loop, answer infinite loop. 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 has a Big O of O(N^3). On this test I want the most precise 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 naïve insertion algorithm.) The tree is initially empty. Draw the resulting tree. 32, 5, 4, 74, 31 CS 307 – Final – Fall 2004 1
Image of page 1

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

View Full Document Right Arrow Icon
For parts B - F 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. What is the output of a level order traversal of the above tree? F. Is the binary tree from parts B, C, and D a binary search tree? CS 307 – Final – Fall 2004 2 root of tree 52 25 9 5 72 75 70 30
Image of page 2
Consider the following Queue class that holds ints void enqueue (int item) Add this item to the back of the this Queue. The item becomes the last element of the Queue int front ( ) Returns the first element of the Queue, that is the one that has been present the longest. int dequeue ( ) Remove and returns the first element of the Queue, that is the one that has been present the longest.
Image of page 3

Info iconThis 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