<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>download | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/download/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Mon, 31 Jan 2011 12:39:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>C++ program to implement B-Trees</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-b-trees/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-b-trees/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Wed, 02 Feb 2011 12:27:29 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[linked list]]></category>
		<category><![CDATA[B trees]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1277</guid>

					<description><![CDATA[<p>#include #include #include 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 ) ; int setval</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-b-trees/">C++ program to implement B-Trees</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#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 ) ;
		int setval ( int val, btnode *n, int *p, btnode **c ) ;
		static btnode * search ( int val, btnode *root, int *pos ) ;
		static int searchnode ( int val, btnode *n, int *pos ) ;
		void fillnode ( int val, btnode *c, btnode *n, int k ) ;
		void split ( int val, btnode *c, btnode *n,
				int k, int *y, btnode **newnode ) ;
		void del ( int val ) ;
		int delhelp ( int val, btnode *root ) ;
		void clear ( btnode *root, int k ) ;
		void copysucc ( btnode *root, int i ) ;
		void restore ( btnode *root, int i ) ;
		void rightshift ( int k ) ;
		void leftshift ( int k ) ;
		void merge ( int k ) ;
		void show( ) ;
		static void display ( btnode *root ) ;
		static void deltree ( btnode *root ) ;
		~btree( ) ;
} ;

btree :: btree( )
{
	root = NULL ;
}
void btree :: insert ( int val )
{
	int i ;
	btnode *c, *n ;
	int flag ;
	flag = setval ( val, root, &i, &c ) ;
	if ( flag )
	{
		n = new btnode ;
		n -> count = 1 ;
		n -> value[1] = i ;
		n -> child[0] = root ;
		n -> child[1] = c ;
		root = n ;
	}
}
int btree :: setval ( int val, btnode *n, int *p, btnode **c )
{
	int k ;
	if ( n == NULL )
	{
		*p = val ;
		*c = NULL ;
		return 1 ;
	}
	else
	{
		if ( searchnode ( val, n, &k ) )
			cout << endl << "Key value already exists." << endl ;
		if ( setval ( val, n -> child[k], p, c ) )
		{
			if ( n -> count < MAX )
			{
				fillnode ( *p, *c, n, k ) ;
				return 0 ;
			}
			else
			{
				split ( *p, *c, n, k, p, c ) ;
				return 1 ;
			}
		}
		return 0 ;
	}
}
btnode * btree :: search ( int val, btnode *root, int *pos )
{
	if ( root == NULL )
		return NULL ;
	else
	{
		if ( searchnode ( val, root, pos ) )
			return root ;
		else
			return search ( val, root -> child[*pos], pos ) ;
	}
}
int btree :: searchnode ( int val, btnode *n, int *pos )
{
	if ( val < n -> value[1] )
	{
		*pos = 0 ;
		return 0 ;
	}
	else
	{
		*pos = n -> count ;
		while ( ( val < n -> value[*pos] ) && *pos > 1 )
			( *pos )-- ;
		if ( val == n -> value[*pos] )
			return 1 ;
		else
			return 0 ;
	}
}
void btree :: fillnode ( int val, btnode *c, btnode *n, int k )
{
	int i ;
	for ( i = n -> count ; i > k ; i-- )
	{
		n -> value[i + 1] = n -> value[i] ;
		n -> child[i + 1] = n -> child[i] ;
	}
	n -> value[k + 1] = val ;
	n -> child[k + 1] = c ;
	n -> count++ ;
}
void btree :: split ( int val, btnode *c, btnode *n,
		int k, int *y, btnode **newnode )
{
	int i, mid ;

	if ( k <= MIN )
		mid = MIN ;
	else
		mid = MIN + 1 ;

	*newnode = new btnode ;

	for ( i = mid + 1 ; i <= MAX ; i++ )
	{
		( *newnode ) -> value[i - mid] = n -> value[i] ;
		( *newnode ) -> child[i - mid] = n -> child[i] ;
	}

	( *newnode ) -> count = MAX - mid ;
	n -> count = mid ;

	if ( k <= MIN )
		fillnode ( val, c, n, k ) ;
	else
		fillnode ( val, c, *newnode, k - mid ) ;

	*y = n -> value[n -> count] ;
	( *newnode ) -> child[0] = n -> child[n -> count] ;
	n -> count-- ;
}
void btree :: del ( int val )
{
	btnode * temp ;

	if ( ! delhelp ( val, root ) )
		cout << endl << "Value " << val << " not found." ;
	else
	{
		if ( root -> count == 0 )
		{
			temp = root ;
			root = root -> child[0] ;
			delete temp ;
		}
	}
}
int btree :: delhelp ( int val, btnode *root )
{
	int i ;
	int flag ;

	if ( root == NULL )
		return 0 ;
	else
	{
		flag = searchnode ( val, root, &i ) ;
		if ( flag )
		{
			if ( root -> child[i - 1] )
			{
				copysucc ( root, i ) ;
				flag = delhelp ( root -> value[i], root -> child[i] ) ;
				if ( !flag )
					cout << endl << "Value " << val << " not found." ;
			}
			else
				clear ( root, i ) ;
		}
		else
			flag = delhelp ( val, root -> child[i] ) ;
		if ( root -> child[i] != NULL )
		{
			if ( root -> child[i] -> count < MIN )
				restore ( root, i ) ;
		}
		return flag ;
	}
}
void btree :: clear ( btnode *root, int k )
{
	int i ;
	for ( i = k + 1 ; i <= root -> count ; i++ )
	{
		root -> value[i - 1] = root -> value[i] ;
		root -> child[i - 1] = root -> child[i] ;
	}
	root -> count-- ;
}
void btree :: copysucc ( btnode *root, int i )
{
	btnode *temp = root -> child[i] ;

	while ( temp -> child[0] )
		temp = temp -> child[0] ;

	root -> value[i] = temp -> value[1] ;
}
void btree :: restore ( btnode *root, int i )
{
	if ( i == 0 )
	{
		if ( root -> child [1] -> count > MIN )
			leftshift ( 1 ) ;
		else
			merge ( 1 ) ;
	}
	else
	{
		if ( i == root -> count )
		{
			if ( root -> child[i - 1] -> count > MIN )
				rightshift ( i ) ;
			else
				merge ( i ) ;
		}
		else
		{
			if ( root -> child[i - 1] -> count > MIN )
				rightshift ( i ) ;
			else
			{
				if ( root -> child[i + 1] -> count > MIN )
					leftshift ( i + 1 ) ;
				else
					merge ( i ) ;
			}
		}
	}
}
void btree :: rightshift ( int k )
{
	int i ;
	btnode *temp ;

	temp = root -> child[k] ;

	for ( i = temp -> count ; i > 0 ; i-- )
	{
		temp -> value[i + 1] = temp -> value[i] ;
		temp -> child[i + 1] = temp -> child[i] ;
	}

	temp -> child[1] = temp -> child[0] ;
	temp -> count++ ;
	temp -> value[1] = root -> value[k] ;
	temp = root -> child[k - 1] ;
	root -> value[k] = temp -> value[temp -> count] ;
	root -> child[k] -> child [0] = temp -> child[temp -> count] ;
	temp -> count-- ;
}
void btree :: leftshift ( int k )
{
	btnode *temp ;

	temp = root -> child[k - 1] ;
	temp -> count++ ;
	temp -> value[temp -> count] = root -> value[k] ;
	temp -> child[temp -> count] = root -> child[k] -> child[0] ;
	temp = root -> child[k] ;
	root -> value[k] = temp -> value[1] ;
	temp -> child[0] = temp -> child[1] ;
	temp -> count-- ;
	for ( int i = 1 ; i <= temp -> count ; i++ )
	{
		temp -> value[i] = temp -> value[i + 1] ;
		temp -> child[i] = temp -> child[i + 1] ;
	}
}
void btree :: merge ( int k )
{
	btnode *temp1, *temp2 ;
	temp1 = root -> child[k] ;
	temp2 = root -> child[k - 1] ;
	temp2 -> count++ ;
	temp2 -> value[temp2 -> count] = root -> value[k] ;
	temp2 -> child[temp2 -> count] = root -> child[0] ;
	for ( int i = 1 ; i <= temp1 -> count ; i++ )
	{
		temp2 -> count++ ;
		temp2 -> value[temp2 -> count] = temp1 -> value[i] ;
		temp2 -> child[temp2 -> count] = temp1 -> child[i] ;
	}
	for ( i = k ; i < root -> count ; i++ )
	{
		root -> value[i] = root -> value[i + 1] ;
		root -> child[i] = root -> child[i + 1] ;
	}
	root -> count-- ;
	delete temp1 ;
}
void btree :: show( )
{
	display ( root ) ;
}
void btree :: display ( btnode *root )
{
	if ( root != NULL )
	{
		for ( int i = 0 ; i < root -> count ; i++ )
		{
			display ( root -> child[i] ) ;
			cout << root -> value[i + 1] << "\t" ;
		}
		display ( root -> child[i] ) ;
	}
}
void btree :: deltree ( btnode *root )
{
	if ( root != NULL )
	{
		for ( int i = 0 ; i < root -> count ; i++ )
		{
			deltree ( root -> child[i] ) ;
			delete ( root -> child[i] ) ;
		}
		deltree ( root -> child[i] ) ;
		delete ( root -> child[i] ) ;
	}
}

btree :: ~btree( )
{
	deltree ( root ) ;
}

void main( )
{
	btree b ;
	int arr[ ] = { 27, 42, 22, 47, 32, 2, 51, 40, 13 } ;
	int sz = sizeof ( arr ) / sizeof ( int ) ;
	for ( int i = 0 ; i < sz ; i++ )
		b.insert ( arr[i] ) ;
	cout << "B-tree of order 5:" << endl ;
	b.show( ) ;
	b.del ( 22 ) ;
	b.del ( 11 ) ;
	cout << "\n\nB-tree after deletion of values:" << endl ;
	b.show( ) ;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-b-trees/">C++ program to implement B-Trees</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-b-trees/feed/</wfw:commentRss>
			<slash:comments>19</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program to implement AVL Tree &#038; its Operations</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-avl-tree-its-operations/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-avl-tree-its-operations/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Wed, 02 Feb 2011 12:23:37 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[AVL trees]]></category>
		<category><![CDATA[linked list]]></category>
		<category><![CDATA[operations]]></category>
		<category><![CDATA[traversal]]></category>
		<category><![CDATA[Binary Search Tree]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1275</guid>

					<description><![CDATA[<p>#include #include #include #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 ( AVLNode *root, int</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-avl-tree-its-operations/">C++ program to implement AVL Tree & its Operations</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#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 ( AVLNode *root, int data, int *h ) ;
		void display( AVLNode *root ) ;
		AVLNode* deldata ( AVLNode* root, int data, int *h ) ;
		static AVLNode* del ( AVLNode *node, AVLNode* root, int *h ) ;
		static AVLNode* balright ( AVLNode *root, int *h ) ;
		static AVLNode* balleft ( AVLNode* root, int *h ) ;
		void setroot ( AVLNode *avl ) ;
		~avltree( ) ;
		static void deltree ( AVLNode *root ) ;
} ;
avltree :: avltree( )
{
	root = NULL ;
}
AVLNode* avltree :: insert ( int data, int *h )
{
	root = buildtree ( root, data, h ) ;
	return root ;
}
AVLNode* avltree :: buildtree ( AVLNode *root, int data, int *h )
{
	AVLNode *node1, *node2 ;

	if ( root == NULL )
	{
		root = new AVLNode ;
		root -> data = data ;
		root -> left = NULL ;
		root -> right = NULL ;
		root -> balfact = 0 ;
		*h = TRUE ;
		return ( root ) ;
	}
	if ( data < root -> data )
	{
		root -> left = buildtree ( root -> left, data, h ) ;

		// If left subtree is higher
		if ( *h )
		{
			switch ( root -> balfact )
			{
				case 1 :
					node1 = root -> left ;
					if ( node1 -> balfact == 1 )
					{
						cout << "\nRight rotation." ;
						root -> left = node1 -> right ;
						node1 -> right = root ;
						root -> balfact = 0 ;
						root = node1 ;
					}
					else
					{
						cout << "\nDouble rotation, left then right." ;
						node2 = node1 -> right ;
						node1 -> right = node2 -> left ;
						node2 -> left = node1 ;
						root -> left = node2 -> right ;
						node2 -> right = root ;
						if ( node2 -> balfact == 1 )
							root -> balfact = -1 ;
						else
							root -> balfact = 0 ;
						if ( node2 -> balfact == -1 )
							node1 -> balfact = 1 ;
						else
							node1 -> balfact = 0 ;
						root = node2 ;
					}
					root -> balfact = 0 ;
					*h = FALSE ;
					break ;

				case 0 :
					root -> balfact = 1 ;
					break ;
				case -1 :
					root -> balfact = 0 ;
					*h = FALSE ;
			}
		}
	}

	if ( data > root -> data )
	{
		root -> right = buildtree ( root -> right, data, h ) ;

		if ( *h )
		{
			switch ( root -> balfact )
			{
				case 1 :
					root -> balfact = 0 ;
					*h = FALSE ;
					break ;
				case 0 :
					root -> balfact = -1 ;
					break ;
				case -1 :
					node1 = root -> right ;
					if ( node1 -> balfact == -1 )
					{
						cout << "\nLeft rotation." ;
						root -> right = node1 -> left ;
						node1 -> left = root ;
						root -> balfact = 0 ;
						root = node1 ;
					}
					else
					{
						cout << "\nDouble rotation, right then left." ;
						node2 = node1 -> left ;
						node1 -> left = node2 -> right ;
						node2 -> right = node1 ;
						root -> right = node2 -> left ;
						node2 -> left = root ;
						if ( node2 -> balfact == -1 )
							root -> balfact = 1 ;
						else
							root -> balfact = 0 ;
						if ( node2 -> balfact == 1 )
							node1 -> balfact = -1 ;
						else
							node1 -> balfact = 0 ;
						root = node2 ;
					}
					root -> balfact = 0 ;
					*h = FALSE ;
			}
		}
	}
	return ( root ) ;
}
void avltree :: display ( AVLNode* root )
{
	if ( root != NULL )
	{
		display ( root -> left ) ;
		cout << root -> data << "\t" ;
		display ( root -> right ) ;
	}
}
AVLNode* avltree :: deldata ( AVLNode *root, int data, int *h )
{
	AVLNode *node ;
	if ( root -> data == 13 )
		cout << root -> data ;
	if ( root == NULL )
	{
		cout << "\nNo such data." ;
		return ( root ) ;
	}
	else
	{
		if ( data < root -> data )
		{
			root -> left = deldata ( root -> left, data, h ) ;
			if ( *h )
				root = balright ( root, h ) ;
		}
		else
		{
			if ( data > root -> data )
			{
				root -> right = deldata ( root -> right, data, h ) ;
				if ( *h )
					root = balleft ( root, h ) ;
			}
			else
			{
				node = root ;
				if ( node -> right == NULL )
				{
					root = node -> left ;
					*h = TRUE ;
					delete ( node ) ;
				}
				else
				{
					if ( node -> left == NULL )
					{
						root = node -> right ;
						*h = TRUE ;
						delete ( node ) ;
					}
					else
					{
						node -> right = del ( node -> right, node, h ) ;
						if ( *h )
							root = balleft ( root, h ) ;
					}
				}
			}
		}
	}
	return ( root ) ;
}
AVLNode* avltree :: del ( AVLNode *succ, AVLNode *node, int *h )
{
	AVLNode *temp = succ ;

	if ( succ -> left != NULL )
	{
		succ -> left = del ( succ -> left, node, h ) ;
		if ( *h )
			succ = balright ( succ, h ) ;
	}
	else
	{
		temp = succ ;
		node -> data = succ -> data ;
		succ = succ -> right ;
		delete ( temp ) ;
		*h = TRUE ;
	}
	return ( succ ) ;
}
AVLNode* avltree :: balright ( AVLNode *root, int *h )
{
	AVLNode *temp1, *temp2 ;
	switch ( root -> balfact )
	{
		case 1 :
			root -> balfact = 0 ;
			break ;
		case 0 :
			root -> balfact = -1 ;
			*h  = FALSE ;
			break ;
		case -1 :
			temp1 = root -> right ;
			if ( temp1 -> balfact <= 0 )
			{
				cout << "\nLeft rotation." ;
				root -> right = temp1 -> left ;
				temp1 -> left = root ;
				if ( temp1 -> balfact == 0 )
				{
					root -> balfact = -1 ;
					temp1 -> balfact = 1 ;
					*h = FALSE ;
				}
				else
				{
					root -> balfact = temp1 -> balfact = 0 ;
				}
				root = temp1 ;
			}
			else
			{
				cout << "\nDouble rotation, right then left." ;
				temp2 = temp1 -> left ;
				temp1 -> left = temp2 -> right ;
				temp2 -> right = temp1 ;
				root -> right = temp2 -> left ;
				temp2 -> left = root ;
				if ( temp2 -> balfact == -1 )
					root -> balfact = 1 ;
				else
					root -> balfact = 0 ;
				if ( temp2 -> balfact == 1 )
					temp1 -> balfact = -1 ;
				else
					temp1 -> balfact = 0 ;
				root = temp2 ;
				temp2 -> balfact = 0 ;
			}
	}
	return ( root ) ;
}
AVLNode* avltree :: balleft ( AVLNode *root, int *h )
{
	AVLNode *temp1, *temp2 ;
	switch ( root -> balfact )
	{
		case -1 :
			root -> balfact = 0 ;
			break ;

		case 0 :
			root -> balfact = 1 ;
			*h = FALSE ;
			break ;

		case 1 :
			temp1 = root -> left ;
			if ( temp1 -> balfact >= 0 )
			{
				cout << "\nRight rotation." ;
				root -> left = temp1 -> right ;
				temp1 -> right = root ;

				if ( temp1 -> balfact == 0 )
				{
					root -> balfact = 1 ;
					temp1 -> balfact = -1 ;
					*h = FALSE ;
				}
				else
				{
					root -> balfact = temp1 -> balfact = 0 ;
				}
				root = temp1 ;
			}
			else
			{
				cout << "\nDouble rotation, left then right." ;
				temp2 = temp1 -> right ;
				temp1 -> right = temp2 -> left ;
				temp2 -> left = temp1 ;
				root -> left = temp2 -> right ;
				temp2 -> right = root ;
				if ( temp2 -> balfact == 1 )
					root -> balfact = -1 ;
				else
					root -> balfact = 0 ;
				if ( temp2-> balfact == -1 )
					temp1 -> balfact = 1 ;
				else
					temp1 -> balfact = 0 ;
				root = temp2 ;
				temp2 -> balfact = 0 ;
			}
	}
	return ( root ) ;
}
void avltree :: setroot ( AVLNode *avl )
{
	root = avl ;
}
avltree :: ~avltree( )
{
	deltree ( root ) ;
}


void avltree :: deltree ( AVLNode *root )
{
	if ( root != NULL )
	{
		deltree ( root -> left ) ;
		deltree ( root -> right ) ;
	}
	delete ( root ) ;
}
void main( )
{
	avltree at ;
	AVLNode *avl = NULL ;
	int h ;
	clrscr();
	avl = at.insert ( 20, &h ) ;
	at.setroot ( avl ) ;
	avl = at.insert ( 6, &h ) ;
	at.setroot ( avl ) ;
	avl = at.insert ( 29, &h ) ;
	at.setroot ( avl ) ;
	avl = at.insert ( 5, &h ) ;
	at.setroot ( avl ) ;
	avl = at.insert ( 12, &h ) ;
	at.setroot ( avl ) ;
	avl = at.insert ( 25, &h ) ;
	at.setroot ( avl ) ;
	avl = at.insert ( 32, &h ) ;
	at.setroot ( avl ) ;
	avl = at.insert ( 10, &h ) ;
	at.setroot ( avl ) ;
	avl = at.insert ( 15, &h ) ;
	at.setroot ( avl ) ;
	avl = at.insert ( 27, &h ) ;
	at.setroot ( avl ) ;
	avl = at.insert ( 13, &h ) ;
	at.setroot ( avl ) ;
	cout << endl << "AVL tree:\n" ;
	at.display ( avl ) ;
	avl = at.deldata ( avl, 20, &#038;h ) ;
	at.setroot ( avl ) ;
	avl = at.deldata ( avl, 12, &#038;h ) ;
	at.setroot ( avl ) ;
	cout << endl << "AVL tree after deletion of a node:\n" ;
	at.display ( avl ) ;
	getch();
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-avl-tree-its-operations/">C++ program to implement AVL Tree & its Operations</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-avl-tree-its-operations/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program to implement Binary Search Tree(BST) and its Operations</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-binary-search-treebst-and-its-operations/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-binary-search-treebst-and-its-operations/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Wed, 02 Feb 2011 12:21:33 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[BST]]></category>
		<category><![CDATA[Binary Search Tree]]></category>
		<category><![CDATA[traversal]]></category>
		<category><![CDATA[linked list]]></category>
		<category><![CDATA[C Programs]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1273</guid>

					<description><![CDATA[<p>#include 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 (</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-binary-search-treebst-and-its-operations/">C++ program to implement Binary Search Tree(BST) and its Operations</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#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 ( char *a, int *l, int *r, int index ) ;
		void display( ) ;
		static void inorder ( node *sr ) ;
		~btree( ) ;
		static void del ( node *sr ) ;
} ;
btree :: btree ( char *a, int *l, int *r, int size )
{
	root = NULL ;
	arr = new char[size] ;
	lc = new int[size] ;
	rc = new int[size] ;
	for ( int i = 0 ; i < size ; i++ )
	{
		* ( arr + i ) = * ( a + i ) ;
		* ( lc + i ) = * ( l + i ) ;
		* ( rc + i ) = * ( r + i ) ;
	}
}
void btree :: insert ( int index )
{
	root = buildtree ( arr, lc, rc, index ) ;
}
node* btree :: buildtree ( char *a, int *l, int *r, int index )
{
	node *temp = NULL ;
	if ( index != -1 )
	{
		temp = new node ;
		temp -> left = buildtree ( a, l, r, * ( l + index ) ) ;
		temp -> data = * ( a + index ) ;
		temp -> right = buildtree ( a, l, r, * ( r + index ) ) ;
	}
	return temp ;
}
void btree :: display( )
{
	inorder ( root ) ;
}
void btree :: inorder ( node *sr )
{
	if ( sr != NULL )
	{
		inorder ( sr -> left ) ;
		cout << sr -> data << "\t" ;
		inorder ( sr -> right ) ;
	}
}
btree :: ~btree( )
{
	delete arr ;
	delete lc ;
	delete rc ;
	del ( root ) ;
}
void btree :: del ( node *sr )
{
	if ( sr != NULL )
	{
		del ( sr -> left ) ;
		del ( sr -> right ) ;
	}
	delete sr ;
}
void main( )
{
	char a[ ] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', '\0', '\0', 'H' } ;
	int  l[ ] = {  1,   3,   5,   -1,   9,  -1,  -1,   -1,   -1,  -1 } ;
	int  r[ ] = {  2,   4,   6,   -1,  -1,  -1,  -1,   -1,   -1,  -1 } ;
	int sz = sizeof ( a ) ;
	btree bt ( a, l, r, sz ) ;
	bt.insert( 0 ) ;
	cout << "\nIn-order Traversal: " << endl ;
	bt.display( ) ;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-binary-search-treebst-and-its-operations/">C++ program to implement Binary Search Tree(BST) and its Operations</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-binary-search-treebst-and-its-operations/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program for creation and traversal of a Binary Tree</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-for-creation-and-traversal-of-a-binary-tree/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-for-creation-and-traversal-of-a-binary-tree/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Wed, 02 Feb 2011 12:19:34 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[traversal]]></category>
		<category><![CDATA[linked list]]></category>
		<category><![CDATA[binary tree]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[C Programs]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1271</guid>

					<description><![CDATA[<p>#include #include #include 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;</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-for-creation-and-traversal-of-a-binary-tree/">C++ program for creation and traversal of a Binary Tree</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#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;
	tree_node *parent;
	p->data=item;
	p->left=NULL;
	p->right=NULL;
	parent=NULL;
	if(isempty())
		root=p;
	else
	{
		tree_node *ptr;
		ptr=root;
		while(ptr!=NULL)
		{
			parent=ptr;
			if(item>ptr->data)		
				ptr=ptr->right;
			else
				ptr=ptr->left;
		}	
		if(item<parent->data)
			parent->left=p;
		else
			parent->right=p;
	}
}
void bst::inordertrav()
{
	inorder(root);
}
void bst::inorder(tree_node *ptr)
{
	if(ptr!=NULL)
	{
		inorder(ptr->left);
		cout<<"  "<<ptr->data<<"     ";
		inorder(ptr->right);
	}
}
void bst::postordertrav()
{
	postorder(root);
}
void bst::postorder(tree_node *ptr)
{
	if(ptr!=NULL)
	{
		postorder(ptr->left);
		postorder(ptr->right);
		cout<<"  "<<ptr->data<<"     ";
	}
}
void bst::preordertrav()
{
	preorder(root);
}
void bst::preorder(tree_node *ptr)
{
	if(ptr!=NULL)
	{
		cout<<"  "<<ptr->data<<"     ";
		preorder(ptr->left);
		preorder(ptr->right);
	}
}
void main()
{
	bst b;
	b.insert(52);
	b.insert(25);
	b.insert(50);
	b.insert(15);
	b.insert(40);
	b.insert(45);
	b.insert(20); cout<<"inorder"<<endl;
	b.inordertrav();
	cout<<endl<<"postorder"<<endl;
	b.postordertrav();
	cout<<endl<<"preorder"<<endl;
	b.preordertrav();
	getch();
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-for-creation-and-traversal-of-a-binary-tree/">C++ program for creation and traversal of a Binary Tree</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-for-creation-and-traversal-of-a-binary-tree/feed/</wfw:commentRss>
			<slash:comments>16</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program to implement circular queue using array</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-implement-circular-queue-using-array/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-implement-circular-queue-using-array/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Wed, 02 Feb 2011 12:16:03 +0000</pubDate>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[circular queue]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[C Programs]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1269</guid>

					<description><![CDATA[<p>#include 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 = new</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-implement-circular-queue-using-array/">C++ program to implement circular queue using array</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#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 = new int [ MAX ];
	front = rear = -1 ;
	for ( int i = 0 ; i < MAX ; i++ )
		arr[i] = 0 ;
}
void cqueue :: addq ( int item )
{
	if ( ( rear + 1 ) % MAX == front )
	{
		cout << "\nQueue is full" ;
		return ;
	}
	rear = ( rear + 1 ) % MAX;
	arr[rear] = item ;
	if ( front == -1 )
		front = 0 ;
}
int cqueue :: delq( )
{
	int data ;
	if ( front == -1 )
	{
		cout << "\nQueue is empty" ;
		return NULL ;
	}

	data = arr[front] ;
	arr[front] = 0 ;
	if ( front == rear )
	{
		front = -1 ;
		rear = -1 ;
	}
	else
		front = ( front + 1 ) % MAX;
	return data ;
}
void cqueue :: display( )
{
	cout << endl ;
	for ( int i = 0 ; i < MAX ; i++ )
		cout << arr[i] << "  " ;
	cout << endl ;
}
void main( )
{
	cqueue a ( 10 ) ;
	a.addq ( 14 ) ;
	a.addq ( 22 ) ;
	a.addq ( 13 ) ;
	a.addq ( -6 ) ;
	a.addq ( 25 ) ;
	cout << "\nElements in the circular queue: " ;
	a.display( ) ;
	int i = a.delq( ) ;
	cout << "Item deleted: " << i ;
	i = a.delq( ) ;
	cout << "\nItem deleted: " << i ;
	cout << "\nElements in the circular queue after deletion: " ;
	a.display( ) ;
	a.addq ( 21 ) ;
	a.addq ( 17 ) ;
	a.addq ( 18 ) ;
	a.addq ( 9 ) ;
	a.addq ( 20 ) ;
	cout << "Elements in the circular queue after addition: " ;
	a.display( ) ;
	a.addq ( 32 ) ;
	cout << "Elements in the circular queue after addition: " ;
	a.display( ) ;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-implement-circular-queue-using-array/">C++ program to implement circular queue using array</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-program-to-implement-circular-queue-using-array/feed/</wfw:commentRss>
			<slash:comments>11</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program to implement Quick sort Algorithm using class</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-program-to-implement-quick-sort-algorithm-using-class/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-program-to-implement-quick-sort-algorithm-using-class/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Tue, 01 Feb 2011 13:35:44 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Source Codes]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[Quick sort]]></category>
		<category><![CDATA[array]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1238</guid>

					<description><![CDATA[<p>#include 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 ) ; void display(</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-program-to-implement-quick-sort-algorithm-using-class/">C++ program to implement Quick sort Algorithm using class</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#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 ) ;
		void display( ) ;
} ;
array :: array( )
{
	count = 0 ;
	for ( int i = 0 ; i < MAX ; i++ )
		arr[i] = 0 ;
}
void array :: add ( int item )
{
	if ( count < MAX )
	{
		arr[count] = item ;
		count++ ;
	}
	else
		cout << "\nArray is full" << endl ;
}
int array :: getcount( )
{
	return count ;
}
void array :: quiksort ( int lower, int upper )
{
	if ( upper > lower )
	{
		int i = split ( arr, lower, upper ) ;
		quiksort ( lower, i - 1 ) ;
		quiksort ( i + 1, upper ) ;
	}
}
int array :: split ( int *a, int lower, int upper )
{
	int i, p, q, t ;

	p = lower + 1 ;
	q = upper ;
	i = a[lower] ;
	while ( q >= p )
	{
		while ( a[p] < i )
			p++ ;
		while ( a[q] > i )
			q-- ;
		if ( q > p )
		{
			t = a[p] ;
			a[p] = a[q] ;
			a[q] = t ;
		}
	}
	t = a[lower] ;
	a[lower] = a[q] ;
	a[q] = t ;
	return q ;
}
void array :: display( )
{
	for ( int i = 0 ; i < count ; i++ )
		cout << arr[i] << "  " ;
	cout << endl ;
}
void main( )
{
	array a ;
	a.add ( 11 ) ;
	a.add ( 2 ) ;
	a.add ( 9 ) ;
	a.add ( 13 ) ;
	a.add ( 57 ) ;
	a.add ( 25 ) ;
	a.add ( 17 ) ;
	a.add ( 1 ) ;
	a.add ( 90 ) ;
	a.add ( 3 ) ;
	cout << "\nQuik sort.\n" ;
	cout << "\nArray before sorting:" << endl ;
	a.display( ) ;
	int c = a.getcount( ) ;
	a.quiksort ( 0, c - 1 ) ;
	cout << "\nArray after quick sorting:" << endl ;
	a.display( ) ;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-program-to-implement-quick-sort-algorithm-using-class/">C++ program to implement Quick sort Algorithm using class</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-program-to-implement-quick-sort-algorithm-using-class/feed/</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
			</item>
		<item>
		<title>C++ rogram to implement merge sort</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-rogram-to-implement-merge-sort/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-rogram-to-implement-merge-sort/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Tue, 01 Feb 2011 13:34:06 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Source Codes]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[Merge sort]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1236</guid>

					<description><![CDATA[<p>#include 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( ) ;</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-rogram-to-implement-merge-sort/">C++ rogram to implement merge sort</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#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( ) ;
} ;
array :: array( )
{
	count = size = 0 ;
	a = NULL ;
}
array :: array( int sz )
{
	count = 0 ;
	size = sz ;
	a = new int[sz] ;
}
void array :: add ( int num )
{
	if ( count < size )
	{
		a[count] = num ;
		count++ ;
	}
	else
		cout << "\nArray is full" << endl ;
}
void array :: display( )
{
	for ( int i = 0 ; i < count ; i++ )
		cout << a[i] << "\t" ;
	cout << endl ;
}
void array :: merge_sort(int low,int high)
{

	int mid;
	if(low<high)
	{
		mid=(low+high)/2;
		merge_sort(low,mid);
		merge_sort(mid+1,high);
		merge(low,mid,high);
	}
}
void array :: merge(int low,int mid,int high)
{
	int h,i,j,b[50],k;
	h=low;
	i=low;
	j=mid+1;

	while((h<=mid)&#038;&#038;(j<=high))
	{
		if(a[h]<=a[j])
		{
			b[i]=a[h];
			h++;
		}
		else
		{
			b[i]=a[j];
			j++;
		}
		i++;
	}
	if(h>mid)
	{
		for(k=j;k<=high;k++)
		{
			b[i]=a[k];
			i++;
		}
	}
	else
	{
		for(k=h;k<=mid;k++)
		{
			b[i]=a[k];
			i++;
		}
	}
	for(k=low;k<=high;k++) a[k]=b[k];
}
array :: ~array( )
{
	delete a ;
}

void main( )
{
	array a ( MAX ) ;

	a.add ( 11 ) ;
	a.add ( 2 ) ;
	a.add ( 9 ) ;
	a.add ( 13 ) ;
	a.add ( 57 ) ;

	cout << "\nMerge sort.\n" ;

	a.merge_sort (0,4) ;

	cout << "\nArray after sorting: " << endl ;
	a.display( ) ;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-rogram-to-implement-merge-sort/">C++ rogram to implement merge sort</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-rogram-to-implement-merge-sort/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program to implement Insertion sort using class</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-program-to-implement-insertion-sort-using-class/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-program-to-implement-insertion-sort-using-class/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Tue, 01 Feb 2011 13:27:51 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Insertion sort]]></category>
		<category><![CDATA[Source Codes]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[array]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1230</guid>

					<description><![CDATA[<p>#include 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 = 0</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-program-to-implement-insertion-sort-using-class/">C++ program to implement Insertion sort using class</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#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 = 0 ; i < MAX ; i++ )
		arr[i] = 0 ;
}
void array :: add ( int item )
{
	if ( count < MAX )
	{
		arr[count] = item ;
		count++ ;
	}
	else
		cout << "\nArray is full" << endl ;
}
void array :: sort( )
{
	int temp ;
	for ( int i = 1 ; i <= count - 1 ; i++ )
	{
		for ( int j = 0 ; j < i ; j++ )
		{
			if ( arr[j] > arr[i] )
			{
				temp = arr[j] ;
				arr[j] = arr[i] ;
				for ( int k = i ; k > j ; k-- )
					arr[k] = arr[k - 1] ;
				arr[k + 1] = temp ;
			}
		}
	}
}

void array :: display( )
{
	for ( int i = 0 ; i < count ; i++ )
		cout << arr[i] << "\t" ;
	cout << endl ;
}
void main( )
{
	array a ;
	a.add ( 25 ) ;
	a.add ( 17 ) ;
	a.add ( 31 ) ;
	a.add ( 13 ) ;
	a.add ( 2 ) ;
	cout << "\nInsertion sort.\n" ;
	cout << "\nArray before sorting:" << endl ;
	a.display( ) ;
	a.sort( ) ;
	cout << "\nArray after insertion sorting:" << endl ;
	a.display( ) ;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-program-to-implement-insertion-sort-using-class/">C++ program to implement Insertion sort using class</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-program-to-implement-insertion-sort-using-class/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>C++ programs to implement Graph Traversal Techniques &#8211; Depth First Search/Breadth First Search</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-programs-to-implement-graph-traversal-techniques-depth-first-searchbreadth-first-search/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-programs-to-implement-graph-traversal-techniques-depth-first-searchbreadth-first-search/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Mon, 31 Jan 2011 12:38:55 +0000</pubDate>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[Graph Traversal Techniques]]></category>
		<category><![CDATA[Breadth first]]></category>
		<category><![CDATA[Search algorithm]]></category>
		<category><![CDATA[Depth First]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1279</guid>

					<description><![CDATA[<p>a)Program to implement Breadth first Search algorithm. #include #include #include int cost[10][10],i,j,k,n,queue[10],front,rear,v,visit[10],visited[10]; void main() { int m; clrscr(); cout n; cout m; cout >j; cost[i][j]=1; } cout v; cout</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-programs-to-implement-graph-traversal-techniques-depth-first-searchbreadth-first-search/">C++ programs to implement Graph Traversal Techniques – Depth First Search/Breadth First Search</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><strong>a)Program to implement Breadth first Search algorithm.</strong></p>
<pre lang="cpp">
#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;
	k=1;
	while(k<n)
	{
		for(j=1;j<=n;j++)
			if(cost[v][j]!=0 &#038;&#038; visited[j]!=1 &#038;&#038; visit[j]!=1)
			{
				visit[j]=1;
				queue[rear++]=j;
			}
		v=queue[front++];
		cout<<v << " ";
		k++;
		visit[v]=0;
		visited[v]=1;
	}
	getch();
}
</pre>
<p><strong>b)Program to implement Depth First Search Algorithm.</strong></p>
<pre lang="cpp">
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
int cost[10][10],i,j,k,n,stack[10],top,v,visit[10],visited[10];
void main()
{
	int m;
	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 <<"ORDER OF VISITED VERTICES";
	cout << v <<" ";
	visited[v]=1;
	k=1;
	while(k<n)
	{
		for(j=n;j>=1;j--)
			if(cost[v][j]!=0 && visited[j]!=1 && visit[j]!=1)
			{
				visit[j]=1;
				stack [top]=j;
				top++;
			}
		v= stack [--top];
		cout<<v << " ";
		k++;
		visit[v]=0; visited[v]=1;
	}
	getch();
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-programs-to-implement-graph-traversal-techniques-depth-first-searchbreadth-first-search/">C++ programs to implement Graph Traversal Techniques – Depth First Search/Breadth First Search</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-advanced/c-programs-to-implement-graph-traversal-techniques-depth-first-searchbreadth-first-search/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program to implement Queue using Linked Representation</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-queue-using-linked-representation/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-queue-using-linked-representation/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Mon, 31 Jan 2011 12:14:56 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[Linked Representation]]></category>
		<category><![CDATA[Queue]]></category>
		<category><![CDATA[linked list]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[C Programs]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1267</guid>

					<description><![CDATA[<p>#include template class Node { friend LinkedQueue; private: T data; Node *link; }; template 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 LinkedQueue&#038; Add(const T&</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-queue-using-linked-representation/">C++ program to implement Queue using Linked Representation</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#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
		LinkedQueue<T>& Add(const T& x);
		LinkedQueue<T>& Delete(T& x);
	private:
		Node<T> *front;  // pointer to first node
		Node<T> *rear;   // pointer to last node
};

	template<class T>
LinkedQueue<T>::~LinkedQueue()
{// Queue destructor.  Delete all nodes.
	Node<T> *next;
	while (front) {
		next = front->link;
		delete front;
		front = next;
	}
}
template<class T>
T LinkedQueue<T>::First() const
{
	if (IsEmpty())   { cout<<"OutOfBounds()";  return -1; };
	return front->data;
}
template<class T>
T LinkedQueue<T>::Last() const
{
	if (IsEmpty()) { cout<<"OutOfBounds()";    return -1; };
	return rear->data;
}
	template<class T>
LinkedQueue<T>& LinkedQueue<T>::Add(const T& x)
{
	Node<T> *p = new Node<T>;
	p->data = x;
	p->link = 0;
	if (front) rear->link = p;  // queue not empty
	else front = p;             // queue empty
	rear = p;
	return *this;
}
	template<class T>
LinkedQueue<T>& LinkedQueue<T>::Delete(T& x)
{
	if (IsEmpty()) {  cout<<"OutOfBounds()"; return *this; };
	x = front->data;
	Node<T> *p = front;
	front = front->link;
	delete p;
	return *this;
}
void main(void)
{
	LinkedQueue<int> Q;
	int x;
	Q.Add(1).Add(2).Add(3).Add(4);
	cout << "No queue add failed" << endl;
	cout << "Queue is now 1234" << endl;
	Q.Delete(x);
	cout << "Deleted " << x << endl;
	cout << Q.First() << " is at front" << endl;
	cout << Q.Last() << " is at end" << endl;
	Q.Delete(x);
	cout << "Deleted " << x << endl;
	Q.Delete(x);
	cout << "Deleted " << x << endl;
	Q.Delete(x);
	cout << "Deleted " << x << endl;
	cout << "No queue delete failed " << endl;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-queue-using-linked-representation/">C++ program to implement Queue using Linked Representation</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-queue-using-linked-representation/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
