The Gateway to Computer Science Excellence
0 votes
61 views
Can somebody write the code or algorithm, how merge sort works efficiently in linked list? Is Heap sort most inefficient in Linked List Sorting? Elaborate plz
in DS by Veteran (118k points) | 61 views

1 Answer

0 votes
struct node* MS(struct node* s, struct node*s1, struct node*s2){

if(s == NULL) return(NULL);

else if(s->next == NULL) return(s);

else{

b = middle(s);

q = b->next;

b->next = NULL;

s1 = MS(s);

s2 = MS(q);

s = merge(s1,s2);

return (s);

}}


No heapsort is not the most inefficient in linked list sorting because it will take O(nlogn)
by (59 points)
0
then which sort is inefficient?
0
Mergesort will also take o ( nlogn)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,270 answers
198,135 comments
104,777 users