Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Non-Linear Data StructuresEasy
Q1. What is a binary tree?
- A.A directed graph with no cycles at all
- B.A tree with exactly 2 total internal nodes
- C.A tree where each node has at most 2 children✓ Correct
- D.A tree where each node has at most 3 children
Explanation
A binary tree is a tree data structure where each node has at most two children, referred to as left and right child.
Report an error in this question
Non-Linear Data StructuresEasy
Q2. What is a graph in data structures?
- A.A chart used for data visualization
- B.A type of contiguous memory array
- C.A sequential linear data structure
- D.A collection of vertices and edges✓ Correct
Explanation
A graph is a non-linear data structure consisting of vertices (nodes) and edges (connections between vertices).
Report an error in this question
Non-Linear Data StructuresEasy
Q3. What is a heap?
- A.A type of directed graph with cycles
- B.A complete binary tree with heap property✓ Correct
- C.A sorted array-based storage structure
- D.A variant of a hash table with chains
Explanation
A heap is a complete binary tree where each node satisfies the heap property (max-heap: parent >= children, min-heap: parent <= children).
Report an error in this question
Non-Linear Data StructuresEasy
Q4. What is the root of a tree?
- A.The node with the most children
- B.The topmost node with no parent✓ Correct
- C.The node with no children at all
- D.The leftmost node in the tree
Explanation
The root is the topmost node in a tree that has no parent. All other nodes are descendants of the root.
Report an error in this question
Non-Linear Data StructuresEasy
Q5. What is the maximum number of nodes in a binary tree of height h?
- A.2^h - 1
- B.h^2
- C.2h
- D.2^(h+1) - 1✓ Correct
Explanation
A binary tree of height h can have at most 2^(h+1) - 1 nodes (when it is a complete/perfect binary tree, counting height from 0).
Report an error in this question
Non-Linear Data StructuresEasy
Q6. What is the degree of a vertex in an undirected graph?
- A.The assigned weight of the given vertex
- B.The number of edges incident to the vertex✓ Correct
- C.The total number of vertices in the graph
- D.The shortest path length from the vertex
Explanation
The degree of a vertex in an undirected graph is the number of edges connected to that vertex.
Report an error in this question
Non-Linear Data StructuresEasy
Q7. What is a leaf node?
- A.A node with two children
- B.A node with no children✓ Correct
- C.The root node itself
- D.A node with one child
Explanation
A leaf node (also called an external node) is a node that has no children.
Report an error in this question
Non-Linear Data StructuresEasy
Q8. What is a Binary Search Tree (BST)?
- A.A binary tree where left child > parent > right child
- B.A tree data structure with exactly two total nodes
- C.A binary tree where left child < parent < right child✓ Correct
- D.A balanced tree structure that is always complete
Explanation
In a BST, for each node, all values in the left subtree are less than the node's value, and all values in the right subtree are greater.
Report an error in this question
Non-Linear Data StructuresEasy
Q9. What is an undirected graph?
- A.A graph where edges have no direction✓ Correct
- B.A graph with no edges at all
- C.A hierarchical tree structure
- D.A graph where edges have direction
Explanation
In an undirected graph, edges have no direction; if there is an edge between A and B, you can traverse it in both directions.
Report an error in this question
Non-Linear Data StructuresHard
Q10. What is the time complexity of building a heap from an unsorted array of n elements?
- A.O(n log n)
- B.O(n)✓ Correct
- C.O(log n)
- D.O(n^2)
Explanation
Using the bottom-up heapify approach (Floyd's algorithm), a heap can be built in O(n) time, as most nodes are near the leaves.
Report an error in this question
Non-Linear Data StructuresHard
Q11. What is the time complexity of deleting the root from a max-heap of n elements?
- A.O(n log n)
- B.O(n)
- C.O(1)
- D.O(log n)✓ Correct
Explanation
Deleting the root involves replacing it with the last element and performing heapify-down, which takes O(log n).
Report an error in this question
Non-Linear Data StructuresMedium
Q12. What is the worst-case time complexity of search in an unbalanced BST?
- A.O(log n)
- B.O(n^2)
- C.O(1)
- D.O(n)✓ Correct
Explanation
An unbalanced BST can degrade to a linked list (skewed tree), making search O(n) in the worst case.
Report an error in this question
Non-Linear Data StructuresMedium
Q13. In a max-heap, where is the maximum element?
- A.At the root✓ Correct
- B.At the last level
- C.At a leaf node
- D.It could be anywhere
Explanation
In a max-heap, the maximum element is always at the root because every parent is greater than or equal to its children.
Report an error in this question
Non-Linear Data StructuresHard
Q14. What is a threaded binary tree?
- A.A tree where null pointers become in-order links✓ Correct
- B.A binary tree with multiple root nodes
- C.A tree with thread-safe atomic operations
- D.A tree used in multithreading concurrency
Explanation
In a threaded binary tree, null left/right pointers are replaced with pointers to the in-order predecessor/successor, enabling efficient traversal without a stack.
Report an error in this question
Non-Linear Data StructuresHard
Q15. In a directed graph with V vertices, what is the maximum number of edges?
- A.V^2
- B.V
- C.V(V-1)✓ Correct
- D.V(V-1)/2
Explanation
In a directed graph without self-loops, each pair of vertices can have two directed edges (one in each direction), giving V(V-1) maximum edges.
Report an error in this question
Non-Linear Data StructuresEasy
Q16. How is a graph typically represented?
- A.Using adjacency matrix or list✓ Correct
- B.Using singly linked lists only
- C.Using stack data structures
- D.Using simple arrays only
Explanation
Graphs are commonly represented using an adjacency matrix (2D array) or an adjacency list (array of lists).
Report an error in this question
Non-Linear Data StructuresHard
Q17. What is a B-tree of order m?
- A.A tree data structure with m distinct roots
- B.A self-balancing tree with at most m children✓ Correct
- C.A binary tree with exactly m total levels
- D.A graph with m connected components total
Explanation
A B-tree of order m is a self-balancing search tree where each node can have at most m children, commonly used in databases and file systems.
Report an error in this question
Non-Linear Data StructuresMedium
Q18. What type of graph has edges with associated weights?
- A.Weighted graph✓ Correct
- B.Directed graph
- C.Bipartite graph
- D.Complete graph
Explanation
A weighted graph assigns a numerical weight (cost, distance, etc.) to each edge.
Report an error in this question
Non-Linear Data StructuresHard
Q19. What is a bipartite graph?
- A.A graph divisible into two disjoint vertex sets✓ Correct
- B.A fully connected complete graph structure
- C.A graph with exactly two vertices in total
- D.A graph with exactly two connected components
Explanation
A bipartite graph's vertices can be partitioned into two sets such that every edge connects a vertex from one set to the other. It contains no odd-length cycles.
Report an error in this question
Non-Linear Data StructuresMedium
Q20. What is the space complexity of an adjacency matrix for a graph with V vertices?
- A.O(V)
- B.O(V + E)
- C.O(E)
- D.O(V^2)✓ Correct
Explanation
An adjacency matrix uses a V × V 2D array, requiring O(V^2) space regardless of the number of edges.
Report an error in this question
Non-Linear Data StructuresMedium
Q21. What is the in-order traversal of a BST with values 4, 2, 6, 1, 3, 5, 7 (root=4)?
- A.1, 2, 3, 4, 5, 6, 7✓ Correct
- B.4, 2, 1, 3, 6, 5, 7
- C.4, 2, 6, 1, 3, 5, 7
- D.1, 3, 2, 5, 7, 6, 4
Explanation
In-order traversal of a BST visits nodes in sorted (ascending) order: left, root, right.
Report an error in this question
Non-Linear Data StructuresHard
Q22. How many distinct BSTs can be formed with n distinct keys?
- A.2^n (powers of two)
- B.n^2 (square of n)
- C.C(n) the Catalan number✓ Correct
- D.n! (factorial of n)
Explanation
The number of structurally distinct BSTs with n keys is the n-th Catalan number: C(n) = (2n)! / ((n+1)! * n!).
Report an error in this question
Non-Linear Data StructuresMedium
Q23. What is the space complexity of an adjacency list for a graph with V vertices and E edges?
- A.O(E)
- B.O(V^2)
- C.O(V + E)✓ Correct
- D.O(V)
Explanation
An adjacency list stores V lists (one per vertex) with a total of E entries across all lists, giving O(V + E) space.
Report an error in this question
Non-Linear Data StructuresHard
Q24. What is the minimum number of nodes in an AVL tree of height h?
- A.N(h) = N(h-1) + N(h-2) + 1✓ Correct
- B.2^(h+1) - 1
- C.2^h
- D.h + 1
Explanation
The minimum number of nodes follows the recurrence N(h) = N(h-1) + N(h-2) + 1, similar to Fibonacci numbers.
Report an error in this question
Non-Linear Data StructuresMedium
Q25. What is the time complexity of searching in a balanced BST?
- A.O(log n)✓ Correct
- B.O(n log n)
- C.O(1)
- D.O(n)
Explanation
In a balanced BST, the height is O(log n), so search operations take O(log n) time.
Report an error in this question
Non-Linear Data StructuresMedium
Q26. What is a full binary tree?
- A.A tree with the maximum number of nodes
- B.A tree where every level is completely filled
- C.A tree where every node has 0 or 2 children✓ Correct
- D.A tree where all leaves are at same depth
Explanation
A full (or proper/strict) binary tree is one where every node has either 0 or 2 children, never just 1.
Report an error in this question
Non-Linear Data StructuresMedium
Q27. What is the time complexity of inserting an element into a max-heap?
- A.O(n)
- B.O(1)
- C.O(log n)✓ Correct
- D.O(n log n)
Explanation
Insertion into a heap involves placing the element at the end and bubbling up, which takes O(log n) due to the tree height.
Report an error in this question
Non-Linear Data StructuresMedium
Q28. What is a complete binary tree?
- A.A tree where every node has exactly 2 children always
- B.A tree where all leaf nodes are at the same level
- C.A tree with the maximum possible depth for its nodes
- D.A tree with all levels full except possibly the last level✓ Correct
Explanation
A complete binary tree has all levels fully filled except possibly the last level, which is filled from left to right.
Report an error in this question
Non-Linear Data StructuresHard
Q29. What is a Red-Black tree's maximum height for n nodes?
- A.n/2
- B.n
- C.log n
- D.2 log(n+1)✓ Correct
Explanation
A Red-Black tree guarantees height at most 2 log(n+1), ensuring O(log n) operations.
Report an error in this question
Non-Linear Data StructuresHard
Q30. What is the difference between a strongly connected and weakly connected directed graph?
- A.Strongly connected means directed paths exist between all pairs; weakly only without directions✓ Correct
- B.There is no meaningful difference between strongly and weakly connected directed graphs
- C.Strongly connected graphs always contain more edges than weakly connected directed graphs
- D.Weakly connected graphs always have more vertices and edges than strongly connected ones
Explanation
A strongly connected directed graph has a directed path between every pair of vertices. A weakly connected graph is connected only when edge directions are ignored.
Report an error in this question