C++ program to implement B-Trees

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

#include <iostream.h> #include <stdlib.h> #include <alloc.h> const int MAX = 4 ; const int MIN = 2 ; struct btnode { int count ; int value[MAX + 1] ; btnode *child[MAX + 1] ; } ; class btree { private : btnode *root ; public : btree( ) ; void insert ( int val ) […]

C++ program to implement AVL Tree & its Operations

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

#include <iostream.h> #include <stdlib.h> #include<constream.h> #define FALSE 0 #define TRUE 1 struct AVLNode { int data ; int balfact ; AVLNode *left ; AVLNode *right ; } ;   class avltree { private : AVLNode *root ; public : avltree( ) ; AVLNode* insert ( int data, int *h ) ; static AVLNode* buildtree ( […]

C++ program to implement Binary Search Tree(BST) and its Operations

Wednesday, February 2nd, 2011  »  Posted By  »  Total 1 Comment

#include <iostream.h> class btree { private : struct node { node *left ; char data ; node *right ; } *root ; char *arr ; int *lc ; int *rc ; public : btree ( char *a, int *l, int *r, int size ) ; void insert ( int index ) ; static node* buildtree […]

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 to implement circular queue using array

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

#include <iostream.h> class cqueue { private : int *arr ; int front, rear ; int MAX; public : cqueue( int maxsize = 10 ) ; void addq ( int item ) ; int delq( ) ; void display( ) ; } ; cqueue :: cqueue( int maxsize ) { MAX = maxsize ; arr = […]

C++ program to implement Quick sort Algorithm using class

Tuesday, February 1st, 2011  »  Posted By  »  Total 8 Comments

#include <iostream.h> const int MAX = 10 ; class array { private :   int arr[MAX] ; int count ; public :   array( ) ; void add ( int item ) ; int getcount( ) ; static int split ( int *, int, int ) ; void quiksort ( int lower, int upper ) […]

C++ rogram to implement merge sort

Tuesday, February 1st, 2011  »  Posted By  »  Total 2 Comments

#include <iostream.h> const int MAX = 5 ; class array { private : int *a ; int size ; int count ; public : array( ) ; array ( int sz ) ; void add ( int num ) ; void display( ) ; void merge_sort(int low,int high); void merge(int low,int mid,int high); ~array( ) […]

C++ program to implement Insertion sort using class

Tuesday, February 1st, 2011  »  Posted By  »  Total 2 Comments

#include <iostream.h> const int MAX = 10 ; class array { private : int arr[MAX] ; int count ; public : array( ) ; void add ( int item ) ; void sort( ) ; void display( ) ; } ; array :: array( ) { count = 0 ; for ( int i = […]

C++ programs to implement Graph Traversal Techniques – Depth First Search/Breadth First Search

Monday, January 31st, 2011  »  Posted By  »  Total 3 Comments

a)Program to implement Breadth first Search algorithm. #include<iostream.h> #include<conio.h> #include<stdlib.h> int cost[10][10],i,j,k,n,queue[10],front,rear,v,visit[10],visited[10]; void main() { int m; clrscr(); cout <<"enterno of vertices"; cin >> n; cout <<"ente no of edges"; cin >> m; cout <<"\nEDGES \n"; for(k=1;k<=m;k++) { cin >>i>>j; cost[i][j]=1; } cout <<"enter initial vertex"; cin >>v; cout <<"Visitied vertices\n"; cout << v; visited[v]=1; […]

C++ program to implement Queue using Linked Representation

Monday, January 31st, 2011  »  Posted By  »  Total 3 Comments

#include <iostream.h> template<class T> class Node { friend LinkedQueue<T>; private: T data; Node<T> *link; }; template<class T> class LinkedQueue { public: LinkedQueue() {front = rear = 0;} // constructor ~LinkedQueue(); // destructor int IsEmpty() const {return ((front) ? 0 : 1);} T First() const; // return first element T Last() const; // return last element […]

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

Free email signup

Email: