Help with Tertiary trees?!?!

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2004
Posts: 2
Reputation: RichyBoomstick is an unknown quantity at this point 
Solved Threads: 0
RichyBoomstick RichyBoomstick is offline Offline
Newbie Poster

Help with Tertiary trees?!?!

 
0
  #1
Nov 9th, 2004
I'm going to use a tertiary tree to navigate through a series of photos. This will hopefully allow someone to "walk" through these photos as if on a tour.

I was wondering if anybody had any advice on tertiary trees, do I just construct them as you would a binary tree? Do I just add another child node to the tree to make it have three children? Am I just talking nonsense?

If anybody can help me it would be greatly appreciated.

Much obliged :cheesy:
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,734
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 738
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Help with Tertiary trees?!?!

 
0
  #2
Nov 10th, 2004
>Am I just talking nonsense?
Nope, those are all very good questions.

>do I just construct them as you would a binary tree?
Most likely not if what you're used to are binary search trees. The strict ordering of less than/greater than is what makes binary search trees work, and modifying that to work with three way paths typically results in a multiway tree of order 3 rather than a true tertiary tree. The first thing you need to do is figure out how to order the data so that a simple insertion algorithm can be written.

>Do I just add another child node to the tree to make it have three children?
You add another child link to each node so that the potential number of children increases to three:
  1. class node {
  2. public type data;
  3. public node first, second, third;
  4. }
Or, because it's almost always easier to work with an array of links instead of separate variables:
  1. class node {
  2. public type data;
  3. public node[] link;
  4. }
Of course, variations exist such as an ArrayList or LinkedList. You can even hardcode your own linked list operations if you want.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC