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

  • SEARCH
  • Home
  • 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 6194097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:14:16+00:00 2026-05-24T03:14:16+00:00

Suppose I have a binary search tree which, initially, satisfies all of the red-black

  • 0

Suppose I have a binary search tree which, initially, satisfies all of the red-black conditions and contains one node for every integer s in some set S. Next, I want to a new node; say a (which is not in S).

Is the result of this addition, after rebalancing, unique?

Put another way: is there only one way to rebalance a red-black tree after inserting a node?

I believe that they are not unique, although I offer no proof (and little confidence). I’m just wondering if someone more knowledgeable than myself might be so kind as to edify me?

  • 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-05-24T03:14:16+00:00Added an answer on May 24, 2026 at 3:14 am

    They are not unique.

    A simple proof would be to make a trivial algorithmic change, like check that we can change the root’s colour, and provide a case where that is still valid, for example:

        1-B
       /  \
     0-R  2-R
    

    add(3):

        1-B
       /  \
     0-B  2-B
            \
            3-R
    

    But the new algorithm could quite as easily yield

        1-R
       /  \
     0-B  2-B
            \
            3-R
    

    The root is a different colour but of course the trees are both still valid RB trees.

    This may seem a little trivial, but you can extend the idea (if you want a proof that is less trivial) to check for more than just the root. You could check O(1) levels deep to make a non-trivial but valid change, which would generate two different algorithms with the same running times.

    For example, check that the first 10 rows are full and black, and change the odd ones to red, would yield an additional constant work (i.e. O(1)), and a new algorithm.

    I should note that this is simply a proof of non-uniqueness, not a bound on the amount of non-uniqueness. I.e. something trivial like this is enough to prove the point, but it leaves the door open for RB algorithms that differ in more fundamental ways.

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

Sidebar

Related Questions

Suppose I have a balanced BST (binary search tree). Each tree node contains a
please , suppose i have this Binary Tree structure : Type TPMyTree = ^TMyTree;
Suppose I have a Makefile: all: $(BINARY) $(BINARY): $(OBJS) $(DEBUG_OBJS) #Link objects here $(OBJS):
Suppose I have a function which I have written as a binary-operator (binop), how
Suppose we have a binary file, that contains 32 bit numbers. Each 32bit number
I have a large tree that grows as my algorithm progresses. Each node contains
suppose I have an array of 10 ints, and I'm using binary search to
Suppose I have an application with the following code: public class Node { public
we have a C++ class which basically reads and writes vectors from a binary
I have an existing Mediawiki installation, for which I suppose I chose the MySQL

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.