500+ arrays types mcqs with free pdf

12
livemcqs.com livemcqs.com 500+ Arrays Types MCQs with FREE PDF 1. Which of the following bitwise operator will you use to invert all the bits in a bit array? a) OR b) NOT c) XOR d) NAND Answer: NOT 2. Which class in Java can be used to represent bit array? a) BitSet b) BitVector c) BitArray d) BitStream Answer: BitSet 3. What is a bit 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) Array in which elements are not present in continuous locations Answer: Data structure that compactly stores bits 4. Which of the following bitwise operations will you use to set a particular bit to 1? a) OR b) AND c) XOR d) NOR Answer: OR 5. Which of the following bitwise operations will you use to set a particular bit to 0? a) OR b) AND c) XOR d) NAND Answer: AND

Upload: others

Post on 18-Feb-2022

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 500+ Arrays Types MCQs with FREE PDF

livemcqs.com

livemcqs.com

500+ Arrays Types MCQs with FREE PDF

1. Which of the following bitwise operator will you use to invert all the bits in a bit array?

a) OR

b) NOT

c) XOR

d) NAND

Answer: NOT

2. Which class in Java can be used to represent bit array?

a) BitSet

b) BitVector

c) BitArray

d) BitStream

Answer: BitSet

3. What is a bit 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) Array in which elements are not present in continuous locations

Answer: Data structure that compactly stores bits

4. Which of the following bitwise operations will you use to set a particular bit to 1?

a) OR

b) AND

c) XOR

d) NOR

Answer: OR

5. Which of the following bitwise operations will you use to set a particular bit to 0?

a) OR

b) AND

c) XOR

d) NAND

Answer: AND

Page 2: 500+ Arrays Types MCQs with FREE PDF

livemcqs.com

livemcqs.com

6. Which of the following bitwise operations will you use to toggle a particular bit?

a) OR

b) AND

c) XOR

d) NOT

Answer: XOR

7. Which of the following is not an advantage of bit array?

a) Exploit bit level parallelism

b) Maximal use of data cache

c) Can be stored and manipulated in the register set for long periods of time

d) Accessing Individual Elements is easy

Answer: Accessing Individual Elements is easy

8. Which of the following is not a disadvantage of bit array?

a) Without compression, they might become sparse

b) Accessing individual bits is expensive

c) Compressing bit array to byte/word array, the machine also has to support byte/word addressing

d) Storing and Manipulating in the register set for long periods of time

Answer: Storing and Manipulating in the register set for long periods of time

50+ Bit Array MCQs and answer with FREE PDF

9. What is a dynamic array?

a) A variable size data structure

b) An array which is created at runtime

c) The memory to the array is allocated at runtime

d) An array which is reallocated everytime whenever new elements have to be added

Answer: A variable size data structure

10. What is meant by physical size in a dynamic array?

a) The size allocated to elements

b) The size extended to add new elements

c) The size of the underlying array at the back-end

d) The size visible to users

Answer: The size of the underlying array at the back-end

11. The number of items used by the dynamic array contents is its __________

a) Physical size

Page 3: 500+ Arrays Types MCQs with FREE PDF

livemcqs.com

livemcqs.com

b) Capacity

c) Logical size

d) Random size

Answer: Logical size

12. How will you implement dynamic arrays in Java?

a) Set

b) Map

c) HashMap

d) List

Answer: List

13. Which of the following is the correct syntax to declare an ArrayList in Java?

a) ArrayList al = new ArrayList();

b) ArrayList al = new ArrayList[];

c) ArrayList al() = new ArrayList();

d) ArrayList al[] = new ArrayList[];

Answer: ArrayList al = new ArrayList();

14. Array is divided into two parts in ____________

a) Hashed Array Tree

b) Geometric Array

c) Bounded-size dynamic array

d) Sparse Array

Answer: Bounded-size dynamic array

15. Which of the following is a disadvantage of dynamic arrays?

a) Locality of reference

b) Data cache utilization

c) Random access

d) Memory leak

Answer: Memory leak

50+ Dynamic Array MCQs with FREE PDF

16. What are parallel arrays?

a) Arrays of the same size

b) Arrays allocated one after the other

c) Arrays of the same number of elements

Page 4: 500+ Arrays Types MCQs with FREE PDF

livemcqs.com

livemcqs.com

d) Arrays allocated dynamically

Answer: Arrays of the same number of elements

17. Which of the following is a disadvantage of parallel array over the traditional arrays?

a) When a language does not support records, parallel arrays can be used

b) Increased locality of reference

c) Ideal cache behaviour

d) Insertion and Deletion becomes tedious

Answer: Insertion and Deletion becomes tedious

18. Which of the following is an advantage of parallel arrays?

a) Poor locality of reference for non-sequential access

b) Very little direct language support

c) Expensive to shrink or grow

d) Increased Locality of Reference

Answer: Increased Locality of Reference

19. To search for an element in a sorted array, which searching technique can be used?

a) Linear Search

b) Jump Search

c) Binary Search

d) Fibonacci Search

Answer: Binary Search

20. Which of the following is not an application of sorted array?

a) Commercial computing

b) Priority Scheduling

c) Discrete Mathematics

d) Hash Tables

Answer: Hash Tables

21. What is the worst case time complexity of inserting an element into the sorted array?

a) O(nlogn)

b) O(logn)

c) O(n)

d) O(n2)

Answer: O(n)

50+ Parallel Array MCQs with FREE PDF

Page 5: 500+ Arrays Types MCQs with FREE PDF

livemcqs.com

livemcqs.com

22. What is sparsity of a matrix?

a) The fraction of zero elements over the total number of elements

b) The fraction of non-zero elements over the total number of elements

c) The fraction of total number of elements over the zero elements

d) The fraction of total number of elements over the non-zero elements

Answer: The fraction of zero elements over the total number of elements

23. Which of the following is the disadvantage of sparse matrices over normal matrices?

a) Size

b) Speed

c) Easily compressible

d) Algorithm complexity

Answer: Speed

24. 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) An array in which memory is allocated in run time

Answer: An array in which most of the elements have the same value

25. 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) When elements are sorted

Answer: When the array has more occurrence of zero elements

26. 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

Answer: Sparse array is memory efficient

50+ Sparse Array MCQs with FREE PDF

27. LCP array and ______ is used to construct suffix tree.

a) Hash tree

Page 6: 500+ Arrays Types MCQs with FREE PDF

livemcqs.com

livemcqs.com

b) Hash trie

c) Suffix array

d) Balanced tree

Answer: Suffix array

28. What is the time required to locate the occurrences of a pattern P of length m in a string of length

n using suffix array?

a) O(nm)

b) O(n2)

c) O(mnlogn)

d) O(mlogn)

Answer: O(mlogn)

29. If comparison based sorting algorithm is used construct the suffix array, then what will be time

required to construct the suffix array?

a) O(nlogn)

b) O(n2)

c) O(n2logn)

d) O(n2) + O(logn)

Answer: O(n2logn)

30. Which of the following is false?

a) Suffix array is always sorted

b) Suffix array is used in string matching problems

c) Suffix array is always unsorted

d) Suffix array contains all the suffixes of the given string

Answer: Suffix array is always unsorted

31. Suffix array of the string “statistics” is ____________

a) 2 8 7 4 9 0 5 1 6 3

b) 2 7 4 9 8 0 5 1 6 3

c) 2 4 9 0 5 7 8 1 6 3

d) 2 8 7 0 5 1 6 9 4 3

Answer: 2 8 7 4 9 0 5 1 6 3

50+ Suffix Array MCQs with FREE PDF

32. Which of the following don’t use matrices?

a) In solving linear equations

Page 7: 500+ Arrays Types MCQs with FREE PDF

livemcqs.com

livemcqs.com

b) Image processing

c) Graph theory

d) Sorting numbers

Answer: Sorting numbers

33. What is the order of a matrix?

a) number of rows X number of columns

b) number of columns X number of rows

c) number of rows X number of rows

d) number of columns X number of columns

Answer: number of rows X number of columns

34. Which of the following property does not hold for matrix multiplication?

a) Associative

b) Distributive

c) Commutative

d) Additive Inverse

Answer: Commutative

35. How do you allocate a matrix using a single pointer in C?(r and c are the number of rows and

columns respectively)

a) int *arr = malloc(r * c * sizeof(int));

b) int *arr = (int *)malloc(r * c * sizeof(int));

c) int *arr = (int *)malloc(r + c * sizeof(int));

d) int *arr = (int *)malloc(r * c * sizeof(arr));

Answer: int *arr = (int *)malloc(r * c * sizeof(int));

36. Matrix A when multiplied with Matrix C gives the Identity matrix I, what is C?

a) Identity matrix

b) Inverse of A

c) Square of A

d) Transpose of A

Answer: Inverse of A

50+ Matrix MCQs with FREE PDF

37. In what way the Symmetry Sparse Matrix can be stored efficiently?

a) Heap

b) Binary tree

Page 8: 500+ Arrays Types MCQs with FREE PDF

livemcqs.com

livemcqs.com

c) Hash table

d) Adjacency List

Answer: Binary tree

38. The matrix contains m rows and n columns. The matrix is called Sparse Matrix if ________

a) Total number of Zero elements > (m*n)/2

b) Total number of Zero elements = m + n

c) Total number of Zero elements = m/n

d) Total number of Zero elements = m-n

Answer: Total number of Zero elements > (m*n)/2

39. Which of the following is not the method to represent Sparse Matrix?

a) Dictionary of Keys

b) Linked List

c) Array

d) Heap

Answer: Heap

40. Which matrix has most of the elements (not all) as Zero?

a) Identity Matrix

b) Unit Matrix

c) Sparse Matrix

d) Zero Matrix

Answer: Sparse Matrix

41. What is the relation between Sparsity and Density of a matrix?

a) Sparsity = 1 – Density

b) Sparsity = 1 + Density

c) Sparsity = Density*Total number of elements

d) Sparsity = Density/Total number of elements

Answer: Sparsity = 1 – Density

50+ Sparse Matrix MCQs with FREE PDF

42. What is the time complexity of the code that uses self balancing BST for determining the number of

inversions in an array?

a) O(n2)

b) O(n)

c) O(log n)

Page 9: 500+ Arrays Types MCQs with FREE PDF

livemcqs.com

livemcqs.com

d) O(n log n)

Answer: O(n log n)

43. What is the space complexity of the code that uses merge sort for determining the number of

inversions in an array?

a) O(n)

b) O(log n)

c) O(1)

d) O(n log n)

Answer: O(n)

44. Under what condition the number of inversions in an array are maximum?

a) when the array is sorted

b) when the array is reverse sorted

c) when the array is half sorted

d) depends on the given array

Answer: when the array is reverse sorted

45. Under what condition the number of inversions in an array are minimum?

a) when the array is sorted

b) when the array is reverse sorted

c) when the array is half sorted

d) depends on the given array

Answer: when the array is sorted

46. How many inversions are there in the array arr = {1,5,4,2,3}?

a) 0

b) 3

c) 4

d) 5

Answer: 5

50+ Count Inversion MCQs with FREE PDF

47. Which of the following is the predefined function for array reversal in C++?

a) rotate()

b) arr_rotate()

c) array_rotate()

d) rot()

Page 10: 500+ Arrays Types MCQs with FREE PDF

livemcqs.com

livemcqs.com

Answer: rotate()

48. How many arguments are required by the predefined function rotate() in C++?

a) 1

b) 2

c) 3

d) 4

Answer: 3

49. Predefined function rotate() in C++ is available under which header file?

a) math

b) stdio

c) stdlib

d) algorithm

Answer: algorithm

50. Which of the following algorithm to rotate an array has the maximum time complexity?

a) rotate elements one by one

b) juggling algorithm

c) reversal algorithm

d) using a temporary array

Answer: rotate elements one by one

51. What is the time complexity of the juggling algorithm to rotate an array?

a) O(1)

b) O(n)

c) O(d)

d) O(n*d)

Answer: O(n)

50+ Rotation Array Operation MCQs with FREE PDF

52. Which of the following is the predefined function for array reversal in javascript?

a) reverse()

b) arr_reverse()

c) array_reverse()

d) rev()

Answer: reverse()

Page 11: 500+ Arrays Types MCQs with FREE PDF

livemcqs.com

livemcqs.com

53. Predefined function reverse() in C++ is available under which header file?

a) math

b) stdio

c) stdlib

d) algorithm

Answer: algorithm

54. What will be the resulting array after reversing arr[]={3,5,4,2}?

a) 2,3,5,4

b) 4,2,3,5

c) 5,4,2,3

d) 2,4,5,3

Answer: 2,4,5,3

55. How many swaps are required for reversing an array having n elements where n is an odd number?

a) (n-1) / 2

b) n/2

c) (n/2) – 1

d) (n+1)/2

Answer: (n-1) / 2

56. How many swaps are required for reversing an array having n elements where n is an even

number?

a) (n-1) / 2

b) n/2

c) (n/2) – 1

d) (n+1)/2

Answer: n/2

50+ Reversal Array Operation MCQs with FREE PDF

57. In how many different ways we can reach the end of the array arr[]={1,3,5,8,9}?

a) 1

b) 2

c) 3

d) 4

Answer: 4

Page 12: 500+ Arrays Types MCQs with FREE PDF

livemcqs.com

livemcqs.com

58. It is not possible to reach the end of an array if starting element of the array is 0.

a) true

b) false

Answer: true

59. What is the minimum possible time complexity to find the number of steps to reach the end of an

array?

a) O(n)

b) O(n2)

c) O(n3/2)

d) O (1)

Answer: O(n)

60. What will be the minimum number of jumps required to reach the end of the array arr[] =

{1,3,6,3,6,8,5}?

a) 1

b) 2

c) 3

d) not possible to reach the end

Answer: 3

50+ Number of Jumps to Reach End-array Operation MCQs