Data Structures Demystified (Demystified)

1.  

What is a linked list?

2.  

What is the benefit of using a linked list?

3.  

What is a node?

4.  

What are the elements of a node?

5.  

What advantage does a linked list have over an array?

6.  

Can a node reference more than one data element?

7.  

In Java, why can t you pass a primitive data type to the add() method of the LinkedList class?

8.  

How can a node be inserted in the middle of a linked list?

9.  

What is a doubly linked list?

10.  

What is a single linked list?

Answers

1.  

A linked list is a data structure consisting of elements called nodes. Each node points to the next and the previous node, thereby linking nodes together to form a linked list.

2.  

The benefit of using a linked list is to join together large amounts of data and manipulate the data without having to rearrange data in memory.

3.  

A node is an element of a linked list.

4.  

A node has three elements. These are the current data and pointers to the previous node and the next node on the linked list.

5.  

A linked list can grow and shrink in size dynamically at runtime, whereas an array is set to a fixed size at compile time.

6.  

Yes, a node can reference more than one data element if the current data element of the node is a pointer to a group of data such as an instance of a class, a structure, or an array.

7.  

The add() method of the LinkedList class in Java requires that an object be passed to it rather than a primitive data type. You must use a Java wrapper class to create the object. The Java wrapper class contains a primitive data type used to store data.

8.  

You can insert a node in the middle of a linked list by repointing the previous and the next elements of existing nodes to the new node.

9.  

A doubly linked list is a linked list consisting of nodes that have both the previous and next elements. This links the node to the previous node and the next node.

10.  

A single linked list is a linked list consisting of nodes that have only the next element and not the previous element. This links the node to only the next node in the linked list. There is no way for the node to reference the previous node in the linked list.

Категории