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?
Data structure for representing arrays of records | |
Data structure that compactly stores bits | |
An array in which most of the elements have the same value | |
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?
When there are unique elements in the array | |
When the array has more occurrence of zero elements | |
When the data type of elements differ | |
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?
Sparse array can hold more elements than a normal array | |
Sparse array is memory efficient | |
Sparse array is dynamic | |
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)
public void store(int inde, x Object val) { List cur = this; List prev = null; List node = new List(index); node.val = val | |
public void store(int inde, x Object val) { List cur = this; List prev = null; List node = new List(index); node.val = val | |
public void store(int inde, x Object val) { List cur = this; List prev = null; List node = new List(index); node.val = val | |
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?
public Object fetch(int index) { List cur = this.next; Object val = null; while (cur != null && cur.index != index) { cur | |
public Object fetch(int index) { List cur = this; Object val = null; while (cur != null && cur.index != index) { cur = cur. | |
public Object fetch(int index) { List cur = this; Object val = null; while (cur != null && cur.index != index) { cur = cur. | |
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.
There are 5 questions to complete.