c - linked list example in c what is below function fun doing what is the operation and what is this data structure struct node int data struct node link headnull void funint val struct node temp null tempstruct node mallocsizeofstruct node tempdataval - skillgun

function fun() is trying to insert a new element into the singly linked list. operation here is insertion to the single linked list. data structure here is linked list.

function fun() is trying to insert a new element at the end of previous element. this operation is a push operation on stack(as we insert new elements in stack at the end). this data structure is implementation of push operation of stack using a linked list.

function fun() is trying to insert a new element at the end of previous element. this operation is a push operation on queue(as we insert new elements in queue at the end). this data structure is implementation of insert() operation of queue using a linked list.

it can be either option 2 or 3.

Answer :(D)

it can be either option 2 or 3.

Description :

if you take stack or queue, new element will be always added at the end of the previous element. so this is the same implementation where new elements are being inserted at the top(end) by giving link to previous node. so this is the implementation of either push() or insert() on either stack or queue respectively. same logic can be used for both the data structures. but here we are not implementing it through array but we are using a linked list(single).