Created
February 20, 2018 06:51
-
-
Save vardanator/1874c4bb23b526b3637e492201687215 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this is a pseudocode, that's why I didn't bother with "const&"'s and "std::"'s | |
| // though it could have look better, forgive me C++ fellows | |
| vector<Item*> GetItemsByKeywordInSortedOrder(string keyword) | |
| { | |
| // assuming IndexTable is a big hashtable mapping keywords to Item BSTs | |
| BST<Item*> items = IndexTable[keyword]; | |
| // suppose BST has a function InOrderProduceVector(), which creates a vector and | |
| // inserts into it items fetched via in-order traversing the tree | |
| vector<Item*> sorted_result = items.InOrderProduceVector(); | |
| return sorted_result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment