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 7754665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:22:02+00:00 2026-06-01T12:22:02+00:00

The textbook I’m learning from (Lafore) presents Red-Black Trees first, and does not include

  • 0

The textbook I’m learning from (Lafore) presents Red-Black Trees first, and does not include any pseudo-code, although the associated algorithms as presented seems fairly complex, with many unique cases.

Next he presents 2-3-4 Trees which seem to me much simpler to understand, and I would guess, to implement. He includes some actual Java code which is very clear. He seems to imply that 2-3-4 is easier to implement, and I would agree based on what I’ve seen so far.

Wikipedia, however, says the opposite… I think it is incorrect perhaps:

http://en.wikipedia.org/wiki/2-3-4_tree

2-3-4 trees are an isometry of red-black trees, meaning that they are
equivalent data structures. In other words, for every 2-3-4 tree,
there exists at least one red-black tree with data elements in the
same order. Moreover, insertion and deletion operations on 2-3-4 trees
that cause node expansions, splits and merges are equivalent to the
color-flipping and rotations in red-black trees. Introductions to
red-black trees usually introduce 2-3-4 trees first, because they are
conceptually simpler. 2-3-4 trees, however, can be difficult to
implement in most programming languages because of the large number of
special cases involved in operations on the tree. Red-black trees are
simpler to implement, so tend to be used instead.

Specifically, the part about the “larger number of special cases” seems quite backward to me (I think it is the RB which have the large number of special cases, not the 2-3-4). But, I’m still learning (and still honestly have not quite fully wrapped my head around the Red-Black Trees), so I’d love to hear other opinions.

As a sidenote… while I do agree with most of what Lafore says, I think it’s interesting he presented them in the opposite order compared to what Wikipedia says is common (2-3-4 before RB). I do think 2-3-4 first would make more sense since the RB is so much harder to conceptualize. Perhaps he chose that order because the RB was more closely related to BST’s which he had just finished in the previous chapter.

  • 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-01T12:22:04+00:00Added an answer on June 1, 2026 at 12:22 pm

    the part about the “larger number of special cases” seems quite backward to me (I think it is the RB which have the large number of special cases, not the 2-3-4)

    RB Trees can be implemented in a dozen or so lines, if you have pattern matching in your langugage:

    data Color = R | B
    data Tree a = E | T Color (Tree a) a (Tree a)
    
    balance :: Color -> Tree a -> a -> Tree a -> Tree a
    balance B (T R (T R a x b) y c          ) z d                               = T R (T B a x b) y (T B c z d)
    balance B (T R a           x (T R b y c)) z d                               = T R (T B a x b) y (T B c z d)
    balance B a                               x (T R (T R b y c) z d          ) = T R (T B a x b) y (T B c z d)
    balance B a                               x (T R b           y (T R c z d)) = T R (T B a x b) y (T B c z d)
    balance col a x b = T col a x b
    
    insert :: Ord a => a -> Tree a -> Tree a
    insert x s = T B a y b where
      ins E          =  T R E x E
      ins s@(T col a y b) 
        | x < y      =  balance col (ins a) y b
        | x > y      =  balance col a y (ins b)
        | otherwise  =  s
      T _ a y b = ins s
    

    This famous definition from Okasaki’s paper

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

Sidebar

Related Questions

I'm working on a program from my C++ textbook, and this this the first
I am practicing the exercises from my textbook but I could not get the
I have been learning Assembly and I have a question. The textbook presents the
I am still going through a beginners textbook but nowhere does it explain how
This is my first use of jquery outside of a textbook so of course
So I was looking at this code from a textbook: for (int i=0; i<N;
I recently made the Simpletron assignment from the Deitel and Deitel textbook. The Simpletron
I'm a student starting out on my first programming module. The textbook I'm working
From Java Malik textbook- determine if an number is divisible by 11.. Code Solution
I'm not so sure what that would imply and my textbook is dancing around

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.