Consider this singly linked list implementation taken from some online resource.
ID: 3863084 • Letter: C
Question
Consider this singly linked list implementation taken from some online resource. Insert_ node_ pos(int pos, int val) adds a node with value as at position pos in the singly linked list. Write 3 unit tests for this method. struct node { int value; struct node }; type of struct node snode: //linked list operations snode* create _node(int); void insert_ node_ first(int value); void insert_ node_ last (int value); void insert_ node _pos(int position, int value); void delete_ pos(); void search(int value); void display(); snode *newnode, *ptr, *prev, *temp; snode *first= NULL, *last = NULL; void insert_ node_ pos(int pos, int val) {int cnt = 0, i; newnode = create_ node(val); ptr = first; while (ptr ! = NULL)[ ptr = ptr rightarrow next: cnt++; } if (pos ==1) { if (first last && first NULL)[ first = last = newnode first rightarrow next = NULL; last rightarrow next = NULL; } else { temp = first; first = newnode; first rightarrow next = temp; } printf( Inserted"); } else if (pos >1 && posExplanation / Answer
Test cases are given below:-
1. New node can be insterted after the first node.
2. New node cannot be inserted before first node.
3. First node points to new node after insertion.