just tell me will this sorting algorithm work out in linked list

for(i=head;i!=null;i=i->next)

for(j=i->next;j!=null;j=j->next)

if(i->data>j->data)
{
temp=i->data;
i->data=j->data;
j->data=temp;
}

Recommended Answers

All 3 Replies

The concept is sound, but super inefficient due to the overhead of chasing pointers.

why will time complexity go too much????

Time complexity doesn't change, but the overhead of individual operations changes noticeably between array indexing and link chasing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.