why insertSort function not working properly, solution is commented but why not commented part giving only first element ?
Insert sort function linke list
even after uncommenting ur code it does not provided a sorted list
refer this code
Below is simple insertion sort algorithm for linked list.
- Create an empty sorted (or result) list
- Traverse the given list, do following for every node.
…a) Insert current node in sorted way in sorted or result list. - Change head of given linked list to head of sorted (or result) list.