Quiz


1.  

What is a linked list?

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.  

What is the benefit of using a linked list?

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.  

What is a node?

a node is an element of a linked list.

4.  

What are the elements of a node?

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.  

What advantage does a linked list have over an array?

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.  

Can a node reference more than one data element?

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.  

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

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.  

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

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.  

What is a doubly linked list?

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.  

What is a single linked list?

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.

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.




Data Structures Demystified
Data Structures Demystified (Demystified)
ISBN: 0072253592
EAN: 2147483647
Year: 2006
Pages: 90

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net