Thread: Simple BST root insertion help

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    16

    Simple BST root insertion help

    Ok, this something which I can find on the web, but I'm kind of having trouble finding it. I'm learning about insertion in a binary search tree and rotation. This is where you have to rotate certain nodes in a tree to restore its shape after inserting a key into a tree.

    Given 31,42,59,44, and 36, use root insertion to insert into an initially empty tree. How would this be done?

    Given 50,34,56,78,98 (assuming this is traversing inorder), what would rootInsert(30) be?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Good timing. I just recently finished writing two tutorials on the subject of binary search trees and balancing. Take a look here. Though this one is the one you want.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem inserting into recursive BST
    By nfrandsen in forum C Programming
    Replies: 4
    Last Post: 09-13-2008, 07:03 PM
  2. Simple Linked List Error
    By guitarist809 in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2008, 10:15 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  5. BST/Red and Black Tree
    By ghettoman in forum C++ Programming
    Replies: 0
    Last Post: 10-24-2001, 10:45 PM