Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8719381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:47:02+00:00 2026-06-13T06:47:02+00:00

The question is how to create a binary tree, given its ancestor matrix. I

  • 0

The question is how to create a binary tree, given its ancestor matrix. I found a cool solution at http://www.ritambhara.in/build-binary-tree-from-ancestor-matrics/. Problem is that it involves deleting rows and columns from the matrix. Now how do I do that? Can anybody suggest a pseudocode for this? Or, is there any better algo possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:47:03+00:00Added an answer on June 13, 2026 at 6:47 am

    You don’t have to actually delete the rows and columns. You can either flag them as deleted in some additional array, or you can make them all zeros, which I think will be effectively the same (actually, you’ll still need to know that they are removed, so you don’t choose them again in step 4.c – so, flagging the node as deleted should be good enough).

    Here are the modifications to the pseudocode from the page:

    4.b.

    used[temp] = true;
    for (i = 0 to N) 
        Sum[i] -= matrix[i][temp]; (aka decrement sum if temp is a predecessor of i)
        matrix[i][temp] = 0;
    

    4.c. Look for all rows for which Sum[i] == 0 and used[i] == false.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found an interesting algorithmic problem. We are given a binary tree which has
Question: Given a SQL string like CREATE VIEW TestView AS SELECT value1, value2 FROM
Given an inorder-traversal list, what's the best way to create a Binary Min/Max Heap?
I was given the following prompt: create a function: BoolAdd(A,B) that performs binary addition
I had a question about a Binary Sorted Tree design principle. I need to
I would like to create an iterator over the binary tree so as to
This question is related to a Binary Search tree. Here is the definition of
I am trying to create a complete binary tree using a linked list, instead
I've decided to take the advice in this question: create-excel-chart-programmatically-in-php and NOT attempt to
i got a question when create a javascript object, when one function invoking another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.