2,024 views
3 votes
3 votes
can BST be used for indexing?

2 Answers

2 votes
2 votes
Yes,BST can be used for indexing,but in that case you will be using one node for a key,which is highly inefficient when it comes to storing huge database,and also SQL query won't work efficiently because in that case we have to go through various node to access particular key.
1 votes
1 votes

Binary search allows you to quickly look up a record by its key, assuming the keys are already sorted. This is especially true if the number of keys is large. 32 key reads would be sufficient to find any single unique key within a collection of two billion sorted keys.

Binary search works this way because each search attempt cuts the number of records to search in half.

That said, databases typically use some other binary tree-like data structure such as b-trees or red-black trees to perform the indexing. Using a binary tree removes the requirement that the list of keys be sorted before searching.

Reference https://stackoverflow.com/questions/9436407/how-binary-search-is-used-in-database-indexing

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
2
0 votes
0 votes
1 answer
4