Unformatted text preview:

LAB 10 Data Structure Nadine ElHaddad S22107736 class Node int data Node left right public Node int item data item left right null class BinaryTree Node root public BinaryTree root null void insert int data root insertRec root data Node insertRec Node root int data if root null root new Node data return root if data root data root left insertRec root left data else if data root data root right insertRec root right data return root int size return size root int size Node node if node null return 0 else return size node left 1 size node right int height return height root int height Node node if node null return 0 else int leftHeight height node left int rightHeight height node right if leftHeight rightHeight return leftHeight 1 else return rightHeight 1 void printNodes printNodesRec root void printNodesRec Node root if root null printNodesRec root left System out print root data printNodesRec root right public class Lab10datastruc public static void main String args BinaryTree tree new BinaryTree tree insert 50 tree insert 30 tree insert 20 tree insert 40 tree insert 70 tree insert 60 tree insert 80 System out println Size of tree tree size System out println Height of tree tree height System out println Nodes in the tree tree printNodes


View Full Document

IIT Chicago-Kent CS 10001 - LAB 10 Data Structure

Download LAB 10 Data Structure
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LAB 10 Data Structure and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LAB 10 Data Structure and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?