Chapters
1. |
Which of these best describes an array? |
A. | A data structure that shows a hierarchical behaviour |
B. | Container of objects of similar types |
C. | Arrays are immutable once initialised |
D. | Array is not a data structure |
Answer» B. Container of objects of similar types |
2. |
How do you initialize an array in C? |
A. | int arr[3] = (1,2,3); |
B. | int arr(3) = {1,2,3}; |
C. | int arr[3] = {1,2,3}; |
D. | int arr(3) = (1,2,3); |
Answer» C. int arr[3] = {1,2,3}; |
3. |
How do you instantiate an array in Java? |
A. | int arr[] = new int(3); |
B. | int arr[]; |
C. | int arr[] = new int[3]; |
D. | int arr() = new int(3); |
Answer» C. int arr[] = new int[3]; |
4. |
Which of the following is a correct way to declare a multidimensional array in Java? |
A. | int[] arr; |
B. | int arr[[]]; |
C. | int[][]arr; |
D. | int[[]] arr; |
Answer» C. int[][]arr; |
5. |
When does the ArrayIndexOutOfBoundsException occur? |
A. | Compile-time |
B. | Run-time |
C. | Not an error |
D. | Not an exception at all |
Answer» B. Run-time |
6. |
Which of the following concepts make extensive use of arrays? |
A. | Binary trees |
B. | Scheduling of processes |
C. | Caching |
D. | Spatial locality |
Answer» D. Spatial locality |
7. |
What are the advantages of arrays? |
A. | Objects of mixed data types can be stored |
B. | Elements in an array cannot be sorted |
C. | Index of first element of an array is 1 |
D. | Easier to store elements of same data type |
Answer» D. Easier to store elements of same data type |
8. |
What are the disadvantages of arrays? |
A. | Data structure like queue or stack cannot be implemented |
B. | There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size |
C. | Index value of an array can be negative |
D. | Elements are sequentially accessed |
Answer» B. There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size |
9. |
Assuming int is of 4bytes, what is the size of int arr[15];? |
A. | 15 |
B. | 19 |
C. | 11 |
D. | 60 |
Answer» D. 60 |
10. |
In general, the index of the first element in an array is |
A. | 0 |
B. | -1 |
C. | 2 |
D. | 1 |
Answer» A. 0 |
11. |
Elements in an array are accessed |
A. | randomly |
B. | sequentially |
C. | exponentially |
D. | logarithmically |
Answer» A. randomly |
12. |
Which of the following is not a disadvantage to the usage of array? |
A. | Fixed size |
B. | There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size |
C. | Insertion based on position |
D. | Accessing elements at specified positions |
Answer» D. Accessing elements at specified positions |
13. |
What is the time complexity of inserting at the end in dynamic arrays? |
A. | O(1) |
B. | O(n) |
C. | O(logn) |
D. | Either O(1) or O(n) |
Answer» D. Either O(1) or O(n) |
14. |
What is the time complexity to count the number of elements in the linked list? |
A. | O(1) |
B. | O(n) |
C. | O(logn) |
D. | O(n2) |
Answer» B. O(n) |
15. |
What is the space complexity for deleting a linked list? |
A. | O(1) |
B. | O(n) |
C. | Either O(1) or O(n) |
D. | O(logn) |
Answer» A. O(1) |
16. |
Which of these is not an application of linked list? |
A. | To implement file systems |
B. | For separate chaining in hash-tables |
C. | To implement non-binary trees |
D. | Random Access of elements |
Answer» D. Random Access of elements |
17. |
Which of the following is false about a doubly linked list? |
A. | We can navigate in both the directions |
B. | It requires more space than a singly linked list |
C. | The insertion and deletion of a node take a bit longer |
D. | Implementing a doubly linked list is easier than singly linked list |
Answer» D. Implementing a doubly linked list is easier than singly linked list |
18. |
What is the worst case time complexity of inserting a node in a doubly linked list? |
A. | O(nlogn) |
B. | O(logn) |
C. | O(n) |
D. | O(1) |
Answer» C. O(n) |
19. |
What differentiates a circular linked list from a normal linked list? |
A. | You cannot have the ‘next’ pointer point to null in a circular linked list |
B. | It is faster to traverse the circular linked list |
C. | You may or may not have the ‘next’ pointer point to null in a circular linked list |
D. | Head node is known in circular linked list |
Answer» C. You may or may not have the ‘next’ pointer point to null in a circular linked list |
20. |
What is the time complexity of searching for an element in a circular linked list? |
A. | O(n) |
B. | O(nlogn) |
C. | O(1) |
D. | O(n2) |
Answer» A. O(n) |
21. |
Which of the following application makes use of a circular linked list? |
A. | Undo operation in a text editor |
B. | Recursive function calls |
C. | Allocating CPU to resources |
D. | Implement Hash Tables |
Answer» C. Allocating CPU to resources |
22. |
Which of the following is false about a circular linked list? |
A. | Every node has a successor |
B. | Time complexity of inserting a new node at the head of the list is O(1) |
C. | Time complexity for deleting the last node is O(n) |
D. | We can traverse the whole circular linked list by starting from any point |
Answer» B. Time complexity of inserting a new node at the head of the list is O(1) |
23. |
Consider a small circular linked list. How to detect the presence of cycles in this list effectively? |
A. | Keep one node as head and traverse another temp node till the end to check if its ‘next points to head |
B. | Have fast and slow pointers with the fast pointer advancing two nodes at a time and slow pointer advancing by one node at a time |
C. | Cannot determine, you have to pre-define if the list contains cycles |
D. | Circular linked list itself represents a cycle. So no new cycles cannot be generated |
Answer» B. Have fast and slow pointers with the fast pointer advancing two nodes at a time and slow pointer advancing by one node at a time |
24. |
A linear collection of data elements where the linear node is given by means of pointer is called? |
A. | Linked list |
B. | Node list |
C. | Primitive list |
D. | Unordered list |
Answer» A. Linked list |
25. |
In linked list each node contain minimum of two fields. One field is data field to store the data second field is? |
A. | Pointer to character |
B. | Pointer to integer |
C. | Pointer to node |
D. | Node |
Answer» C. Pointer to node |
We're developing a website for study materials for students.
We would love to hear your answers to some of the questions.