adsa viva
adsa viva
A: An AVL tree is a self-balancing binary search tree where the difference in heights between the left and
right subtrees (balance factor) for any node is at most 1. This ensures O(log n) time complexity for
search, insertion, and deletion operations.
2. B-Trees
Q: What is a B-tree?
A: A B-tree is a self-balancing tree data structure that maintains sorted data and allows searches,
sequential access, insertions, and deletions in logarithmic time. It is commonly used in databases and file
systems.
Each node can have a variable number of children within a predefined range.
3. Heap Trees
Q: What is a heap?
A: A heap is a special tree-based data structure that satisfies the heap property. In a max heap, for any
given node, the value of the node is greater than or equal to the values of its children. In a min heap, the
value of the node is less than or equal to the values of its children.
1. Add the element at the end of the heap (maintaining the complete tree property).
2. Perform "heapify up" (or bubble up) to restore the heap property by comparing the inserted
element with its parent and swapping if necessary.
4. Graph Traversals
Depth-First Search (DFS): Explores as far as possible along each branch before backtracking.
Breadth-First Search (BFS): Explores all neighbors at the present depth prior to moving on to
nodes at the next depth level.
5. Sorting Techniques
Quick Sort: A divide-and-conquer algorithm that selects a 'pivot' and partitions the array.
Merge Sort: A divide-and-conquer algorithm that divides the array into halves, sorts them, and
merges them.
Bubble Sort: A simple comparison-based algorithm that repeatedly steps through the list.
Kruskal's Algorithm: Adds edges in increasing order of weight, ensuring no cycles are formed.
Prim's Algorithm: Grows the MST by adding the smallest edge from the tree to a vertex not yet
in the tree.
You
BLACKBOXAI
Certainly! Here are some viva questions and answers related to the 0/1 Knapsack Problem, Traveling
Salesperson Problem, Optimal Binary Search Trees, N-Queens Problem, and Job Sequencing.
Q: What is the time complexity of the dynamic programming solution for the 0/1 Knapsack Problem?
A: The time complexity of the dynamic programming solution is O(n * W), where n is the number of
items and W is the maximum weight capacity of the knapsack.
Brute Force: Generate all permutations of cities and calculate the total distance for each.
Dynamic Programming: Use memoization to store results of subproblems (Held-Karp
algorithm).
2. Filling the matrix based on the frequency of access and the structure of the tree.
4. N-Queens Problem
3. If a time slot is available, schedule the job; otherwise, move to the next job.