user2332475
user2332475

Reputation: 43

How to insert ascending numbers in a Red Black Tree

Can someone show me a step by step tutorial on how to insert numbers 1-10 in a Red-black tree?

I already tried doing so but I seem to be failing

*by insert I mean adding 1,2,3,4,5,6,7,8,9,10 in an initially empty rbt. thanks!

Upvotes: 1

Views: 2000

Answers (1)

Ami Tavory
Ami Tavory

Reputation: 76366

It depends on what you mean by " insert numbers 1-10 in a Red-black tree":

  • If you mean a legal tree obtained from these values, you can build a red-black tree from an ordered vector in linear time.

  • If you mean a visualization of 10 insert operations, you can try here.

Drawn with the help of the link mentioned here

Upvotes: 3

Related Questions