CS301 Midterm MCQs PDF

Summary

This document is a collection of multiple-choice questions (MCQs) from a midterm exam for a course on data structures and algorithms (specifically CS301). The questions cover various concepts within the topic. The questions appear to be in a quiz format.

Full Transcript

## Data Structures and Algorithms Quiz ### Question No: 1 of 26 Marks: 1 (Budgeted Time 1 Min) An array x of 100 integers is declared as, Answer (Please select your correct option) - int x = [100]; - int x[100]; - integer array x = 100; - integer x = 100; Correct answer solved by hadi Cell No:03228...

## Data Structures and Algorithms Quiz ### Question No: 1 of 26 Marks: 1 (Budgeted Time 1 Min) An array x of 100 integers is declared as, Answer (Please select your correct option) - int x = [100]; - int x[100]; - integer array x = 100; - integer x = 100; Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 2 of 26 Marks: 1 (Budgeted Time 1 Min) What is the maximum depth of recursive calls a function may make? Answer (Please select your correct option) - 1 - 2 - n (where n is the argument) - There is no fixed maximum Made By: Waqar Siddhu ### Question No: 3 of 26 Marks: 1 (Budgeted Time 1 Min) A Linear Data Structure is the data structure in which data elements are arranged in a sequence or a linear list. Which of the following is Non Linear Data Structure? Answer (Please select your correct option) - Arrays - Linked Lists - Binary Search Trees - Stack Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 4 of 26 Marks: 1 (Budgeted Time 1 Min) The new operation in C++ for dynamically allocating memory returns, Answer (Please select your correct option) - Size of the memory it has allocated - Pointer to the memory it has allocated - Both size and pointer to the memory it has allocated - Value of the memory it has allocated Made By: Waqar Siddhu ### Question No: 5 of 26 Marks: 1 (Budgeted Time 1 Min) In a programmer uses two pointers in the node, ie. one to point to next node and the other to point to the previous node. Answer (Please select your correct option) - Linked list - Doubly-linked list - Array - Structure Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 6 of 26 Marks: 1 (Budgeted Time 1 Min) The expression AB+C* is called? Answer (Please select your correct option) - Prefix expression - Postfix expression - Infix expression - Prefix and Infix expression Made By: Waqar Siddhu ### Question No: 7 of 26 Marks: 1 (Budgeted Time 1 Min) Consider the function X as under int X (int& Value) { return Value; } Now a and b are integers in a calling function. Which one of the following is a valid call to the above function X? Answer (Please select your correct option) - a = X (b); - a = X (&b); - a = X (*b); - a = X (&*b) ; Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 8 of 26 Marks: 1 (Budgeted Time 1 Min) Each node in Binary Search Tree has Answer (Please select your correct option) - 1 pointer - 2 pointers - 3 pointers - 4 pointers Made By: Waqar Siddhu ### Question No: 9 of 26 Marks: 1 (Budgeted Time 1 Min) Suppose n is the number of nodes in a complete Binary Tree, then maximum steps required for a search operation are Answer (Please select your correct option) - $Log_2(n+1)-1$ - $Log_2(n+1)$ - $Log_2(n) - 1$ - $Log_2(n)$ Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 10 of 26 Marks: 1 (Budgeted Time 1 Min) The next field in the last node of a singly-linked list is set to Answer (Please select your correct option) - NAN - 1 - NULL - -1 Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 11 of 26 Marks: 1 (Budgeted Time 1 Min) Consider the following function: void test_a(int n) { cout << n << "; if (n>0) Answer (Please select your correct option) - 420 - 024 - 42 - 24 Made By: Waqar Siddhu ### Question No: 12 of 26 Marks: 1 (Budgeted Time 1 Min) A queue where the dequeue operation does not depend upon FIFO, is called: Answer (Please select your correct option) - enqueue - simple queue - stack - priority queue Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 13 of 26 Marks: 1 (Budgeted Time 1 Min) a \* (b+c)-d is an example of expression. Answer (Please select your correct option) - infix - prefix - postfix - allfix Made By: Waqar Siddhu ### Question No: 14 of 26 Marks: 1 (Budgeted Time 1 Min) Below is a Binary Search Tree (BST). If we delete the value 50 from the root node, what would be the value in the root of the remaining tree? [Image of a Binary Search Tree with root 50, and 2 child nodes: 30, and 80] Answer (Please select your correct option) - 50 - 60 - 70 - 80 Made By: Waqar Siddhu ### Question No: 15 of 26 Marks: 1 (Budgeted Time 1 Min) Consider the following tree: [Image of a binary tree with root 14, left node 2, and right node 11] Answer (Please select your correct option) - 2 - 4 - 6 - 9 Made By: Waqar Siddhu ### Question No: 16 of 26 Marks: 1 (Budgeted Time 1 Min) Which one of the following calling methods does not change the original value of the argument in the calling function? Answer (Please select your correct option) - Call by passing the value of the argument - Call by passing reference of the argument - Call by passing the address of the argument - Call by passing pointer of the argument Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 17 of 26 Marks: 1 (Budgeted Time 1 Min) Which of the following statement is NOT true for reference variable? Answer (Please select your correct option) - Once a reference is created, it cannot be later made to reference another object. - References cannot be NULL. - References can be uninitialized. - It is not possible to refer directly to a reference object after it is defined Made By: Waqar Siddhu ### Question No: 18 of 26 Marks: 1 (Budgeted Time 1 Min) Searching an element in an AVL tree takes maximum time (where n is number of nodes in AVL tree). Answer (Please select your correct option) - $Log_2(n+1)$ - $Log_2(n+1)-1$ - 1.44 Logan - 1.66 Logan Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 19 of 26 Marks: 1 (Budgeted Time 1 Min) In the post-order traversal of a binary search tree, nodes process as: Answer (Please select your correct option) - Left-subtree, Right-subtree, Root - Right-subtree, Root, Left-subtree - Left-subtree, Root, Right-subtree - Right-subtree, Left-subtree, Root Made By: Waqar Siddhu ### Question No: 20 of 26 Marks: 1 (Budgeted Time 1 Min) The main use of AVL tree is: Answer (Please select your correct option) - Searching of data - Storing of data - Insertion of data - Security of data Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 1 of 26 Marks: 1 (Budgeted Time 1 Min) Each operator in a postfix expression refers to the previous operand(s). Answer (Please select your correct option) - One - Two - Three - Four Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 2 of 26 Marks: 1 (Budgeted Time 1 Min) Which one of the following statements is correct? Answer (Please select your correct option) - Array size is fixed once it is created. - Link List size is fixed once it is created. - Binary Search Tree size is fixed once it is created - AVL Tree size is fixed once it is created Made By: Waqar Siddhu ### Question No: 3 of 26 Marks: 1 (Budgeted Time 1 Min) Linked list always contains elements that can be described as, Answer (Please select your correct option) - Redundant - Recursive - Self-referential. - Bidirectional. Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 4 of 26 Marks: 1 (Budgeted Time 1 Min) One difference between a queue and a stack is: Answer (Please select your correct option) - Queues require dynamic memory, but stacks do not. - Stacks require dynamic memory, but queues do not. - Queues use two ends of the structure; stacks use only one. - Stacks use two ends of the structure, queues use only one. Made By: Waqar Siddhu ### Question No: 5 of 26 Marks: 1 (Budgeted Time 1 Min) Stack and Queue can be implemented using Answer (Please select your correct option) - Singly Link List - Binary Tree - Binary Search Tree - AVL Tree Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 6 of 26 Marks: 1 (Budgeted Time 1 Min) New items are added at the of the stack. Answer (Please select your correct option) - Bottom - Middle - Top - Center Made By: Waqar Siddhu ### Question No: 7 of 26 Marks: 1 (Budgeted Time 1 Min) is the stack characteristic but was implemented because of the size limitation of the array. Answer (Please select your correct option) - isFull(), isEmpty() - pop(), push() - isEmpty(), isFull() - push(), pop() Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 8 of 26 Marks: 1 (Budgeted Time 1 Min) Consider the following tree. [Image of a binary tree with root 14, left node 2, and right node 11] Answer (Please select your correct option) - 2 - 3 - 4 - 5 Made By: Waqar Siddhu ### Question No: 9 of 26 Marks: 1 (Budgeted Time 1 Min) The difference between a "Binary Tree (BT)" and a "Binary Search Tree(BST)" is that, Answer (Please select your correct option) - A BST has two children per node whereas a BT can have none, one, or two children per node - In BST, nodes are inserted based on the values they contain - In BT, nodes are inserted based on the values they contain - There is no difference Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 10 of 26 Marks: 1 (Budgeted Time 1 Min) Which of the following operations returns "most recently entered value" from the stack? Answer (Please select your correct option) - Push - Recent - Top - First Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 11 of 26 Marks: 1 (Budgeted Time 1 Min) Which of the following is correct about AVL Tree? Answer (Please select your correct option) - It is identical to BST except height of the left and right subtrees can differ by at least 1. - It is identical to BST except height of the left and right subtrees must differ by at least 1. - It is not identical to BST, its totally different kind of tree. - It is identical to BST except height of the left and right subtrees can differ by at most 1. Made By: Waqar Siddhu ### Question No: 12 of 26 Marks: 1 (Budgeted Time 1 Min) What will be postfix expression of the following infix expression? Infix Expression: a+b\*c-d Answer (Please select your correct option) - ab+c\*d- - abc\+c\*d- - abc\+*d- - abcd+*- Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 13 of 26 Marks: 1 (Budgeted Time 1 Min) In the call by methodology, a copy of the object is passed to the called function. Answer (Please select your correct option) - Reference - Value - Reference & Value - Copy of the object can not be passed Made By: Waqar Siddhu ### Question No: 14 of 26 Marks: 1 (Budgeted Time 1 Min) Consider the following tree, how many levels does it has? [Image of a Binary Tree with root node on top, left node below, and 2 nodes on the bottom] Answer (Please select your correct option) - One - Two - Three - Seven Made By: Waqar Siddhu ### Question No: 15 of 26 Marks: 1 (Budgeted Time 1 Min) Consider the following tree, which statement is correct about this tree. [Image of a Binary Tree with root node 8, left node 5, and right node 9] Answer (Please select your correct option) - 3 and 5 are on the same level - 7 is the parent of 3 - 9 is the root of this tree - 5 is on the second level Made By: Waqar Siddhu ### Question No: 16 of 26 Marks: 1 (Budgeted Time 1 Min) Recursive call of a function use.............. data structure. Answer (Please select your correct option) - Linked List - Queue - Stack - Table Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 17 of 26 Marks: 1 (Budgeted Time 1 Min) In the statement int& a= b; Answer (Please select your correct option) - a and b pointing to two different memory location - a and b are two different names of the same memory location - a and b are two different variable names - b hold the address of variable a Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 18 of 26 Marks: 1 (Budgeted Time 1 Min) The variables which are destroyed automatically when a function's execution ends are: Answer (Please select your correct option) - Global variables - Local variables defined inside function body - Variables (objects) defined inside function body dynamically - Variables (objects) defined inside function body statically Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 19 of 26 Marks: 1 (Budgeted Time 1 Min) The worst case of searching in binary search tree (BST) is: Answer (Please select your correct option) - When the data inserted in BST is sorted - When the height of left sub-tree is greater than right sub-tree - When the height of right sub-tree is greater than left sub-tree - When the tree is balanced Made By: Waqar Siddhu ### Question No: 20 of 26 Marks: 1 (Budgeted Time 1 Min) In simple implementation of stack, isFull() method is used due to .......... Answer (Please select your correct option) - Limitation of array - Strength of array - Linked list connectivity - Complexity of linked list Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 1 of 26 Marks: 1 (Budgeted Time 1 Min) Each node in singly link list has, Answer (Please select your correct option) - 1 pointer - 2 pointers - 3 pointers - 4 pointers Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 2 of 26 Marks: 1 (Budgeted Time 1 Min) Parameters in function call are passed using, Answer (Please select your correct option) - Stack - Queue - Binary Search Tree - AVL Tree Made By: Waqar Siddhu ### Question No: 3 of 26 Marks: 1 (Budgeted Time 1 Min) The method of list data structure removes the element residing at the current position. Answer (Please select your correct option) - Add - Next - Remove - Find Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 4 of 26 Marks: 1 (Budgeted Time 1 Min) Insertion in a linked list can be done at Answer (Please select your correct option) - Front only - Back only - Somewhere in middle only - Front, back and somewhere in the middle Made By: Waqar Siddhu ### Question No: 5 of 26 Marks: 1 (Budgeted Time 1 Min) An array is a group of memory locations. Answer (Please select your correct option) - Scattered - Isolated - Random(non-consecutive) - Consecutive Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 6 of 26 Marks: 1 (Budgeted Time 1 Min) Which of the following applications may use a stack? Answer (Please select your correct option) - Accessing shared resource - Parentheses balancing program - Buffering messages - Waiting list Made By: Waqar Siddhu ### Question No: 7 of 26 Marks: 1 (Budgeted Time 1 Min) Every AVL is Answer (Please select your correct option) - Ternary Tree - Complete Binary Tree - Heap - Binary Search Tree Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 8 of 26 Marks: 1 (Budgeted Time 1 Min) Consider the following infix expression: x-y\*a+b/c Which of the following is a correct equivalent expression for the above? Answer (Please select your correct option) - xy-a\*btc/ - x\*ya-bc/+ - xya\* - bc/+ - xya\*b/ + c Made By: Waqar Siddhu ### Question No: 9 of 26 Marks: 1 (Budgeted Time 1 Min) Non-recursive calls are faster than which of the following calls? Answer (Please select your correct option) - Parameterized - Recursive - Function - Non-Function Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 10 of 26 Marks: 1 (Budgeted Time 1 Min) The balance of a node is the result of "height of left subtree" ......... "height of right subtree". Answer (Please select your correct option) - Plus - Minus - Multiply - Divided by Made By: Waqar Siddhu ### Question No: 11 of 26 Marks: 1 (Budgeted Time 1 Min) Searching an element in an AVL tree takes maximum time (where n is number of nodes in AVL tree). Answer (Please select your correct option) - $Log_2(n+1)$ - $Log_2(n+1)-1$ - 1.44 Logan - 1.66 Logan Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 12 of 26 Marks: 1 (Budgeted Time 1 Min) A complete binary tree having "N" nodes consists of Levels. Answer (Please select your correct option) - $Log_2(N+1) - 1$ - $Log_2(N-1) - 1$ - $Log_2(N+1) + 1$ - $Log_2(N-1) + 1$ Made By: Waqar Siddhu ### Question No: 13 of 26 Marks: 1 (Budgeted Time 1 Min) In the post-order traversal of a binary search tree, nodes process as: Answer (Please select your correct option) - Left-subtree, Right-subtree, Root - Right-subtree, Root, Left-subtree - Left-subtree, Root, Right-subtree - Right-subtree, Left-subtree, Root Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 14 of 26 Marks: 1 (Budgeted Time 1 Min) The simplest case in a BST to delete a node is: Answer (Please select your correct option) - When the node, that is to be deleted is root node - When the node, that is to be deleted has both left and right child - When the node, that is to be deleted has only one child - When the node, that is to be deleted is a leaf node Made By: Waqar Siddhu ### Question No: 15 of 26 Marks: 1 (Budgeted Time 1 Min) If class A defines class B as its friend, then: Answer (Please select your correct option) - Class A can access private members of class B - Class B can access only the public members of class A - Class A can access only the public members of class B - Class B can access private members of class A Made By: Waqar Siddhu ### Question No: 16 of 26 Marks: 1 (Budgeted Time 1 Min) In the statement int& a= b; Answer (Please select your correct option) - a and b pointing to two different memory location - a and b are two different names of the same memory location - a and b are two different variable names - b hold the address of variable a Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 17 of 26 Marks: 1 (Budgeted Time 1 Min) The main use of AVL tree is: Answer (Please select your correct option) - Searching of data - Storing of data - Insertion of data - Security of data Made By: Waqar Siddhu ### Question No: 18 of 26 Marks: 1 (Budgeted Time 1 Min) In simple implementation of stack, isFull() method is used due to .......... Answer (Please select your correct option) - Limitation of array - Strength of array - Linked list connectivity - Complexity of linked list Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 19 of 26 Marks: 1 (Budgeted Time 1 Min) Write in postfix form: 5 \* (9-7) Answer (Please select your correct option) - 5(97-)\* - 59\*7- - 597\- - 5 (97-) Correct answer solved by hadi Cell No:03228043306 Email: [email protected] Made By: Waqar Siddhu ### Question No: 20 of 26 Marks: 1 (Budgeted Time 1 Min) What will be result of following postfix expression? 1 2 3 \* + 2 - Answer (Please select your correct option) - 3 - 4 - (3 + (2 * 9)) - 6 becomes 3 2 9\* + 6 - - 5 - 10 Made By: Waqar Siddhu

Use Quizgecko on...
Browser
Browser