Which of the following data structures is used to represent a hierarchical structure such as a family tree?
In a binary search tree, which property ensures that all values in the left subtree of a node are smaller than the node's value, and all values in the right subtree are greater?
Which of the following data structures is used to efficiently perform union and find operations in disjoint sets?
What is the time complexity of searching for an element in a balanced binary search tree with n elements?
Which of the following statements about Fenwick trees (Binary Indexed Trees) is true?
Consider the following code snippet:
#include <iostream>
using namespace std;
struct Node {
int data;
Node* left;
Node* right;
};
int main() {
Node* root = new Node;
root->data = 10;
root->left = new Node;
root->left->data = 20;
root->left->left = NULL;
root->left->right = NULL;
root->right = new Node;
root->right->data = 30;
root->right->left = NULL;
root->right->right = NULL;
cout << root->left->data << endl;
return 0;
}
What will be the output of the above code?
Which of the following data structures is most commonly used to represent a tree?
Which traversal technique visits the left subtree, then the root, and finally the right subtree of a binary tree?
What is the time complexity to search for an element in a binary search tree (BST) with 'n' nodes in the worst case?