This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 Department of Computer Science and Engineering York University, Winter 2009 CSE 2011: Assignment 2 Due Date  Monday, May 11, by Noon ! Question 1 Binary Tree Traversal [15 points] The recursive implementations of Preorder and Inorder Traversal on a binary tree are provided below. void recursivePreorder (Node t) { if (t != null) { processNode(t); recursivePreorder (t.getLeft()); recursivePreorder (t.getRight()); } } void recursiveInorder (Node t) { if (t != null) { recursiveInorder (t.getLeft()); processNode(t); recursiveInorder (t.getRight()); } } Write a corresponding nonrecursive version of both above methods. (Hint: you are allowed to use an additional data structure, e.g. a stack or a queue.) Question 2 Binary Search Tree [15 points] In a binary search tree, in addition to the standard operations, we want to support an operation called findLargest (K), that takes integer K as an argument and returns the Kth largest key in the tree. In order to implement this method, we are allowed to add new attributes to BTNode class (see textbook, pp. 288). In your answer to this question, the following should be clearly explained: 1) what new attribute(s) we need to store at each node; 2) how these attributes should be used to perform the...
View
Full
Document
This note was uploaded on 10/30/2010 for the course CSE 2011 taught by Professor Nguyen during the Spring '10 term at Maple Springs Baptist Bible College.
 Spring '10
 nguyen
 Computer Science

Click to edit the document details