GATE Indexing Topics
GATE Indexing Topics
1. Indexing:
Indexing is a technique used to quickly locate a record in a database or file. It helps speed up
retrieval operations by reducing the number of records to scan.
2. Types of Indexes:
• Primary Index: An index where the search key is a unique identifier (e.g., primary key).
• Secondary Index: An index where the search key is not unique.
• Clustered Index: The order of records in the database is the same as the index order.
• Non-clustered Index: The records are stored separately, and the index points to the
locations.
• Multilevel Index: An index built on top of another index to optimize search efficiency.
3. Indexing Structures:
• B-Tree Indexing: A balanced tree structure. Each node contains multiple keys.
- Formula: Height of B-tree: h = log_d(N) where d is the order of the tree and N is the
number of nodes.
- Search Time Complexity: O(log N)
• B+ Tree Indexing: A variation of B-tree where all records are stored in leaf nodes.
- Formula: Height: Same as B-tree: h = log_d(N)
- Searching: O(log N)
• Hash Indexing: Uses a hash function to map keys to specific positions.
- Formula: hash(key) = key mod size_of_table
- Search Time Complexity: O(1) (in ideal conditions)
4. Indexing Operations:
• Insertion in B-Tree/B+ Tree: Insert a key while maintaining the tree's balance. Split nodes
if necessary.
• Deletion in B-Tree/B+ Tree: Remove a key and ensure tree properties are maintained.
Merge nodes if necessary.
• Search Operation: Search involves traversing the tree from root to leaf to find the key.
7. Index Maintenance:
Indexes need to be updated when records are added, removed, or modified. In some cases,
indexes can become inefficient over time due to fragmentation.