Insert sort function linke list


why insertSort function not working properly, solution is commented but why not commented part giving only first element ?

even after uncommenting ur code it does not provided a sorted list

refer this code

Below is simple insertion sort algorithm for linked list.

  1. Create an empty sorted (or result) list
  2. Traverse the given list, do following for every node.
    …a) Insert current node in sorted way in sorted or result list.
  3. Change head of given linked list to head of sorted (or result) list.

@chhavibansal ok, thank you mam

1 Like