in DS
1,175 views
2 votes
2 votes

When a user submits a query, a search engine does the following. For every webpage that has been visited by the search engine, it computes a score indicating how relevant that page is to the query. Finally, it reports the pages with the top k scores on the screen, for a number $k$ specified by the user. A good data structure for accumulating the scores and ranking them is:

  1. a queue
  2. a heap
  3. a stack
  4. a binary search tree
in DS
1.2k views

2 Answers

0 votes
0 votes
Ans D) a binary search tree

say a BST we have increasing or decreasing order

So, rather than heap it can can check top k score easily

Say search engine search for top 5 DBMS scores

So, first go to branch of BST which gives DBMS score and then find top five scores

3 Comments

Hi, can you explain it a bit more.
0
0
official answer given is (B)Heap.

Let n be the number of pages visited by the search engine at the time a query is submitted. Assume that it takes constant time to compute the relevance score for each page w.r.t. a query. Then it takes O(n) time to compute the relevance scores, a further O(n) time to build a heap of n relevance scores, and O(k · log n) time for k delete-max operations to return the top k scores.

(from cmi answer key)
0
0
Why will it delete the scores, doesn’t it need them for future references?
0
0
0 votes
0 votes

Answer:

Related questions