Meine Frage, wie folgend:Wie eine Datenstruktur entwerfen, die eine Mischung aus hashtable ist und Heap
eine Liste von Triple gegeben, und sie sind in einer Datenstruktur namens hash_heap gespeichert (Ich bin nicht sicher über die Name, ich meine nur, es sollte die Mischung aus Hashtabelle und Heap sein). Und ich hoffe, die Datenstruktur bietet folgende Methoden,
index_by_first_col(key) // the method could help find the a triple stored in it by matching the first column. It expects the searching is running at constant time
get_min_by_third_col() // the method get the minimum triple sort according to the third column, it is also expects the method is running at constant time.
insert_new_elt(triple) // add new trip, running at constant time
Ist es möglich, einige Datenstruktur wie folgt zu implementieren? Ich weiß, Hashtable konnte die erste Methode unterstützen und Heap konnte die zweite und dritte Methode unterstützen, aber ich weiß nicht, wie man sie miteinander vermischt. Irgendwelche Ideen?
Danke!
Ich denke, das wurde schon einmal gefragt: http://stackoverflow.com/questions/3285168/data-structure-to-store-key-value-pairs-and-retrive-the-key-for-the-lowest -Wert – majelbstoat
Beachten Sie, dass ein Heap Ihre dritte Methode nicht unterstützt, einfügen in einem Heap ist O (log n). –