Data Structure Questions and Answers-Sparse Array

 

 Help authour, Buy PDF Ebook   >>>Click Here<<<

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
NTA NET Questions answers
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
Management Questions answers
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
Civics Test Questions answers
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
Computer science Questions answers
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
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

Management Questions answers
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.

There are 5 questions to complete.

 

 Download all FREE PDF Ebook >>>CLICK HERE<<<