Add to Favorites    Make Home Page 166 Online  
 Language Categories  
 Our Services  

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies


  • Java Data Structures - Contents


    Node Pool Nodes...

    A D V E R T I S E M E N T

    Attention: Free eWeek Magazine Subscription. Absolutely Free!

    Search Projects & Source Codes:

        As with everything else, there are TONS of ways to write exactly the same thing! With nodes, there is no exception. I prefer to implement node-pool nodes with integer children; where the integer points to the next child inside the node-pool array. This may not be the best Object Oriented way to do this, since it's binding the node-pool node to the node-pool tree. However, there are many other solutions to this, and many are more "elegant" than the one I'll be using here. So, if you don't like it, implement your own version!

        If you've paid close attention to the discussion about regular binary trees (somewhere in this document), you'll find this discussion of node-pool stuff pretty easy and similar to that "regular" stuff. Enough talk, lets go and write this node-pool node!

    public class pNodePoolTreeNode{
    
        private Object data;
        private int left;
        private int right;
    
        public pNodePoolTreeNode(){
            left = right = -1;
            data = null;
        }
        public pNodePoolTreeNode(int l,int r){
            left = l;
            right = r;
            data = null;
        }
        public Object getData(){
            return data;
        }
        public void setData(Object o){
            data = o;
        }
        public int getLeft(){
            return left;
        }
        public void setLeft(int l){
            left = l;
        }
        public int getRight(){
            return right;
        }
        public void setRight(int r){
            right = r;
        }
        public String toString(){
            return new String(data.toString());
        }
    }

        The code above is pretty much self explanatory (if it's not, take a look back at binary tree nodes section, and you'll figure it out). The only significant thing you should notice is that children of the node are now integers, instead of references to other node objects. Although, it later turns out that what these integer children are referencing are in fact nodes.

        Well, that was easy enough, are you ready to figure out how a tree actually manipulates these?


    Back to Table of Contents


    A D V E R T I S E M E N T




    Google Groups Subscribe to SourceCodesWorld - Techies Talk
    Email:

    Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

     Advertisements  

     Free Magazines

    Jobs & Career
    Freshers Jobs
    Jobs Newsletter
    Placement Papers
    Placement Papers
    GATE Preparation
    Analysis & Design Of Algo.
    Operating System
    Lexical Analysis
    GRE Preparation
    GRE Home
    1208 Antonyms Test
    5000 Word's List
    Top 100 Words' List
    Scholarships
    Top 100 CS Univ.
    Top 126 EE Univ.
    Tutorials
    Hardware Tutorial
    1500 Free eBooks
    XML Tutorial
    Webmaster Resources
    EzTraffic
    Articles
    Fun
    Send FREE SMS!
    SMS Jokes
    Love SMS
    Funny Jokes

    Google Search

    Google

    Source Codes World.com is a part of Vyom Network.

    Vyom Network : Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Delhi Info | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

    Sitemap | Privacy Policy
    Copyright ©2003-2006 Vyom Technosoft Pvt. Ltd., All Rights Reserved.
    Page URL: http://www.sourcecodesworld.com/articles/java/java-data-structures/Node_Pool_Nodes.asp


    Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions