Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
In a binary tree, what is the maximum number of children a node can have?
Not quite. Try another option.
Answer: 2
By definition, a binary tree is a tree data structure in which each node has at most two children, referred to as the left child and the right child.
Question 2 of 50
What is a Complete Binary Tree?
Not quite. Try another option.
Answer: A binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.
This is the standard definition of a Complete Binary Tree, often used in heap data structures.
Question 3 of 50
In an Extended Binary Tree (2-tree), nodes that replace NULL pointers in the original tree are called:
Not quite. Try another option.
Answer: External nodes
An extended binary tree transforms an arbitrary binary tree into a tree where every node has either 0 or 2 children by adding special 'external nodes' (often represented as squares) at NULL links.
Question 4 of 50
What is the maximum number of nodes in a binary tree of height 'h' (where the root is at height 1)?
Not quite. Try another option.
Answer: 2^h - 1
A full binary tree of height h contains a total of 2^h - 1 nodes.
Question 5 of 50
If a binary tree has 'n' nodes, how many edges does it have?
Not quite. Try another option.
Answer: n - 1
In any tree, the number of edges is always one less than the number of nodes, as every node except the root has exactly one incoming edge.
Question 6 of 50
When representing a binary tree using an array (sequential representation) with the root at index 0, what is the index of the left child of the node at index 'i'?
Not quite. Try another option.
Answer: 2i + 1
In 0-based indexing, the left child is at 2i + 1 and the right child is at 2i + 2.
Question 7 of 50
When representing a binary tree using an array with the root at index 0, what is the index of the right child of the node at index 'i'?
Not quite. Try another option.
Answer: 2i + 2
In 0-based indexing, the right child is located at index 2i + 2.
Question 8 of 50
Which memory representation is most memory-efficient for a skewed binary tree?
Not quite. Try another option.
Answer: Linked representation
Linked representation uses memory dynamically for nodes that exist. Sequential representation would allocate a large array with many empty (wasted) spaces for a skewed tree.
Question 9 of 50
In the linked representation of a binary tree, a node structure typically contains:
Not quite. Try another option.
Answer: Data, a pointer to the left child, and a pointer to the right child
A binary tree node requires pointers to both its left and right subtrees in addition to the data payload.
Question 10 of 50
Which traversal visits the root first, then the left subtree, then the right subtree?
Not quite. Try another option.
Answer: Pre-order
Pre-order traversal follows the order: Root -> Left -> Right.
Question 11 of 50
Which traversal visits the left subtree, then the root, then the right subtree?
Not quite. Try another option.
Answer: In-order
In-order traversal follows the order: Left -> Root -> Right.
Question 12 of 50
Which traversal visits the left subtree, then the right subtree, then the root?
Not quite. Try another option.
Answer: Post-order
Post-order traversal follows the order: Left -> Right -> Root.
Question 13 of 50
What is the In-order traversal of a tree with Root A, Left Child B, and Right Child C?
Not quite. Try another option.
Answer: B A C
In-order visits Left (B), then Root (A), then Right (C).
Question 14 of 50
Which traversal is useful for deleting nodes in a binary tree (freeing memory)?
Not quite. Try another option.
Answer: Post-order
Post-order is preferred because it visits children before the parent, allowing the children to be deleted/freed before deleting the parent node.
Question 15 of 50
Performing an In-order traversal on a Binary Search Tree (BST) results in:
Not quite. Try another option.
Answer: Nodes in ascending sorted order
A fundamental property of a BST is that an in-order traversal yields the values in sorted (non-decreasing) order.
Question 16 of 50
To reconstruct a unique binary tree, which combination of traversals is sufficient?
Not quite. Try another option.
Answer: Pre-order and In-order
You generally need In-order plus one other traversal (Pre-order or Post-order) to uniquely reconstruct a binary tree. Pre-order and Post-order alone are insufficient.
Question 17 of 50
What is the primary property of a Binary Search Tree (BST)?
Not quite. Try another option.
Answer: Left child value < Root value < Right child value.
In a BST, for every node, all values in the left subtree are smaller, and all values in the right subtree are larger.
Question 18 of 50
What is the worst-case time complexity for searching in a Binary Search Tree?
Not quite. Try another option.
Answer: O(n)
In the worst case (a skewed tree resembling a linked list), searching requires visiting every node, resulting in O(n).
Question 19 of 50
What is the best-case time complexity for searching in a Binary Search Tree?
Not quite. Try another option.
Answer: O(log n)
In a balanced BST, the height is log(n), making the search operation O(log n).
Question 20 of 50
When inserting a new node into a BST, the new node is always inserted as:
Not quite. Try another option.
Answer: A leaf node
Standard BST insertion traverses down the tree comparing values until a NULL pointer is found, where the new node is attached as a leaf.
Question 21 of 50
Which node has the minimum value in a Binary Search Tree?
Not quite. Try another option.
Answer: The leftmost node in the left subtree
Due to the BST property, the smallest value is found by following left child pointers until the end.
Question 22 of 50
When deleting a node with two children in a BST, which node can replace it to maintain the BST property?
Not quite. Try another option.
Answer: Its In-order predecessor or In-order successor
To maintain the sorted property, a node with two children is typically swapped with the largest value in the left subtree (predecessor) or smallest in the right subtree (successor).
Question 23 of 50
What defines a 'base case' in recursion?
Not quite. Try another option.
Answer: The condition that stops the recursion.
The base case provides a termination condition for the recursive calls, preventing infinite recursion.
Question 24 of 50
What happens if a recursive function does not have a base case?
Not quite. Try another option.
Answer: It causes a Stack Overflow error.
Without a base case, the function calls itself indefinitely, filling up the call stack memory until it overflows.
Question 25 of 50
The Towers of Hanoi problem with 'n' disks requires a minimum of how many moves?
Not quite. Try another option.
Answer: 2^n - 1
The recurrence relation for Towers of Hanoi is T(n) = 2T(n-1) + 1, which solves to 2^n - 1.
Question 26 of 50
In the recursive solution to Towers of Hanoi, how many recursive calls are made to move n-1 disks?
Not quite. Try another option.
Answer: 2
The algorithm involves moving n-1 disks to the auxiliary peg, moving the largest disk, and then moving the n-1 disks to the destination. Thus, 'move n-1' is called twice.
Question 27 of 50
What data structure is implicitly used by the system to handle recursion?
Not quite. Try another option.
Answer: Stack
The system uses a call stack to keep track of function calls, local variables, and return addresses during recursion.
Question 28 of 50
Which sorting algorithm uses the 'Divide and Conquer' strategy and merges two sorted subarrays?
Not quite. Try another option.
Answer: Merge Sort
Merge Sort divides the array into halves, recursively sorts them, and then merges the sorted halves.
Question 29 of 50
What is the time complexity of Merge Sort in the worst case?
Not quite. Try another option.
Answer: O(n log n)
Merge Sort consistently divides the array in half (log n levels) and merges them linearly (n), resulting in O(n log n) for all cases.
Question 30 of 50
Which of the following is a disadvantage of Merge Sort compared to Quick Sort?
Not quite. Try another option.
Answer: It requires O(n) auxiliary space.
Standard Merge Sort is not in-place; it requires a temporary array to merge elements, leading to O(n) space complexity.
Question 31 of 50
Quick Sort uses which element to partition the array?
Not quite. Try another option.
Answer: The pivot
Quick Sort selects a 'pivot' element and partitions the array such that elements less than the pivot are on the left and elements greater are on the right.
Question 32 of 50
What is the worst-case time complexity of Quick Sort?
Not quite. Try another option.
Answer: O(n^2)
The worst case occurs (e.g., already sorted array with standard pivot selection) when the partition is highly unbalanced, reducing the problem size by only 1 each step.
Question 33 of 50
In Quick Sort, if the partition is always balanced (splits array in half), the time complexity is:
Not quite. Try another option.
Answer: O(n log n)
Balanced partitioning results in a recursion tree of depth log n, with O(n) work at each level, yielding O(n log n).
Question 34 of 50
Which sorting algorithm is generally considered the fastest in practice (average case) for arrays?
Not quite. Try another option.
Answer: Quick Sort
Despite its O(n^2) worst case, Quick Sort has a small constant factor and good cache locality, making it faster on average than Merge Sort for arrays.
Question 35 of 50
Is Merge Sort a stable sorting algorithm?
Not quite. Try another option.
Answer: Yes
Merge Sort is stable, meaning it preserves the relative order of equal elements.
Question 36 of 50
What does 'Tail Recursion' mean?
Not quite. Try another option.
Answer: Recursion where the recursive call is the last operation performed.
Tail recursion occurs when the recursive call is the final action in the function, allowing compilers to optimize stack usage.
Question 37 of 50
In a binary tree, a node with no children is called a:
Not quite. Try another option.
Answer: Leaf
A leaf node (or terminal node) is a node that has no children (degree 0).
Question 38 of 50
The height of a binary tree with only a root node is:
Not quite. Try another option.
Answer: 1
By standard convention in many contexts (though some use 0), a single root node represents a height of 1 (counting nodes on the path).
Question 39 of 50
If a Binary Search Tree is created from the sequence [10, 5, 20, 3, 7], which node is the left child of 5?
Not quite. Try another option.
Answer: 3
5 is inserted to the left of 10. 3 is smaller than 10 and smaller than 5, so it becomes the left child of 5.
Question 40 of 50
Which data structure concept is Towers of Hanoi primarily used to illustrate?
Not quite. Try another option.
Answer: Recursion
Towers of Hanoi is a classic textbook problem used to demonstrate the power and logic of recursion.
Question 41 of 50
In Quick Sort, what happens during the 'partition' step?
Not quite. Try another option.
Answer: Elements are placed in their correct sorted position relative to the pivot.
The partition step rearranges the array so that all elements smaller than the pivot are to its left and all larger are to its right.
Question 42 of 50
Merge Sort on a Linked List can be implemented with:
Not quite. Try another option.
Answer: O(1) auxiliary space
Unlike arrays, Merge Sort for linked lists can be implemented using only a few pointers for the merge step, requiring constant extra space (ignoring recursion stack).
Question 43 of 50
The traversal sequence 4, 2, 5, 1, 3 is obtained from a tree. If this is an In-order traversal and the Root is 1, what is the Left Subtree?
Not quite. Try another option.
Answer: {4, 2, 5}
In In-order traversal (Left, Root, Right), if the Root is 1, everything appearing before 1 in the sequence belongs to the Left Subtree.
Question 44 of 50
In a recursive function, the set of local variables is stored in a:
Not quite. Try another option.
Answer: Stack frame
Each recursive call creates a new stack frame (activation record) containing local variables and parameters.
Question 45 of 50
Which of the following is true about Quick Sort regarding stability?
Not quite. Try another option.
Answer: It is not stable.
The standard partition operation involves swapping non-adjacent elements, which can disrupt the relative order of equal keys.
Question 46 of 50
Which traversal is equivalent to a Depth First Search (DFS) on a tree?
Not quite. Try another option.
Answer: Both Pre-order and In-order
Pre-order, In-order, and Post-order are all variations of Depth First Search, whereas Level-order is Breadth First Search.
Question 47 of 50
What is the space complexity of the recursive implementation of Post-order traversal?
Not quite. Try another option.
Answer: O(h) where h is height
The space complexity is determined by the maximum depth of the recursion stack, which corresponds to the height of the tree.
Question 48 of 50
If the Pre-order traversal is AB and In-order traversal is BA, what is the structure of the binary tree?
Not quite. Try another option.
Answer: Root A, Left Child B
Pre-order (Root, Left, Right) = AB implies A is Root. In-order (Left, Root, Right) = BA implies B is to the left of A.
Question 49 of 50
Which operation is NOT supported efficiently by a standard Binary Search Tree?
Not quite. Try another option.
Answer: Random Access
BSTs are node-based structures. Accessing the 'k-th' element requires traversal, unlike arrays which allow O(1) random access.
Question 50 of 50
In the context of recursion, what is 'Indirect Recursion'?
Not quite. Try another option.
Answer: Function A calls Function B, and Function B calls Function A.
Indirect recursion occurs when a function calls another function, which eventually calls the original function again, forming a cycle.
That's unit 4
Answer a few questions and your score shows up here.
Nearly through. Did unit 4 of CSE205 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 4 of CSE205 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.