Spread the post

selection sort of given linked list

Suppose given linked list contain following nodes.

Input: 17 66 13 32 11 61 17 84

Output: 11 13 17 17 32 61 66 84


Use three pointer temp, help and sort_node. view function to prform selcetion sort.

Time complexity O(n^2).

Given example:

selection sort linked list

View insertion process.

Try it yourself

After Perform selection sort linked list is.


Code execution:

Stack Areamainroot(pointer)selection_sorthelp(pointer)sort_node(pointer)sort_value (int) =13temp(pointer) Heap Areastruct Nodedata (int)= 11next (pointer) struct Nodedata (int)= 13next (pointer) struct Nodedata (int)= 66next (pointer) struct Nodedata (int)= 32next (pointer) struct Nodedata (int)= 17next (pointer) struct Nodedata (int)= 61next (pointer) struct Nodedata (int)= 17next (pointer) struct Nodedata (int)= 84next (pointer)= NULL

Note that not given all step of execution process here.View How to insert linked list element and so on.

Try it yourself

C program to perform selection sort of given linked list.


Spread the post

Recommended Posts: