Topic — Add New » Posts Last Poster Freshness
Binary Tree to BST 15 varadharajan 3 days

convert a binary tree to binary search tree inplace. We cant use any extra space.

Ancestor of two given leaf nodes 7 dead 1 week

Determine the first common ancestor of twi given leaf nodes in Binary Tree.

Build a Graph in C++ 3 scott 1 week

Determine if any given graph has a cycle or not and to list the vertices that constitute this cycle. Assume a graph of 6-7 vertices. You will need to allow the user to design the graph as he wants in other words ,the user will be able to decide if any given vertices will have an edge or not. Your program will then read the input graph traverse it and determine if it has a cycle or not and then if it has cycle it lists its vertices. A cycle is when you can start from one vertex and visit othe...

Find border of a binary tree 2 rao_555 3 weeks

We are given a binary search tree; we need to find out its border.

So, if the binary tree is

           10
       /         \
     50           150
    /  \            /    \
  25    75     200    20
 / \           /            / \
15 35    120      155 250

It should print out 50 25 15 35 120 155 250 20 150 10.

If the binary tree is

               10
           /         \
         50           150
        /    \         /
      25     75     200
   ...
Minimum/Maximum Sum path in A Binary Tree 11 1 month

Find and Print the Root to leaf path with minimum sum.Every node has a Integer value.No need to consider edge weight or no. of edges.Only 1 root-leaf path will be printed who has the minimum sum(i.e the sum of all nodes including the root and the leaf)

How to find the center of a binary tree 3 harjitmeister 2 months

Given a binary tree, you have to find the center of the binary tree. It was asked me by amazon.

[closed] trees 5 kartik 3 months

given a binary tree where each node has positive and negative values, at each node store the sum of the left
and right sub trees.
ex:
10
-2 6
8 -4 7 5

output:
20(4-2+12+6)
...

Amazon Banglore Online Written 6 atul007 3 months

You are given a function printKDistanceNodes which takes in a root node of a binary tree, a start node and an integer K. Complete the function to print the value of all the nodes (one-per-line) which are a K distance from the given start node in sorted order. Distance can be upwards or downwards.

Tree Helical order traversal 2 kartik 3 months

Any body, give a program / logic to traverse a tree in helical order

ex:
tree:
1
2 3
4 5 6 7

Out Put:
1 2 3 7 6 5 4 or 1 3 2 4 5 6 7

Binar Tree to Double Linked List (circular) Conversion 1 kasireddi 3 months
struct node {
   int data;
   struct node* left;
   struct node* right;
};
typedef struct node* Node;  

//root: Current tree node
//prev: this pointer should have the address of in-order predecessor of root
//head: this denoted head of final link list
void treeToDoublyList(Node root, Node & prev, Node & head)
{
   if (!root) return;
   treeToDoublyList(root->left, prev, head);  

   // current node's left points to previous node
   root->left = prev;
   if (prev)
       prev-...
Traversal of binary search trees 4 3 months

I came across this problem about In-order Traversal of binary search tree without using a stack or recursion. Hint says to assume that testing of pointers for equality is a legitimate operation.I'm stuck finding the solution to this problem. Please give me some direction. I'm not looking for the code. Just give me the right direction.

New member, need help! 1 3 months
[closed] Convert a Sorterd Linked list in to a balanced Binary Search Tree 5 kartik 4 months

Given a Sorted Linked List.
Convert it in to any balanced Binary Search Tree.
Validate that the output is really a balanced tree.

Ex:
Input

1 --> 2 --> 3 --> 4--> 5 --> NULL

Output

                                        3
                                  /         \
                             1                 5
                               \              /
                                 2          4
Construction of BST from given Postorder Traversal 7 Santanu[COMPLEXGENE] 4 months

You are given the postorder traversal P of a <b>binary search tree</b> on the n elements 1, 2,….,n. You have to determine the unique binary search tree that has P as its postorder traversal.

Is is possible to uniquely determine BST? If no then give some example trees that can not be constructed. If yes then write a program with minimum time complexity.

Finding that Given Binary tree has mirror images at its root 2 lakshmi 4 months

In this We have to find out that the given tree has mirror image to its left to right..
here is the code..that works fine....Any other Suggestion.

#include<stdio.h>
#include<stdlib.h>
struct node
{
  int data;
  struct node *left;
  struct node *right;
}*root;
void traversal(struct node *n)
{
  if(n!=NULL)
  {
    //if(node->left!=NULL)
      traversal(n->left);
    printf("%d ",n->data);
    traversal(n->right);
  }
}
int m;
int compare1(struct node *...
Sum of nodes in a path 6 k53 4 months

Given a binary tree, devise a recursive algorithm to find if there is a path from root to a leaf with the given sum

Duplicate & insert left 2 kartik 4 months

Give an efficient algorithm to create duplicate node for each node in a binary tree and insert the duplicate node as the left node of the original node

Eg:   20
       /     \
     10       30
                                        20
                                      /   \
                                   20     30
                                 /         /
                               10       30
                              /
                            10