1. Define Tree with example
A tree is a non-linear data structure consisting of nodes connected by edges, having one root node and subtrees of children. It represents hierarchical relationships. Example: A root node A with children B and C forms a simple tree structure .
2. Construct the Binary Tree by:
A binary tree is constructed by creating a root node and recursively adding left and right child nodes. Each node can have at most two children. Nodes are inserted level-wise or based on given traversal data .
3. Applications of BST
Binary Search Tree is used for efficient searching, insertion, and deletion in O(log n) time. It is used in databases, file systems, auto-complete features, and priority queues .
4. Mean by Expression Tree
An expression tree is a binary tree in which leaf nodes contain operands and non-leaf nodes contain operators. It is used to represent and evaluate arithmetic expressions like a + (b * c) .
5. Define Heap
Heap is a complete binary tree that satisfies the heap property. In a Min-Heap, parent nodes are smaller than children, and in a Max-Heap, parent nodes are greater than children .
6. How will you find the efficiency of algorithm
The efficiency of an algorithm is measured using time complexity and space complexity. It describes how execution time and memory usage grow with input size (Big O notation).
7. Types of Sorting
Sorting is classified into Internal Sorting (data in main memory) and External Sorting (data in secondary memory). Examples include Bubble Sort, Selection Sort, Merge Sort, and Quick Sort .
8. List the 3 levels of Traversal
The three tree traversal methods are Inorder (Left, Root, Right), Preorder (Root, Left, Right), and Postorder (Left, Right, Root) .
9. AVL Tree, List the operation
AVL Tree is a height-balanced binary search tree where balance factor is -1, 0, or 1. Operations include insertion, deletion, searching, and rotations (left, right, left-right, right-left) .
10. Pivot node (example)
A pivot node is the selected element in Quick Sort used to partition the array into smaller and larger elements. Example: In array [10,7,8,9,1,5], 5 can be chosen as pivot .
11. Difference between Minimum Heap deletion and Maximum Heap deletion
In Min-Heap deletion, the smallest element (root) is removed and heapified downward. In Max-Heap deletion, the largest element (root) is removed and heapified to maintain max-heap property .
12. Difference between Internal & External Sorting
Internal sorting is performed when entire data fits in main memory and is faster. External sorting is used when data is large and stored in secondary memory like disk .
13. Complexity of Binary Search
Binary Search has time complexity O(log n) in worst and average cases, and O(1) in best case. It works only on sorted arrays .
14. Define Radix Sorting
Radix Sort is a non-comparative sorting algorithm that sorts numbers digit by digit from least significant to most significant digit. Its time complexity is O(d(n+k)) .
15. Purpose of Hashing
Hashing is used to store and retrieve data efficiently using a hash function that maps keys to indices in a hash table. It provides average time complexity of O(1) for search, insert, and delete operations .
16. Define Linear and Binary Search
Linear Search checks elements sequentially until the key is found and has O(n) complexity. Binary Search divides the sorted array into halves repeatedly to find the key in O(log n) time .