Which of following is/are true about linked list?a)Arrays have better ...
A linked list consists of a number of nodes in which each node has a next pointer to the following element. The link of the last node in the list is NULL, which indicates the end of the list.
Array occupies continues memory locations. In linked lists, it's not necessary that the nodes created are in a continues memory location so that the possibility of the cache miss is higher.
View all questions of this test
Which of following is/are true about linked list?a)Arrays have better ...
Overview:
A linked list is a linear data structure where each element, known as a node, contains a value and a reference to the next node in the list. Unlike arrays, linked lists do not require contiguous memory allocation. Each node in a linked list can be independently allocated and connected using pointers.
Explanation:
Let's analyze the given options one by one to determine if they are true or false:
a) Arrays have better cache locality that can make them better in terms of performance:
False. Arrays have better cache locality compared to linked lists because array elements are stored in contiguous memory locations. This improves cache performance, as the elements can be accessed more efficiently. In contrast, linked lists store elements scattered across different memory locations, resulting in poor cache performance.
b) It is easy to insert and delete elements in Linked List:
True. Linked lists offer efficient insertion and deletion operations. In an array, when an element is inserted or deleted, other elements need to be shifted, resulting in time-consuming operations. However, in a linked list, inserting or deleting an element only requires updating the pointers of adjacent nodes, making the process relatively easier and faster.
c) Random access is not allowed in linked list:
True. Random access refers to accessing elements directly using their indices. In arrays, elements can be accessed randomly, whereas in linked lists, elements can only be accessed sequentially by traversing the list from the beginning. This is because linked lists do not have indices, and each element can only be accessed by following the references from the previous node.
Conclusion:
Based on the analysis of the given options, it can be concluded that all of the above statements are true. Arrays have better cache locality, linked lists provide easy insertion and deletion operations, and random access is not allowed in linked lists.
To make sure you are not studying endlessly, EduRev has designed Railways study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Railways.