Results 1 to 3 of 3
Thread: Binary tree help please
- 12-04-2012, 10:24 PM #1
Member
- Join Date
- Oct 2011
- Posts
- 30
- Rep Power
- 0
Binary tree help please
Hi, If I get given an array say [5,4,10,8,21,12,9,45,13,11,28]
I have to draw the complete binary tree for that. How would I know what goes at the top of the tree or where to start?
I have looked around and have found you go from left to right, could somebody check my answer please?
Java Code:5 / \ 4 10 / \ 8 21 \ / \ 9 12 45 / 13 / \ 11 28Last edited by sim18; 12-05-2012 at 06:05 AM.
- 12-04-2012, 10:30 PM #2
Senior Member
- Join Date
- Aug 2011
- Posts
- 116
- Rep Power
- 0
Re: Binary tree help please
It depends if you want to create a Binary Tree or a Binary Search Tree. The main difference between the two is with the BST, nodes to the left are greater than those to the right. This allows the tree to be efficiently searched. A BST can can have many different variations, from a completely balanced tree to a completely unbalanced tree depending on the root node value.
- 12-04-2012, 10:39 PM #3
Member
- Join Date
- Oct 2011
- Posts
- 30
- Rep Power
- 0
Re: Binary tree help please
I'm not sure it just says to draw that complete binary tree from the array. I then have to heapify the tree into a maximum heap. (I know how to do this) Then I will be inserting and removing nodes into the tree.
I am just checking if the tree is correct to begin with.
Thank you
Similar Threads
-
binary tree q
By stuckonjava in forum New To JavaReplies: 6Last Post: 05-21-2012, 05:58 PM -
Binary tree
By harmy in forum New To JavaReplies: 1Last Post: 02-03-2012, 08:46 AM -
Binary Tree Help - Find the largest sub-tree
By joshhazel in forum New To JavaReplies: 2Last Post: 01-30-2012, 02:08 AM -
Data Structures(Binary Search Tree to AVL Tree)ASAP pls
By jfAdik in forum Forum LobbyReplies: 0Last Post: 04-04-2010, 07:40 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks