functions (3.papers)

loops (1.papers)

Conditional statements (2.papers)

arrays (2.papers)

structures (3.papers)

unions (1.papers)

Enums and TypeDefs (3.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)

bitwise operators (1.papers)

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?

O(n) and O(1)

O(1) and O(n)

O(n) and O(n)

O(n) and O(log n)

Show Answer

2

What is the time complexity of inserting a new node after kth element in a single linked list of n nodes? Note: only head pointer is given.

O(1)

O(k)

O(log k)

O(n)

Show Answer

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; } }

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.

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.

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.

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

4

Which of the below statements are true about a linked list?

Single linked lists are faster than circular linked lists.

circular linked lists are faster than single linked lists as it avoid unnecessary header and tail checks.

circular linked lists add unnecessary head ache, so better to avoid it. other wise time complexity would be almost same for both.

circular linked lists add unnecessary head ache, so better to avoid it. single linked lists are faster compared to circular.

Show Answer