Updated April 7, 2023
Definition of Linked List Interview
Linked list is the most used data structure which is linear in nature after the array data structure. Hence, it is obvious that you will come across many questions related to linked list while you will be giving an interview for post related to data manipulations or even any other technology related post. In this article, we will learn about some of the most frequently asked questions related to linked list in interviews.
Question and Answers
Let us discuss questions and answer about Linked List Interview Questions.
1. What is linked list?
Answer:
Linked list is a data structure which is linear in nature and does not stores the data in the sequential memory locations. A linked list consists of one or more nodes also called as links.
2. Tell about the graphical representation of linked list.
Answer:
Each link is a pair of two things one is the data part which holds the value of the element which needs to be stored in the linked list while the second part is the next which stores the address of the next link or node to which it pints to. The starting node or link is known as the head. The last node has its next part pointing to the null as there is no further node to be pointed which marks the end of the linked list as shown in the below figure.
As shown above each node contains the data field and the reference field. A linked list can contain any number of nodes depending on the data which we need to store and the memory capacity that is available.
3. How many linked list types are present?
Answer:
There are following types of linked list:
• Singly Linked List
• Multiply Linked List
• Doubly Linked List
• Circular Linked List
4. Describe the singly linked list.
Answer:
The answers of first and second combining can be referred for this question’s answer.
5. Describe the doubly linked list.
Answer:
In doubly linked multiple links or nodes are connected to each other and each of the node contains three field in it namely prev, data, and next containing the pointer to previous node, the data of the element, and the pointer to next element respectively. The graphical representation of the doubly linked list is as shown below –
6. Describe the circular linked list.
Answer:
A circular queue is a data structure that helps to store the data in a linear way and is similar to the normal simple queue but with functionality where the last element is connected to the first one. This facilitates the insertion of the new element in the queue even when the queue is full provided the first place of the queue is empty.
The following figure shows the visual representation of the working of the circular queue and the way in which the data is stored in it.
7. What type of memory allocation is used in implementation of linked list?
Answer:
Dynamic memory allocation is used in linked list.
8. What is meant by traversing the linked list?
Answer:
Processing each individual element in the linked list is called as traversal.
9. Specify the differences that exist between the linear array and linear linked list.
Answer:
Linear Array |
Linked List |
Difficult for insertion and deletion | No movement of nodes required to perform insertion and deletion. |
Space is wasted as fixed size needs to be specified priorly. | No wastage of memory due to dynamic memory allocation. |
Same amount of time is required for availing different elements stored in array. | Different amount of time is required for availing different elements stored in array. |
Elements are stored consecutively. | Elements may not be stored consequently. |
Direct access to required node is done. | Traversing of all the prior nodes needs to be done for reaching particular node. |
10. What are applications of the linked list data structure?
Answer:
Stacks, queues, skip unrolled linked list, binary tree, hash table, etc. are some of the applications of linked list.
11. What is the advantage of using the linked list data structure?
Answer:
• No specification of the fixed size required as memory is allocated dynamically in runtime according to requirement.
12. What are disadvantages of using a linked list?
Answer:
• Sequential access of the data needs to be done resulting in not able to use binary search which is why we cannot perform random access in linked list.
• More memory required for storing the pointer addresses.
• O(n) time complexity for accessing the element which results in slow performance due to recursion.
• Poor locality resulted due to scattered placement of data of the linked list.
13. From where we bring the free node while performing the insertion operation of linked list?
Answer:
Avail list
14. Name the header list which has the last node pointing to null pointer.
Answer:
Grounded header list.
15. Which package is used in java programming language for implementing the linked list?
Answer:
Java.util package.
16. In java, which interfaces implement the linked list?
Answer:
The following interfaced implement linked list in java –
• Iterable
• List
• Queue
• Cloneable
• Deque
• Serializable
• Collection
17. Tell me about the process of adding the two linked list with the help of stack using java programming language.
Answer:
The resultant linked list can be filled with the values in such a way that the sum of first element in first linked list will be done with the first element of the second linked list and the resulting value will be inserted in the first element for the resultant linked list. The same process will be carried out for the other elements of the linked list as well. If both the list are not of same length then the remaining elements of the longer list will be copied directly to the resultant list at the end of carrying out the sum for previous elements as explained previously.
Conclusion
You should be aware about all the basics of linked list and its working in order to prepare for interview. For the same thing, it is necessary that you go through all the above-mentioned questions and answers and clear yourself with the structure, working, and implementation of linked list data structure.
Recommended Articles
This is a guide to Linked List Interview Questions. Here we discuss questions and answers of structure, working, and implementation of linked list data structure. You may also have a look at the following articles to learn more –