# Data Structure Questions and Answers-Sparse Array

## Data Structure Questions and Answers-Sparse Array

 Question 1
What is a sparse array?
 A Data structure for representing arrays of records B Data structure that compactly stores bits C An array in which most of the elements have the same value D None of the mentioned
Question 1 Explanation:
They are set to a default value, usually 0 or null.

 Question 2
When do you use a sparse array?
 A When there are unique elements in the array B When the array has more occurrence of zero elements C When the data type of elements differ D In all of the mentioned cases
Question 2 Explanation:
It need not necessarily be zero, it could be any default value, usually zero or null.

 Question 3
What is the difference between a normal(naive) array and a sparse array?
 A Sparse array can hold more elements than a normal array B Sparse array is memory efficient C Sparse array is dynamic D A naive array is more efficient
Question 3 Explanation:
A naive implementation allocates space for the entire size of the array, whereas a sparse array(linked list implementation) allocates space only for the non-default values.

 Question 4
Choose the code which performs the store operation in a sparse array.(Linked list implementation)
 A public void store(int inde, x Object val) { List cur = this; List prev = null; List node = new List(index); node.val = val B public void store(int inde, x Object val) { List cur = this; List prev = null; List node = new List(index); node.val = val C public void store(int inde, x Object val) { List cur = this; List prev = null; List node = new List(index); node.val = val D None of the mentioned
 A public Object fetch(int index) { List cur = this.next; Object val = null; while (cur != null && cur.index != index) { cur  B public Object fetch(int index) { List cur = this; Object val = null; while (cur != null && cur.index != index) { cur = cur. C public Object fetch(int index) { List cur = this; Object val = null; while (cur != null && cur.index != index) { cur = cur. D None of the mentioned