Thread: Minimum height of a B-Tree

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    13

    Question Minimum height of a B-Tree

    Hi

    I know you use the formula Log2(N) to find the minimum height of a tree with N number nodes, but the problem is I don't know how to express Log2 ( that is a little two subscript) in programming language. Any help would be appreicated.

    thanks,
    FlatLost

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    536
    Quote Originally Posted by FlatLost
    Hi

    I know you use the formula Log2(N) to find the minimum height of a tree with N number nodes, but the problem is I don't know how to express Log2 ( that is a little two subscript) in programming language. Any help would be appreicated.

    thanks,
    FlatLost
    You calculate as follows:

    log2(N) = log(N)/log(2)

    Where log2(N) is "log to the base 2"

    log(N) and log(2) can be natural log or common log or log to any other base (both the same of course)

    Dave
    Last edited by Dave Evans; 04-01-2004 at 08:36 AM.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    13
    Thanks Dave for the help!!

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >to find the minimum height of a tree with N number nodes
    You need to be more specific. Is this a B-Tree (which is a different data structure that has differing height guarantees) or are you just abbreviating for a binary search tree?
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary Tree Search
    By C++Newbie in forum C++ Programming
    Replies: 7
    Last Post: 04-05-2011, 01:17 AM
  2. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 05:59 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. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. BST/Red and Black Tree
    By ghettoman in forum C++ Programming
    Replies: 0
    Last Post: 10-24-2001, 10:45 PM