Home > IB Computer Science 2017 > Binary Tree Task (HL only)

Binary Tree Task (HL only)

October 22, 2015 Leave a comment Go to comments

Create a BinaryTree class in Java. It should be a binary search tree with integers increasing from left to right.

You will need to create a Node class with a left and right child and an integer data field.

The binary tree will need the methods:

  • add(int)
  • preOrderPrint()
  • inOrderPrint()
  • postOrderPrint()

Deletion is hard so I won’t ask you to code it, but try to work out what the problem with deletion is.

Create a BinaryTreeDemo class that instantiates a BinaryTree object and populates it with random numbers. Call the print methods to check that it’s all working.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s