Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: B-Tree implementation

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default B-Tree implementation

    Hi, i have passed my exam from java programming, but i have to solve one more homework. Its about B-tree implementation :/ i dont really know, how to do it. I have a few lines of code but its no working properly.
    When i define the number of keys in node, i can add them, but if i add one more key, there is a null.pointer.exception. And with remove method i dont know

    Here is a task and my code.

    B-tree homework.txt
    Attachment 1736


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: B-Tree implementation

    Please post any questions you have and the code here on the forum.

    there is a null.pointer.exception.
    Please copy the full text of the error messages and past it here.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: B-Tree implementation

    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.elementData(ArrayList.java:371 )
    at java.util.ArrayList.get(ArrayList.java:384)
    at Node.getChild(Homework6.java:151)
    at Node.splitChild(Homework6.java:117)
    at Tree.add(Homework6.java:32)
    at Main.main(Homework6.java:193)
    Java Result: 1

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: B-Tree implementation

    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.elementData(ArrayList.java:371 )
    at java.util.ArrayList.get(ArrayList.java:384)
    at Node.getChild(Homework6.java:151)
    At line 151 the code calls the get() method with an invalid value of -1. Look at that line and see why the value is -1 and then backtrack in the code to see why the value is not a valid one.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Binary Search Tree inorder tree traversal
    By Maukkv in forum What's Wrong With My Code?
    Replies: 17
    Last Post: January 26th, 2013, 05:28 PM
  2. ArrayList implementation
    By meijuh in forum Collections and Generics
    Replies: 8
    Last Post: March 22nd, 2012, 01:03 PM
  3. Data Structures(Binary Search Tree to AVL Tree)ASAP
    By jfAdik in forum Algorithms & Recursion
    Replies: 2
    Last Post: April 5th, 2010, 03:58 AM
  4. B+ Tree implementation
    By programmer in forum Java Theory & Questions
    Replies: 2
    Last Post: November 15th, 2009, 05:47 PM
  5. Binary Search Tree implementation
    By Ceasar in forum Java Theory & Questions
    Replies: 3
    Last Post: October 9th, 2009, 12:23 AM