Browse Source

Fix two off-by-one errors in MinHeap::print_heap()

Ian Goldberg 7 months ago
parent
commit
1270ae19f1
1 changed files with 2 additions and 2 deletions
  1. 2 2
      heap.cpp

+ 2 - 2
heap.cpp

@@ -509,8 +509,8 @@ void MinHeap::init(MPCTIO tio, yield_t & yield, size_t n) {
 void MinHeap::print_heap(MPCTIO tio, yield_t & yield) {
     auto HeapArray = oram.flat(tio, yield);
     auto Pjreconstruction = HeapArray.reconstruct(); 
-    for (size_t j = 0; j <= num_items; ++j) {
-        if(2 * j < num_items) { 
+    for (size_t j = 1; j <= num_items; ++j) {
+        if(2 * j <= num_items) { 
             std::cout << j << "-->> HeapArray[" << j << "] = " <<   Pjreconstruction[j].share() << ", children are: " << Pjreconstruction[2 * j].share() << " and " << Pjreconstruction[2 * j + 1].share() <<  std::endl;
         } else {
             std::cout << j << "-->> HeapArray[" << j << "] = " << std::dec << Pjreconstruction[j].share() << " is a LEAF " <<  std::endl;