Thread: binary heap (build question)

  1. #1
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572

    binary heap (build question)

    OK, this is the question:
    a.Show the result of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, 2, one at a time into an inittially empty binary heap.
    b. Show the result of using the linear-time algorithm to build a binary heap using the same input.
    My answers are below...but I think I got confused on part b using bottom up percolateDown()...if anyone could quickly double check, I would greatly appreciate it.
    a. 1 3 2 6 7 5 4 15 14 12 9 10 11 13 8
    b. 1 3 2 12 6 4 8 15 14 9 7 5 11 13 10
    Last edited by axon; 03-01-2004 at 08:03 PM.

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  2. #2
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    hmm

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. insert into binary tree question..
    By transgalactic2 in forum C Programming
    Replies: 32
    Last Post: 11-18-2008, 03:21 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 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. Binary Tree Question
    By tar in forum C Programming
    Replies: 6
    Last Post: 09-26-2002, 01:22 AM
  5. Another binary file question
    By girlrobot in forum C Programming
    Replies: 5
    Last Post: 07-30-2002, 05:40 PM