944,154 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2485
  • Java RSS
Nov 9th, 2004
0

Help with Tertiary trees?!?!

Expand Post »
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:
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
RichyBoomstick is offline Offline
2 posts
since Nov 2004
Nov 10th, 2004
0

Re: Help with Tertiary trees?!?!

>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:
Java Syntax (Toggle Plain Text)
  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:
Java Syntax (Toggle Plain Text)
  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.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: calculations in java
Next Thread in Java Forum Timeline: creating a frame with four clocks





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC