spring2004final

spring2004final - 1.00 Introduction to Computers and...

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

View Full Document Right Arrow Icon
1.00 Introduction to Computers and Engineering Problem Solving Final Examination - May 19, 2004 Name: E-mail Address: TA: Section: You have 3 hours to complete this exam. For coding questions, you do not need to include comments, and you should assume that all necessary files have already been imported. Good luck! Question Points Question 1 / 10 Question 2 / 10 Question 3 / 20 Question 4 / 20 Question 5 /15 Question 6 / 25 Total / 100
Background image of page 1

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

View Full DocumentRight Arrow Icon
THIS PAGE INTENTIONALLY LEFT BLANK
Background image of page 2
Page 1 of 19 Question 1. Tree traversal (10 points) After several terms of 1.00, the TAs decided they were tired of the inorder and postorder traversals taught in the course. After much thought, they developed new, modified inorder and postorder traversals. These new traversals are: A modified inorder traversal performs the following, recursively: - Traverse the right subtree - Visit the node - Traverse the left subtree A modified postorder traversal performs the following, recursively: - Traverse the right subtree - Traverse the left subtree - Visit the node 3 99 33 22 66 11 55 a) If the tree shown is traversed in modified inorder, starting at the root of the tree, what is the sequence of nodes visited? Answer: b) If the tree shown is traversed in modified postorder, starting at the root of the tree, what is the sequence of nodes visited? Answer: 5 88 77 44
Background image of page 3

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

View Full DocumentRight Arrow Icon
Page 2 of 19 Question 2. Circular linked list (10 points) A circular linked list is a linked list in which the last node refers to the first node. By convention, first is a reference to the first node in the linked list. The program below builds a circular list and manipulates it. Your task is to predict the output at three stages in the program. Hint : Trace the program by drawing the linked list at intermediate steps (draw the list with the data and next fields for every node, and with the first and last references) public class CircularList { public static class Node { int data; Node next; Node (int d, Node n) { data = d; next = n; } } public static void main(String[] args) { int i; int N = 5, M = 3; // Step (a) Node first = new Node(1, null); first.next = first; Node last = first; // End of Step (a) // Step (b) for (i = 2; i<= N ; i++) { last.next = new Node (i,first); last= last.next; } // End of Step (b) // Step (c): What’s happening here? while (last!= last.next) { for (i=1; i<M; i++) last= last.next; last.next = last.next.next; } // End of Step (c)
Background image of page 4
Page 3 of 19 // Output the result System.out.println (last.data); } } // Draw the list after step (a) finishes // Draw the list after step (b) finishes // What is the final output from step (c)?
Background image of page 5

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

View Full DocumentRight Arrow Icon
Page 4 of 19 Question 3. Computing grade ranges (20 points) In order to assign overall letter grades for 1.00, the teaching staff needs to organize students’ numerical scores. First, the staff places all student scores into an
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 19

spring2004final - 1.00 Introduction to Computers and...

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

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