MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the information, which a LinkedList’s Node must store?
A
The address of the next node if it exists
B
The value of the current node
C
Both (A) and (B)
D
None of the above
Explanation: 

Detailed explanation-1: -A Linked List node usually contains 2 properties stored in it. They are: The value to be stored in the current node. The reference or address of the next node, or NULL if it is the last node.

Detailed explanation-2: -In the case of a singly linked list, the next of the last node contains the address of the first node and in case of a doubly-linked list, the next of last node contains the address of the first node and prev of the first node contains the address of the last node. The list can be traversed from any node.

Detailed explanation-3: -Like arrays, a Linked List is a linear data structure. Unlike arrays, linked list elements are not stored at a contiguous location; the elements are linked using pointers. They include a series of connected nodes. Here, each node stores the data and the address of the next node.

Detailed explanation-4: -The first node in the list is called the head, and the last node in the list is called the tail. To create a singly linked list, we first need to create a node class. Each node will have two data members: an integer value and a reference to the next node in the list.

Detailed explanation-5: -The elements of a linked list are called the Nodes. Each node is consists of two fields:Data and Pointer. Each node in a linked list contains one or more members that represent data. The Nodes stored in a Linked List can be anything from primitives types such as integers to more complex types like instances of classes.

There is 1 question to complete.