diff options
-rw-r--r-- | Sources/DataStructure.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Sources/DataStructure.cpp b/Sources/DataStructure.cpp index ebb4c2e..e9332c4 100644 --- a/Sources/DataStructure.cpp +++ b/Sources/DataStructure.cpp @@ -13,7 +13,7 @@ using std::endl; class TreeOrders { public: int n; - vector<int> key; + vector<long> key; vector<int> left; vector<int> right; @@ -30,7 +30,7 @@ public: bool is_Bst() { if (key.size()==0) return true; std::stack<int> keyIndexStack; - vector<int> result; + vector<long> result; bool walkLeft = true; int currentIndex = 0; keyIndexStack.push(currentIndex); @@ -44,14 +44,14 @@ public: int i = keyIndexStack.top(); keyIndexStack.pop(); if (result.size() > 0) { - if (key[i] <= result[(result.size()-1)]) return false; + if (key[i] < result[(result.size()-1)]) return false; } result.push_back(key[i]); walkLeft = false; } } else { if (right[currentIndex] != -1) { - if (key[right[currentIndex]] <= key[currentIndex]) return false; + if (key[right[currentIndex]] < key[currentIndex]) return false; currentIndex = right[currentIndex]; keyIndexStack.push(currentIndex); walkLeft = true; |