
You can find the answers to these questions at this link.
#Basic data structures java software
Ive compiled this list from research and from several credible sources for interviews for software developers. These questions are suited for freshers as well.

The class node consists of a variable ‘value’ which holds data for each node and reference to the next node. We have to define head, p and class node as static so that it can be accessed from main() function. In the above code, we are using LinkedList class and node a separate class. Implementation of LinkedList in Java import While in arrays accessing an element can be done in O(1). We have to traverse the linked list from starting to access an element in linked list. Ģ.) Random access not allowed:- Random access of an element in a linked list is not allowed. Disadvantages of using Linked Listġ.) Extra memory space for pointers:- As each node in a linked list consists of pointers which hold the address of next node, so an extra memory space for a pointer is required with each element of linked list. In array insertion of an element needs room for that element and shifting of elements. There is an upper limit on the number of elements in array as the size of array is fixed.Ģ.) Ease of Insertion and Deletion:- Insertion and deletion of an element in a linked list is very easy as compared to arrays and can be done in O(1). So, we can add more and more elements in a linked list easily as compared to arrays. In Java Linked List is represented as a separate class and node as a separate class class Codespeedyġ.) Dynamic Size:- Memory allocation to linked list elements is done dynamically. Each node in a linked list is connected to next node using pointer.

Starting node of linked list is known as head node.ġ.) Data field:- stores the data of a node.Ģ.) Pointer to next node:- Each node holds the address of the next node. Elements in LinkedList are linked to each other using pointers.Ī linked list consists of nodes in which each data holds a data field and a pointer to the next node. Linked list is a linear data structure in which elements are not stored in contiguous memory locations. In this Java tutorial, we are going to discuss the linked list data structure. We will learn the following things in this Java Linked List tutorial:
