1: sort Q by the length of each term's posting list
2: t = shift Query
3: posting_list = FetchList(term)
4: for all t ∈ Q do
5: t = shift Query
6: posting_list = Intersect(posting_list,t)
7: end for
8: array = NewArray()
9: for all Di ∈ DocIDs(posting_list) do
10: arrayi =CalcRelevancy(Q,Di) or GetAttribute(Di)
11: end for
12: HeapSortK(array)
13: Identify the k greatest arrayi values and return the corresponding documents.