Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7814651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:15:36+00:00 2026-06-02T05:15:36+00:00

We have been asked to implement a Red Black Tree in java, but not

  • 0

We have been asked to implement a Red Black Tree in java, but not i’m exatcly sure how this is done. It would be really nice if anyone would comment on my node class for the r/b tree implementation. Here we go:

public class RBTnode {

public RBTnode(int key, RBTnode left, RBTnode right) {
    /* this is the constructor for a root node */
    color = 0;
    parent = null;
    key = this.key;
    left = this.left;
    right = this.right;
}

public RBTnode(int key, RBTnode left, RBTnode right, RBTnode parent, int color ) {
    key = this.key;
    color = this.color;
    left = this.left;
    right = this.right;
    parent = this.parent;

}

int color; // 0 black, 1 red
int key;
RBTnode parent;
RBTnode left;
RBTnode right;

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:15:38+00:00Added an answer on June 2, 2026 at 5:15 am

    I haven’t written a RB tree myself, but I am learning about them right now. From what I’ve been told, It seems that you need some adjustments.

    There are certain rules that you need to follow in order for a RB Tree to be a RB Tree:

    • Every node is RED or BLACK
    • Root node is always BLACK
    • New nodes are always RED
    • Both children of a RED node is BLACK.
    • Every path from a root to a leaf, or to a null child, must contain the same number of black nodes.

    That being said, I don’t think you need the second constructor because no matter what, you are always going to initialize a new node to RED.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure this question HAS to have been asked, but after searching through the
This has to have been asked before, but I haven't had any in searches.
I know similar questions have been asked, e.g. here , but having done a
I know this has been asked before but I have looked at every answer
I hope that this question has not been asked elsewhere, but I'm having difficulty
I have been asked to implement some email address validation on a web app
I have an old website and I've been asked to implement a small forum
This might have been asked a million times before or might be incredibly stupid
I know this question has been asked before, but none of the previous answers
I have been asked to implement a javascript floodlight tag onto my site which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.