Hi,
I want to sort 2 listboxes with DLL i have came to this part but i have no idea how to make the second node, and how to implement it into the buttonsort. I have searched for hours and hours for a solution but i can't find it.
Maybe you guys can help me on my way.
Many thanxs,
Damion
I want to sort 2 listboxes with DLL i have came to this part but i have no idea how to make the second node, and how to implement it into the buttonsort. I have searched for hours and hours for a solution but i can't find it.
Maybe you guys can help me on my way.
Many thanxs,
Damion
namespace DLL
{
class cS
{
private static cS v, m;
private cS L;
private int w;
private cS R;
private static cS[] car;
//constructor
private cS(cS pL,int v, cS pR)
{
L = pL;
w = v;
R = pR;
}
public static int[] mDLL(int[] iar)
{
//make first node
car[0] = new cS(null, iar[0], null);
v = car[0]; m = v;
car[1] = new cS(null, iar[0], null);
if (iar[1] <= iar[0])
{
//before
car[0].L = car[1];
car[1].R = car[0];
v = car[1];
}
else
{
//back
car[0].R = car[1];
car[1].L = car[0];
}
for (int i = 2; i < n; i++)
{
car[i] = new cS(null, iar[i], null);
m=v;
while (car[i].w > m.w)
{
if (m.R != null)
{
m = m.R;
}
else
{
}
}
}
return iar;
}
}
}
///FORM
private void buttonsort_Click(object sender, EventArgs e)
{
int n=10;
int[] iar=new int[n];
Random r = new Random();
for (int i =0 ; i<n; i++)
{
iar[i] = r.Next(0, 20);
lbU.Items.Add(iar[i]);
}
iar = cS.mDLL(iar);
for (int i = 0; i < n; i++)
{
lbS.Items.Add(iar[i]);
}