Data Structure Questions and Answers-Sparse Array

DOWNLOAD FREE PDF <<CLICK HERE>>

Data Structure Questions and Answers-Sparse Array

Congratulations - you have completed Data Structure Questions and Answers-Sparse Array.

You scored %%SCORE%% out of %%TOTAL%%.

Your performance has been rated as %%RATING%%


Your answers are highlighted below.
Question 1 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
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 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
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 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
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 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
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
Question 4 Explanation: 
Create a new node and traverse through the list until you reach the correct position, check for duplicate and nullity of the list and then insert the node.

Question 5 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Which of the following performs the fetch operation?
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

Question 5 Explanation: 
You travers through the array until the end is reached or the index is found and return the element at that inde, x null otherwise.

Once you are finished, click the button below. Any items you have not completed will be marked incorrect. Get Results
There are 5 questions to complete.

DOWNLOAD FREE PDF <<CLICK HERE>>