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

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

Jump to Post

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 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.