Skip to content

Instantly share code, notes, and snippets.

@pm-dev
Last active March 10, 2019 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pm-dev/b1feaf1f030ca0fd464677c3c902ed0b to your computer and use it in GitHub Desktop.
Save pm-dev/b1feaf1f030ca0fd464677c3c902ed0b to your computer and use it in GitHub Desktop.
using namespace std;
Node* LineManager::lineManagerRec(Vector<Line *>& sortedLines, int start, int end) {
if (start > end) {
return NULL;
}
int middleIdx = (end + start) / 2;
Line *middle = sortedLines[middleIdx];
Node *root = new Node();
root->thisLine = middle;
root->below = lineManagerRec(sortedLines, start, middleIdx - 1) ;
root->above = lineManagerRec(sortedLines, middleIdx + 1, end);
return root;
}
LineManager::LineManager(const Vector<Line *>& sortedLines) {
Node *rootOfBST;
if (lines.size() == 0) {
rootOfBST = new Node();
} else {
rootOfBST = lineManagerRec(sortedLines, 0, sortedLines.size());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment