MCQOPTIONS
Saved Bookmarks
This section includes 721 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.
| 501. |
What is missing in this logic of finding a path in the tree for a given sum (i.e checking whether there will be a path from roots to leaf nodes with given sum)? checkSum(struct bin-treenode *root , int sum) : if(root==null) return sum as 0 else : leftover_sum=sum-root_node-->value //missing |
| A. | code for having recursive calls to either only left tree or right trees or to both subtrees depending on their existence |
| B. | code for having recursive calls to either only left tree or right trees |
| C. | code for having recursive calls to either only left tree |
| D. | code for having recursive calls to either only right trees |
| Answer» B. code for having recursive calls to either only left tree or right trees | |
| 502. |
What may be the psuedo code for finding the size of a tree? |
| A. | find_size(root_node–>left_node) + 1 + find_size(root_node–>right_node) |
| B. | find_size(root_node–>left_node) + find_size(root_node–>right_node) |
| C. | find_size(root_node–>right_node) – 1 |
| D. | find_size(root_node–>left_node + 1 |
| Answer» B. find_size(root_node–>left_node) + find_size(root_node–>right_node) | |
| 503. |
Why we prefer threaded binary trees? |
| A. | storage required by stack and queue is more |
| B. | pointers in most of nodes of a binary tree are NULL |
| C. | difficult to find a successor node |
| D. | all of the mentioned |
| Answer» E. | |
| 504. |
Level order traversal of a tree is formed with the help of |
| A. | breadth first search |
| B. | depth first search |
| C. | dijkstra’s algorithm |
| D. | prims algorithm |
| Answer» B. depth first search | |
| 505. |
How to travel a tree in linkedlist representation? |
| A. | using post order traversing |
| B. | using pre order traversing |
| C. | using post order traversing |
| D. | all of the mentioned |
| Answer» E. | |
| 506. |
Disadvantages of linked list representation of binary trees over arrays? |
| A. | Randomly accessing is not possible |
| B. | Extra memory for a pointer is needed with every element in the list |
| C. | Difficulty in deletion |
| D. | Random access is not possible and extra memory with every elemen |
| Answer» E. | |
| 507. |
Advantages of linked list representation of binary trees over arrays? |
| A. | dynamic size |
| B. | ease of insertion/deletion |
| C. | ease in randomly accessing a node |
| D. | both dynamic size and ease in insertion/deletion |
| Answer» E. | |
| 508. |
Can a tree stored in an array using either one of inorder or post order or pre order traversals be again reformed? |
| A. | yes just traverse through the array and form the tree |
| B. | No we need one more traversal to form a tree |
| C. | No in case of sparse trees |
| D. | None of the mentioned |
| Answer» C. No in case of sparse trees | |
| 509. |
Why is heap implemented using array representations than tree(linked list) representations though both tree representations and heaps have same complexities? for binary heap -insert: O(log n) -delete min: O(log n) for a tree -insert: O(log n) -delete: O(log n) Then why go with array representation when both are having same values ? |
| A. | arrays can store trees which are complete and heaps are by it’s property are complete |
| B. | lists representation takes more memory hence memory efficiency is less and go with arrays |
| C. | array have better caching |
| D. | all of the mentioned |
| Answer» E. | |
| 510. |
Consider a situation of writing a binary tree into a file with memory storage efficiency in mind, is array representation of tree is good? |
| A. | yes because we are overcoming the need of pointers and so space efficiency |
| B. | yes because array values are indexable |
| C. | No it is not efficient in case of sparse trees and remaning cases it is fine |
| D. | No linked list representation of tree is only fine |
| Answer» D. No linked list representation of tree is only fine | |
| 511. |
If the tree is not a complete binary tree then what changes can be made for easy access of children of a node in the array ? |
| A. | every node stores data saying which of its children exist in the array |
| B. | no need of any changes continue with 2w and 2w+1, if node is at i |
| C. | keep a seperate table telling children of a node |
| D. | use another array parallel to the array with tree |
| Answer» B. no need of any changes continue with 2w and 2w+1, if node is at i | |
| 512. |
What is the parent for a node ‘w’ of a complete binary tree in an array representation when w is not 0? |
| A. | floor(w-1/2) |
| B. | ceil(w-1/2) |
| C. | w-1/2 |
| D. | w/2 |
| Answer» B. ceil(w-1/2) | |
| 513. |
What are the children for node ‘w’ of a complete-binary tree in an array representation? |
| A. | 2w and 2w+1 |
| B. | 2+w and 2-w |
| C. | w+1/2 and w/2 |
| D. | w-1/2 and w+1/2 |
| Answer» B. 2+w and 2-w | |
| 514. |
What must be the ideal size of array if the height of tree is ‘l’? |
| A. | 2l-1 |
| B. | l-1 |
| C. | l |
| D. | 2l |
| Answer» B. l-1 | |
| 515. |
Disadvantage of using array representation for binary trees is? |
| A. | difficulty in knowing children nodes of a node |
| B. | difficult in finding the parent of a node |
| C. | have to know the maximum number of nodes possible before creation of trees |
| D. | difficult to implement |
| Answer» D. difficult to implement | |
| 516. |
Binary trees can have how many children? |
| A. | 2 |
| B. | any number of children |
| C. | 0 or 1 or 2 |
| D. | 0 or 1 |
| Answer» D. 0 or 1 | |
| 517. |
Accessing free list very frequently for wide range of addresses can lead to |
| A. | paging |
| B. | segmentation fault |
| C. | memory errors |
| D. | cache problems |
| Answer» B. segmentation fault | |
| 518. |
How are free blocks linked together mostly and in what addressing order? |
| A. | circular linked list and increasing addressing order |
| B. | linked list and decreasing addressing order |
| C. | linked list and in no addressing order |
| D. | none of the mentioned |
| Answer» B. linked list and decreasing addressing order | |
| 519. |
Assume there is a free list which contains nodes and is filled with a value if it is already assigned and the value will be the size of requested block else will be 0. z = startpoint; while ((z < end) && \\ didn't reach end (*z <= len)) \\ too small to satisfy request { assign this block } The above code represents what ? |
| A. | code for first fit |
| B. | code for best fit |
| C. | code for worst fit |
| D. | none of the mentioned |
| Answer» B. code for best fit | |
| 520. |
What are the disadvantages in implementing buddy system algorithm for free lists ? |
| A. | internal fragmentation |
| B. | it takes so much space |
| C. | we no more have the hole lists in order of memory address, so it is difficult to detect if 2 holes remain adjacent in memory and shall be merged into one hole |
| D. | both a and c are correct |
| Answer» E. | |
| 521. |
How does implicit free lists(garbage collection) works in adding memory to free list ? |
| A. | whichever comes last will be added to free list |
| B. | whichever comes first will be added to free list |
| C. | certain blocks cannot be used if there are no pointers to them and hence they can be freed |
| D. | makes a probabilistic guess |
| Answer» D. makes a probabilistic guess | |
| 522. |
What is buddy memory management of free lists ? |
| A. | modified version of first fit |
| B. | buddy allocation keeps several free lists, each one holds blocks which are of one particular size |
| C. | modified version of best fit |
| D. | a tree representation of free lists |
| Answer» C. modified version of best fit | |
| 523. |
What are different ways of implementing free lists and which is simple among them? |
| A. | best fit, first fit, worst fit, simple-first fit |
| B. | best fit, first fit, worst fit, simple-best fit |
| C. | best fit, first fit, worst fit, simple-worst fit |
| D. | best fit simple-best fit |
| Answer» B. best fit, first fit, worst fit, simple-best fit | |
| 524. |
What datastructures can be used in implementing a free list? |
| A. | only linked list |
| B. | linked list or sort trees |
| C. | arrays |
| D. | trees |
| Answer» C. arrays | |
| 525. |
What are implicit and explicit implementations of freelists? |
| A. | garbage collection and new or malloc operators respectively |
| B. | new or malloc and garbage collection respectively |
| C. | implicit implementation is not favored |
| D. | explicit implementation is not favored |
| Answer» B. new or malloc and garbage collection respectively | |
| 526. |
Free lists are used in |
| A. | static memory allocation |
| B. | dynamic memory allocation |
| C. | contagious allocations |
| D. | ) are used for speeding up linked list operations |
| Answer» C. contagious allocations | |
| 527. |
What are the important properties of xor lists |
| A. | X⊕X = 0 |
| B. | X⊕0 = X |
| C. | (X⊕Y)⊕Z = X⊕(Y⊕Z) |
| D. | All of the mentioned |
| Answer» E. | |
| 528. |
Disadvantages of xor lists |
| A. | Almost of debugging tools cannot follow the XOR chain, making debugging difficult |
| B. | You need to remember the address of the previously accessed node in order to calculate the next node’s address |
| C. | In some contexts XOR of pointers is not defined |
| D. | All of the mentioned |
| Answer» E. | |
| 529. |
What does first and last nodes of a xor linked lists contain ? (let address of first and last be A and B) |
| A. | NULL xor A and B xor NULL |
| B. | NULL and NULL |
| C. | A and B |
| D. | NULL xor A and B |
| Answer» B. NULL and NULL | |
| 530. |
What does a xor linked list have ? |
| A. | every node stores the XOR of addresses of previous and next nodes |
| B. | actuall memory address of next node |
| C. | every node stores the XOR of addresses of previous and next two nodes |
| D. | every node stores xor 0 and the current node address |
| Answer» B. actuall memory address of next node | |
| 531. |
What is xor linked list ? |
| A. | uses of bitwise XOR operation to decrease storage requirements for doubly linked lists |
| B. | uses of bitwise XOR operation to decrease storage requirements for linked lists |
| C. | uses of bitwise operations to decrease storage requirements for doubly linked lists |
| D. | just another form of linked list |
| Answer» B. uses of bitwise XOR operation to decrease storage requirements for linked lists | |
| 532. |
What is indexed skip list? |
| A. | it stores width of link in place of element |
| B. | it stores index values |
| C. | array based linked list |
| D. | indexed tree |
| Answer» B. it stores index values | |
| 533. |
How to maintain multi-level skip list properties when insertions and deletions are done? |
| A. | design each level of a multi-level skip list with varied probabilities |
| B. | that cannot be maintained |
| C. | rebalancing of lists |
| D. | reconstruction |
| Answer» B. that cannot be maintained | |
| 534. |
The nodes in a skip list may have many forward references. their number is determined |
| A. | probabilistically |
| B. | randomly |
| C. | sequentially |
| D. | orthogonally |
| Answer» B. randomly | |
| 535. |
To which datastructure are skip lists similar to in terms of time complexities in worst and best cases? |
| A. | balanced binary search trees |
| B. | binary search trees |
| C. | binary trees |
| D. | linked lists |
| Answer» B. binary search trees | |
| 536. |
What is the time complexity improvement of skip lists from linked lists in insertion and deletion? |
| A. | O(n) to O(logn) where n is number of elements |
| B. | O(n) to O(1) where n is number of elements |
| C. | no change |
| D. | O(n) to O(n2) where n is number of elements |
| Answer» B. O(n) to O(1) where n is number of elements | |
| 537. |
Skip lists are similar to which of the following datastructure? |
| A. | stack |
| B. | heap |
| C. | binary search tree |
| D. | balanced binary search tree |
| Answer» E. | |
| 538. |
What is a skip list? |
| A. | a linkedlist with size value in nodes |
| B. | a linkedlist that allows faster search within an ordered sequence |
| C. | a linkedlist that allows slower search within an ordered sequence |
| D. | a tree which is in the form of linked list |
| Answer» C. a linkedlist that allows slower search within an ordered sequence | |
| 539. |
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» C. Square of A | |
| 540. |
What is the disadvantage of matrices? |
| A. | Internal complexity |
| B. | Searching through a matrix is complex |
| C. | Not space efficient |
| D. | All of the mentioned |
| Answer» E. | |
| 541. |
Which of the following are the uses of matrices? |
| A. | In solving linear equations |
| B. | Image processing |
| C. | Graph theory |
| D. | All of the mentioned |
| Answer» E. | |
| 542. |
If column-major order is used, how is the following matrix stored in memory? a b c d e f g h i |
| A. | ihgfedcba |
| B. | abcdefghi |
| C. | cfibehadg |
| D. | adgbehcfi |
| Answer» E. | |
| 543. |
If row-major order is used, how is the following matrix stored in memory? a b c d e f g h i |
| A. | ihgfedcba |
| B. | abcdefghi |
| C. | cfibehadg |
| D. | adgbehcfi |
| Answer» C. cfibehadg | |
| 544. |
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» C. int *arr = (int *)malloc(r + c * sizeof(int)); | |
| 545. |
Which of the following property does not hold for matrix multiplication? |
| A. | Associative |
| B. | Distributive |
| C. | Commutative |
| D. | None of the mentioned |
| Answer» D. None of the mentioned | |
| 546. |
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» B. number of columns X number of rows | |
| 547. |
What are the advantages of sparse matrices over normal matrices? |
| A. | Size |
| B. | Speed |
| C. | Easily compressible |
| D. | All of the mentioned |
| Answer» E. | |
| 548. |
What is sparsity of a matrix? |
| A. | The fraction of zero elements over the total number of elements b |
| 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» B. The fraction of non-zero elements over the total number of elements | |
| 549. |
Suppose the contents of an array A are, A = {1, null, null, null, null, 10}; What would be the size of the array considering it as a normal array and a sparse array? |
| A. | 6 and 6 |
| B. | 6 and 2 |
| C. | 2 and 6 |
| D. | 2 and 2 |
| Answer» C. 2 and 6 | |
| 550. |
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» C. Sparse array is dynamic | |