QuickSort tren dslk
void DSLK::quicksort1()
{
DSLK l1,l2;
if(this->Cuoi==this->Dau)return;
TRONUT p,x=this->Dau;
this->Dau=x->tiep;
while(this->Dau)
{
p=this->Dau;
this->tachNut(p);
if(p->DL<x->DL)l1.themPhanTu_Cuoi(p);
else l2.themPhanTu_Cuoi(p);
}
l1.quicksort1();
l2.quicksort1();
if(l1.Dau)
{
this->Dau=l1.Dau;
l1.Cuoi->tiep=x;
}
else
this->Dau=x;
x->tiep=l2.Dau;
if(l2.Dau)
{
this->Cuoi=l2.Cuoi;
}
else
{
this->Cuoi=x;
}
l1.Cuoi=l1.Dau=NULL;
l2.Cuoi=l2.Dau=NULL;
}
Bạn đang đọc truyện trên: AzTruyen.Top