Linked List (3)
- 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.
- 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.
- The flowchart of insertToList() may look like:
The program may run as follows:
1
3
5
7
2
4
6
0
1 2 3 4 5 6 7