| 10 | // initialised first as null |
| 11 | |
| 12 | void createList(int arr[], int n) |
| 13 | { |
| 14 | struct Node *t; |
| 15 | struct Node *last; |
| 16 | |
| 17 | // setup a new node |
| 18 | first = new struct Node; |
| 19 | first->data = arr[0]; |
| 20 | first->next = NULL; |
| 21 | |
| 22 | // last is first as 1 element only |
| 23 | last = first; |
| 24 | |
| 25 | for (int i = 1; i < n; i++) |
| 26 | { |
| 27 | // setup a new node |
| 28 | t = new struct Node; |
| 29 | t->data = arr[i]; |
| 30 | t->next = NULL; |
| 31 | |
| 32 | // make current last point to new node |
| 33 | last->next = t; |
| 34 | |
| 35 | // update last |
| 36 | last = t; |
| 37 | } |
| 38 | }; |
| 39 | |
| 40 | void printList(struct Node *p) |
| 41 | { |
nothing calls this directly
no outgoing calls
no test coverage detected