Singly Linked List Operations Questions and Answers

Data Structure Questions and Answers – Singly Linked List Operations

This set of Data Structure Interview Questions and Answers for freshers focuses on “Singly Linked Lists Operations

1. Which of the following points is/are not true about Linked List data structure when it is compared with an array?
a) Arrays have better cache locality that can make them better in terms of performance
b) It is easy to insert and delete elements in Linked List
c) Random access is not allowed in a typical implementation of Linked Lists
d) Access of elements in linked list takes less time than compared to arrays

Explanation: To get to an element in a linked list, we must go through all of the elements until we find the one we want. Because arrays provide random access to their elements, this will take longer.
2. What does the following function do for a given Linked List with first node as head?

void fun1(struct node* head)
{
if(head == NULL)
return;
fun1(head->next);
printf(“%d “, head->data);
}
a) Prints all nodes of linked lists
b) Prints all nodes of linked list in reverse order
c) Prints alternate nodes of Linked List
d) Prints alternate nodes in reverse order

Explanation: fun1() prints the given Linked List in reverse manner.
For Linked List 1->2->3->4->5, fun1() prints 5->4->3->2->1.
3. Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?
a) Insertion Sort
b) Quick Sort
c) Heap Sort
d) Merge Sort

Explanation: For linked lists, both Merge sort and Insertion sort can be utilised. Because of a linked list’s slow random-access performance, other algorithms (such as quicksort) perform badly, and others (such as heapsort) are impossible. Merge Sort is recommended over Insertion Sort because its worst-case time complexity is O(nLogn) whereas Insertion Sort is O(n2).

4. What kind of linked list is best to answer questions like “What is the item at position n?”
a) Singly linked list
b) Doubly linked list
c) Circular linked list
d) Array implementation of linked list

Explanation: By containing the index value in square brackets, arrays allow for random access to elements. We must go over each element in the linked list until we reach the nth position. Having an element represented in an array takes less time than accessing an element represented in a singly, doubly, or circular linked list. As a result, the item at position n is accessed using array implementation.
5. Linked lists are not suitable for the implementation of ___________
a) Insertion sort
b) Radix sort
c) Polynomial manipulation
d) Binary search

Explanation: It cannot be implemented using linked lists.
6. Linked list is considered as an example of ___________ type of memory allocation.
a) Dynamic
b) Static
c) Compile time
d) Heap

Explanation: As memory is allocated at the run time.
7. In Linked List implementation, a node carries information regarding ___________
a) Data
b) Link
c) Data and Link
d) Node

Explanation: A linked list is a group of objects that are linked together via references from one object to another. These objects are referred to as nodes by convention. A linked list is made up of nodes, each of which has one or more data fields and a link to the next node.
8. Linked list data structure offers considerable saving in _____________
a) Computational Time
b) Space Utilization
c) Space Utilization and Computational Time
d) Speed Utilization

Explanation: Linked lists saves both space and time.

A singly linked list is a sort of unidirectional linked list that may only be explored in one direction, from head to final node (tail). A node is the name for each element in a linked list. A single node contains data as well as a pointer to the next node, which aids in the list’s structure. A linked list is a group of objects that are linked together via references from one object to another. These objects are referred to as nodes by convention. A linked list is made up of nodes, each of which has one or more data fields and a link to the next node.

Leave a Reply

Your email address will not be published. Required fields are marked *