Docsity

CS303 Assignment 3: Binary Tree Algorithms and Search Property, Assignments of Computer Science

Toggle sidebar
bg1
CS303: Algorithms and Data Structures Fall 2007
Assignment 3 (written) Due Date: October 10, 2007 (during lab hours)
1. (50 points) Write two Java methods that take the root of a binary tree B and compute:
(a) The number of nodes in B
(b) The number of leaves in B
(c) What are the running times of your methods?
2. (50 points) Write a recursive Java method that tests whether a binary tree satisfies the search tree
property at every node, i.e. the left child node is less than (or equal to) the parent and the right child
node is greater than (or equal to) the parent.

Partial preview of the text

Download CS303 Assignment 3: Binary Tree Algorithms and Search Property and more Assignments Computer Science in PDF only on Docsity!

CS303: Algorithms and Data Structures Fall 2007 Assignment 3 (written) Due Date: October 10, 2007 (during lab hours)

  1. (50 points) Write two Java methods that take the root of a binary tree B and compute:

(a) The number of nodes in B (b) The number of leaves in B (c) What are the running times of your methods?

  1. (50 points) Write a recursive Java method that tests whether a binary tree satisfies the search tree property at every node, i.e. the left child node is less than (or equal to) the parent and the right child node is greater than (or equal to) the parent.