Question 154Asked in DSSSB TGT Computer Science, 25 Jun 2023, Shift 3 (4:30 PM)

What is the difference between a B-tree and a Hash index in a database?

  1. AA B-tree index is used to sort data in a table, while a Hash index is used to filter data in a table.
  2. BA B-tree index is used for exact match queries and sorts data using a hash function, while a Hash index is used for range queries and sorts data in a hierarchical structure.
  3. CA B-tree index is used for range queries and sorts data in a hierarchical structure, while a Hash index is used for exact match queries and sorts data using a hash function.
  4. DThere is no difference between a B-tree and a Hash index.
Show answerHide answer

Correct answer: (C) A B-tree index is used for range queries and sorts data in a hierarchical structure, while a Hash index is used for exact match queries and sorts data using a hash function.

Explanation

B-tree indexes keep keys in sorted, hierarchical order, so they handle range queries well. Hash indexes use a hash function, which is good for exact-match lookups but not ranges.

From DSSSB TGT Computer Science PYQ, 25 Jun 2023, Shift 3 (4:30 PM)

This is question 154 of DSSSB TGT Computer Science PYQ, 25 Jun 2023, Shift 3 (4:30 PM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.