Linked List (3)

  1. In contrast with previous exercises which store data with the same order or reverse order as the input order, this time we want to store data in a "sorted" order.
  2. Design a function ListElement* insertToList(ListElement* pHead, int v) so that it will insert the value v in an appropriate position in the linked list, so that all the values in the linked list are arranged in an ascending order.
  3. The flowchart of insertToList() may look like:
    insertTo_List()

The program may run as follows:

1
3
5
7
2
4
6
0
1 2 3 4 5 6 7