C++ program to implement Quick sort Algorithm using class

Tuesday, February 1st, 2011  »  Posted By Ranjith  »  Total 2 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 Ranjith  »  Total 0 Comment

#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 Shell sort using class

Tuesday, February 1st, 2011  »  Posted By Ranjith  »  Total 0 Comment

#include<iostream.h> #include<constream.h> void read(int a[10],int n) { cout<<"reading\n"; for(int i=0;i<n;i++) cin>>a[i]; } void display(int a[10],int n) { for(int i=0;i<n;i++) cout<<a[i]<<"\t"; } void shellsort(int a[10],int n) { int gap=n/2; do { int swap; do   { swap=0; for(int i=0;i<n-gap;i++) if(a[i]>a[i+gap]) { int t=a[i]; a[i]=a[i+gap]; a[i+gap]=t; swap=1; } } while(swap); } while(gap=gap/2); } void main() { int [...]

C++ program to implement Insertion sort using class

Tuesday, February 1st, 2011  »  Posted By Ranjith  »  Total 1 Comment

#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++ program to implement Selection sort using class

Tuesday, February 1st, 2011  »  Posted By Ranjith  »  Total 1 Comment

#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 = [...]

Program to implement Binary Search Algorithm

Tuesday, February 1st, 2011  »  Posted By Ranjith  »  Total 0 Comment

#include <iostream.h> template<class T> int binarySearch(T a[], int n, T& x) { int left = 0; // left end of segment int right = n – 1; // right end of segment while (left <= right) { int middle = (left + right)/2; // middle of segment if (x == a[middle]) return middle; if (x [...]

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

Monday, January 31st, 2011  »  Posted By Ranjith  »  Total 1 Comment

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 Ranjith  »  Total 0 Comment

#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 [...]

C++ program to implement Queue using Formula Based Representation

Monday, January 31st, 2011  »  Posted By Ranjith  »  Total 0 Comment

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

C++ program to implement Hash Table

Monday, January 31st, 2011  »  Posted By Ranjith  »  Total 1 Comment

#include <iostream.h> #include <stdlib.h> #include<constream.h> template<class E, class K> class HashTable { public: HashTable(int divisor = 11); ~HashTable() {delete [] ht; delete [] empty;} int Search(const K& k, E& e) const; HashTable<E,K>& Insert(const E& e); void Output();// output the hash table void del(E e); private: int hSearch(const K& k) const; int D; // hash function [...]

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

Free email signup