diff options
Diffstat (limited to 'Sources/DataStructure.cpp')
-rw-r--r-- | Sources/DataStructure.cpp | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/Sources/DataStructure.cpp b/Sources/DataStructure.cpp index b82f908..91fdf86 100644 --- a/Sources/DataStructure.cpp +++ b/Sources/DataStructure.cpp @@ -23,24 +23,16 @@ public: parent = theParent; parent->children.push_back(this); } - - vector<Node *> getChildren() { - return children; - } - - void setKey(int theKey) { - key = theKey; - } }; int treeLevelCounter(vector<Node> &nodes, int rootIndex) { int levelCounter = 1; queue<Node *> q; int popCount = 0; - int childrenCount = nodes[rootIndex].getChildren().size(); + int childrenCount = nodes[rootIndex].children.size(); int grandChildrenCount = 0; for (int i = 0; i < childrenCount; i++) { - q.push(nodes[rootIndex].getChildren()[i]); + q.push(nodes[rootIndex].children[i]); } while (!q.empty()) { if (popCount < childrenCount) { @@ -67,9 +59,8 @@ int getHeight(vector<int> &a) { vector<Node> nodes; nodes.resize(a.size()); int rootIndex = 0; - for (int i = 0; i < a.size(); i++) { + for (size_t i = 0; i < a.size(); i++) { int parentIndex = a[i]; - nodes[i].setKey(i); if (parentIndex == -1) { rootIndex = i; } else { |