C++ program for creation and traversal of a Binary Tree

Wednesday, February 2nd, 2011  »  Posted By  »  Total 13 Comments

#include<iostream.h> #include<conio.h> #include<process.h> struct tree_node { tree_node *left; tree_node *right; int data; } ; class bst { tree_node *root; public: bst() { root=NULL; } int isempty() { return(root==NULL); } void insert(int item); void inordertrav(); void inorder(tree_node *); void postordertrav(); void postorder(tree_node *); void preordertrav(); void preorder(tree_node *); }; void bst::insert(int item) { tree_node *p=new tree_node; […]

C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem

Thursday, March 11th, 2010  »  Posted By  »  Total 2 Comments

/* Write a C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem */ #include<iostream> #include<conio.h> #include<stdio.h> using namespace std; #define MAX 10 int find(int i,int j); void print(int,int); int p[MAX],q[MAX],w[10][10],c[10][10],r[10][10],i,j,k,n,m; char idnt[7][10];   main() { cout << "enter the no, of identifiers"; cin >>n; cout <<"enter identifiers"; for(i=1;i<=n;i++) gets(idnt[i]); […]

C++ program that uses non-recursive functions to traverse a binary tree in Post-order

Thursday, March 11th, 2010  »  Posted By  »  Total 54 Comments

/* Write C++ program that uses non-recursive functions to traverse a binary tree in Post-order */ #include<iostream.h> #include<conio.h> #include<stdlib.h>   class node { public: class node *left; class node *right; int data; };   class tree: public node { public: int stk[50],top; node *root; tree() { root=NULL; top=0; } void insert(int ch) { node *temp,*temp1; […]

C++ program that uses non-recursive functions to traverse a binary tree in In-order

Thursday, March 11th, 2010  »  Posted By  »  Total 0 Comment

/* Write C++ program that uses non-recursive functions to traverse a binary tree in In-order */ #include<iostream> #include<conio.h> #include<stdlib.h> using namespace std; class node { public: class node *left; class node *right; int data; };   class tree: public node { public: int stk[50],top; node *root; tree() { root=NULL; top=0; } void insert(int ch) { […]

C++ program that uses non-recursive functions to traverse a binary tree in Pre-order

Thursday, March 11th, 2010  »  Posted By  »  Total 2 Comments

/* Write C++ program that uses non-recursive functions to traverse a binary tree in Pre-order */ #include<iostream> #include<conio.h> #include<stdlib.h> using namespace std; class node { public: class node *left; class node *right; int data; };   class tree: public node { public: int stk[50],top; node *root; tree() { root=NULL; top=0; } void insert(int ch) { […]

C++ program to perform Insert, Delete, Search an element into a binary search tree

Wednesday, March 10th, 2010  »  Posted By  »  Total 4 Comments

/* Write a C++ program to perform the following operations:
a) Insert an element into a binary search tree.
b) Delete an element from a binary search tree.
c) Search for a key element in a binary search tree. */

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: