Last active
March 10, 2019 19:31
-
-
Save pm-dev/b1feaf1f030ca0fd464677c3c902ed0b to your computer and use it in GitHub Desktop.
This file contains 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
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