Skip to content

Instantly share code, notes, and snippets.

@joboccara
Created January 9, 2018 00:24
Show Gist options
  • Save joboccara/7ff4de5262e11655b315d830f856416f to your computer and use it in GitHub Desktop.
Save joboccara/7ff4de5262e11655b315d830f856416f to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#include <queue>
size_t leftChild(size_t index)
{
return (index + 1) * 2 - 1;
}
size_t rightChild(size_t index)
{
return (index + 1) * 2;
}
std::vector<int> extractSubHeap(std::vector<int> const& heap, size_t subRootIndex)
{
return {};
}
int main()
{
std::vector<int> heap = {9, 8, 6, 7, 4, 5, 2, 0, 3, 1};
std::vector<int> subHeap = extractSubHeap(heap, 1);
for (int node : subHeap)
{
std::cout << node << ' ';
}
std::cout << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment