1.
Algorithm for BFS Traversal of a Graph
BFS explores a graph level by level using a queue.
Steps:
- Enqueue starting node, mark visited.
- Dequeue node, process it, enqueue unvisited neighbors.
2. Applications of Graph
- Social Networks: Represent relationships.
- Network Routing: Find shortest paths.
3. Topological Sort
Ordering vertices such that for every directed edge u -> v, u appears before v.
4. Degree of Vertex
Number of edges connected to a vertex; can be indegree or outdegree.
5. Topological Sort
(Already discussed.)
6. Acyclic Graph
Graph with no cycles, meaning no path starts and ends at same vertex.
7. Multigraph
Graph allowing multiple edges between the same pair of nodes.
8. Hashing vs Rehashing
Hashing: Maps data to table for fast access.
Rehashing: Recomputes hashes when table is resized or too full.
9. Hashing
Hashing maps data via hash function for fast access.
Need: Fast retrieval.
Advantages: Fast access, reduces search time, easy insertion.
10. C Function to Insert in BST
Function recursively inserts data maintaining BST properties.
11. Steps for Creating BST (15, 11, 13, 8, 9, 18, 16)
Insert 15 -> root. 11 left, 13 right of 11, 8 left of 11, 9 right of 8, 18 right of 15, 16 left of 18.
12. Types of Trees
- Binary Tree: Max two children.
- BST: Left child < Node < Right child.
- AVL Tree: Balanced BST.
- B-Tree: Disk storage optimization.
- Heap: Complete binary tree.
13. Tree Traversal Methods
- Inorder: Left, Root, Right.
- Preorder: Root, Left, Right.
- Postorder: Left, Right, Root.
- Level Order: Level by Level.
14. AVL Tree for Mon, Wed, Tue, Sat, Sun, Thur
Balanced using rotations after insertion when imbalance is detected.
15. AVL Tree Concept
AVL Tree maintains balance factor (-1,0,1) after every insertion/deletion.
16. Splay Tree
BST that brings accessed node to the root using rotations to optimize access.
17. Red-Black Tree
Self-balancing BST maintaining color rules: red/black properties.
18. Balance Factor
Difference between height of left and right subtree.
19. Siblings
Nodes sharing same parent in a tree.
20. Degree of Tree
Maximum number of children among all nodes.