2011Winter2009_Assignment2 - 1 Department of Computer...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 non-recursive 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 K-th 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.

Page1 / 3

2011Winter2009_Assignment2 - 1 Department of Computer...

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

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