hi everyone


i was trying to sort a linked list using bubble sorting but i could not reach the end. i need ur help to solve it. i dont know my logic is correct or not.

here is a simple program of bubble sort with arrays.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void bubble(int x[]);

int main() {
int data[]={4,7,6,8,3};
bubble(data);
return 0;
}

void bubble(int x[])
{
int i, j, temp;
for(i=0; i<=3; i++)
{
for(j=0;j<=3;j++)
{
if (x[j]>x[j+1])
{
temp=x[j];
x[j]=x[j+1];
x[j+1]=temp;
}
}
}
printf("after sorting.....\n");
for(i=0;i<=4;i++)
printf(" %d\n", x[ i ] ) ;
}

the attched file is the linked list program where i tried to use bubble sorting.