Explorar o código

Off-by-one error in MinHeap::verify_heap_property

Ian Goldberg %!s(int64=2) %!d(string=hai) anos
pai
achega
8a2dddba94
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      heap.cpp

+ 1 - 1
heap.cpp

@@ -217,7 +217,7 @@ void MinHeap::verify_heap_property(MPCTIO tio, yield_t & yield) {
         #endif
     }
     
-    for (size_t j = 2; j < num_items; ++j) {
+    for (size_t j = 2; j <= num_items; ++j) {
         if (heapreconstruction[j/2] > heapreconstruction[j]) {
             std::cout << "heap property failure\n\n";
             std::cout << "j = " << j << std::endl;