Skip to content

Instantly share code, notes, and snippets.

@louridas
Created April 8, 2019 10:22
Show Gist options
  • Save louridas/bccae435c45d2337a90d85f2b7a53562 to your computer and use it in GitHub Desktop.
Save louridas/bccae435c45d2337a90d85f2b7a53562 to your computer and use it in GitHub Desktop.
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
@louridas
Copy link
Author

louridas commented Apr 8, 2019

Example implementation of search in a priority queue pq; the search is from node s trying to find a node containing c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment