CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Mar 2011
    Posts
    14

    creating an optimal binary search tree

    I attach code for creating an optimal binary search tree...well after create table root[][] in dynamic programming - java, I success make
    ===============my output==========
    Root table:
    1 1 2 2 2
    2 2 2 4
    3 4 5
    4 5
    5
    k[2] is the root
    k[1] is the left child of node 2
    k[5] is the right child of node 2
    k[4] is the left child of node 5
    k[3] is the left child of node 4
    ================================

    but find difficulty create dummy keys like[The below is correct output must achieved-as Cormen MIT book shows the final output]:
    k[2] is the root
    k[1] is the left child of node 2
    d[0] is the left child of node 1
    d[1] is the right child of node 1
    k[5] is the right child of node 2
    k[4] is the left child of node 5
    k[3] is the left child of node 4
    d[2] is the left child of node 3
    d[3] is the right child of node 3
    d[4] is the right child of node 4
    d[5] is the right child of node 5

    can you help?
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured