Created
April 8, 2019 10:22
-
-
Save louridas/bccae435c45d2337a90d85f2b7a53562 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
def find_in_pq(pq, s, c): | |
if get_data(pq, s) == c: | |
return s | |
elif get_data(pq, s) > c: | |
return None | |
found_below = None | |
for i in children(pq, s): | |
found_below = find_in_pq(pq, i, c) | |
if found_below: | |
return found_below | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example implementation of search in a priority queue
pq
; the search is from nodes
trying to find a node containingc
.