250+ TOP MCQs on Sparse Matrices – 1 and Answers

MATLAB Multiple Choice Questions on “Sparse Matrices – 1”.

1. What is the attribute of sparse matrices?
a) sparse
b) double
c) vector
d) no attribute

Answer: a
Clarification: The attribute of a sparse matrix will be sparse while the class of the attribute is double, by default. Hence, sparse is correct.

2. What is the output of the following code?

a) A m*n all zero sparse matrix
b) A m*n sparse matrix
c) Error due to syntax
d) Error in the input

Answer: c
Clarification: There are two errors in the above code. MATLAB would return the syntactical error due to [] since there should be a parenthesis. There is an error in the input since there should be a ‘ , ‘ between m an n.

3. The nature of complex input taken by the sparse() command is ______________
a) Only Imaginary part
b) Only positive imaginary part
c) Only negative real part
d) All of the mentioned

Answer: d
Clarification: The sparse() command takes all kind of complex inputs. It is not biased by default.

4. Which of the following can be the space taken up by a sparse matrix?
a) .25 megabytes
b) 600 megabytes
c) .5 GB
d) 450 megabytes

Answer: a
Clarification: The sparse matrix takes extremely small space from memory which is why it is so useful. The most plausible option amongst is .25 megabytes while the rest suggest pretty large amount of memory.

5. To check whether the input matrix is sparse or not, we use the ________ command.
a) issparse
b) besparse
c) ifsparse
d) sparse

  250+ TOP MCQs on Branching – 1 and Answers

Answer: a
Clarification: The correct command to check whether the input matrix is sparse or not is the issparse command. The sparse command generates a sparse matrix.

6. A sparse identity matrix is generated by the ______ command.
a) sparseid
b) isparse
c) speye
d) idensparse

Answer: a
Clarification: The correct command to generate a sparse identity matrix is the speye command. The issparse command checks whether an input matrix is a sparse matrix. Hence speye is correct.

7. What is the command used to generate a sparse normally generated matrix?
a) sparserndn
b) sprandom
c) sprandn
d) no such command

Answer: c
Clarification: The sprandn command uses the same random number generator as that of the randn command. The rest of the commands don’t exist.

8. What is the output of the following code?

A=[1 2 0 3; 2 8 4 1; sin(Inf) 2 3 4]; P=sparse(A); nnz(P)

a) 11

b) 10
c) Error while declaring A
d) Error while making sparse matrix

Answer: a
Clarification: The number of non-zero numbers in the A vector is 11. Sin(Inf) Is treated as NaN and holding a non-zero value since the range of sine is [-1,1]. There won’t be any error while declaring A or making the sparse matrix.

9. The non-zero elements in a sparse matrix are shown by the ______ command.
a) nzeros
b) nonzeros
c) notzeros
d) nozero

Answer: b
Clarification: The non-zeros command is used to get the non-zero elements present in the sparse matrix. The rest of the options are not defined in MATLAB.

10. What is the output of the following code?

Answer: a
Clarification: The full command converts a sparse matrix into it’s original matrix. The space taken up by both the matrices in the memory are same. Hence, only l=a is correct.

11. The size of the sparse matrix will be ___ the original matrix.
a) equal
b) greater than
c) less than
d) not equal to

Answer: a
Clarification: The sparse matrix stores the non-zero elements in the sparse matrix. The space taken up by the sparse matrix being very less than the original, the size of both the matrix will be same. Hence, only option equal is correct.

12. The maximum space allocated for sparse matrices is given by the ____ command.
a) maxsparse
b) sparsemax
c) nzmax
d) no such command

Answer: c
Clarification: The nzmax is the command to find the maximum space allocated for sparse matrices. The maximum space is proportional to the number of non-zero elements in the original matrix.

13. The output of the following command is

a=[1 2 3;4 0 0;3 0 9]; spy(A)

a) a graph of sparsity
b) a pattern of sparsity
c) syntactical error
d) logical error

Answer: a

14. The output of the following code is:

a) Suppressed output
b) A pattern of sparsity
c) Syntactical error
d) Symbolic error

Answer: c
Clarification: The input to the spy command has to be within parentheses. Due to this, there will be a syntactical error in the above command.

15. The spy command takes in multiple matrices.
a) True
b) False

Answer: b
Clarification: The spy command does not take in multiple inputs. It will show the sparsity pattern of only input vector.

  250+ TOP MCQs on Linear Systems and Answers
Scroll to Top