First time user?    |

#### Select chapter

functions (3.papers)
loops (1.papers)
arrays (2.papers)
structures (3.papers)
unions (1.papers)
pointers (7.papers)
null pointers (1.papers)
strings (2.papers)
misc c concepts (1.papers)
Data structures (5.papers)
linked lists (3.papers)
trees (1.papers)
basics (5.papers)
Hide

# c linked lists interview questions and answers

1
`What is the time complexity of deleting all the nodes of linked list and deleting all the elements of an array which is allocated dynamically?`
1. `O(n) and O(1)`
2. `O(1) and O(n)`
3. `O(n) and O(n)`
4. `O(n) and O(log n)`
Show Answer
Share
Show Answer
Share
3
```What is function fun() doing in below code?

#include  <stdio.h>

struct linkedlist{
int val;
struct linkedlist *next;
}*head = NULL, *tail = NULL;

void fun(int p, struct linkedlist *item){
if(p<0 || item == NULL)
return;

struct linkedlist *temp = head;
for(int i=1; i<p && temp; i++){
temp = temp->next;
}
if(!temp && p>0)
return;
if(p>0){
item->next = temp->next;
temp->next = item;
}else{
item->next = head;
head = item;
}
}```
1. `the function fun() is trying to insert a node after pth element in the given double linked list. But it is not handling the condition where we want to insert a new node as head node.`
2. `the function fun() is trying to insert a node after pth element in the given single linked list. But it is not handling the condition where we want to insert a new node as head node.`
3. `the function fun() is trying to insert a node after pth element in the given single linked list. It is handling the conditions of inserting a node at 0th or other locations. But it is not handling if p is more than n.`
4. `the function fun() is trying to insert a node after pth element in the given single linked list. It is handling the conditions of inserting a node at 0th or other locations. it is also handling if p is greater than n.`
Show Answer
Share
4
`Which of the below statements are true about a linked list?`
1. `Single linked lists are faster than circular linked lists.`
2. `circular linked lists are faster than single linked lists as it avoid unnecessary header and tail checks.`
3. `circular linked lists add unnecessary head ache, so better to avoid it. other wise time complexity would be almost same for both.`
4. `circular linked lists add unnecessary head ache, so better to avoid it. single linked lists are faster compared to circular.`
Show Answer
Share
Read more papers :