Total members 11786 |It is currently Thu Jul 18, 2019 10:25 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Simple selection sort algorithm(data structure concepts) implementation using C plus plus programming

cpp code
#include
#include

struct node
{
int data;
node *next;
};

class list
{
list() {head=current=tail=0;}

private:
node *head;
node *tail;
node *current;
public:
///put i at the beganning of j

//********************************copy function********************

void selectionsort(list &ok)
{

int max=0;
node *h;
for(h=head;h->next!=0;h=h->next)
if (h->data > max)
{ max=h->data;
ok.insert(max);
}

/*list *copy()
{list opop;

list opo;
if(head==0) coutnext!=0;head=head->next)
{node *noda=new node;
noda->data =h->data;

noda ->data=h->data;
if(opop.head==0)
{
opop.head->next=noda;
opop.head=opop.tail=noda;
}
else
{
opop.tail->next=noda;
opop.tail=noda;
opop.tail->next=0;

}

opop.display();



}


}
return 0;


}////////*/
//****************************************************************

list(int a[],int n)////insert the array of the size n in the list
{
head=tail=0;
for(int i=0;idata=elm;
if(head==0)
{
head=tail=n;
}
else
{
tail->next=n;
tail=n;
tail->next=0;
}
}
void display()
{
node *c=new node;
if(head==0)
{
coutnext!=0;c=c->next)
{
coutdatadatanext=head;}

void main()
{
list ok;
int size,size2;
cout>size;
int *n=new int[size];
for(int i=0;i>n[i];
}
list l(n,size);
l.display();

cout>size2;
int *u=new int[size2];
for(int p=0;p>u[p];
}

list k(u,size2);

l.append(k);
k.display();


l.selectionsort(ok);

ok.display();

}




_________________
Please recommend my post if you found it helpful


Last edited by msi_333 on Wed Jan 23, 2013 2:18 pm, edited 4 times in total.
Code must be in code tag


Author:
Newbie
User avatar Posts: 14
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : selection sort
 C++ Selection Sort     -  
 Help with selection sort for strings?     -  
 fill selection options from list     -  
 selection of checkbox in buttongroup in netbeans     -  
 Good looking selection box with image per option     -  
 validate age entered as selection box in javascript     -  
 calculate data from multiple selection     -  
 how to load the form elements depending on selection option     -  
 redirect page based on user selection radio button     -  
 C++ Recursion Sort     -  



Topic Tags

C++ Sorting






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com