Q:

Binary Tree to Heap Tree Conversion - Stuck in infinite loop

While working on a problem, I have tried the following solution.  Somehow my output is stuck into infinite loop and not printing result or updated heap tree. 
Given a tree where the left and right subtrees are min heaps, but the root node does not maintain the min heap property.  Your code should modify the tree rooted at Node* n so it is a min heap. ( This means you need to satisfy the min heap property:
it is okay for a node's value to be equal to one or both of its children, but the node's value must not be greater than either of its children.  You do not have to try to balance the tree or make it a complete tree.)  
#include <iostream>
#include <string>

You have the following class Node already defined. 
You cannot change this class definition, so it is
shown here in a comment for your reference only:

class Node {
public:
  int value;
  Node *left, *right;
  Node(int val = 0) { value = val; left = right = nullptr; }
  ~Node() {
    delete left;
    left = nullptr;
    delete right;
    right = nullptr;
  }
};

This function has also previously been defined for you:

void printTreeVertical(const Node* n);

You can use it to print a verbose, vertical diagram of
a tree rooted at n. In this vertical format, a left child
is shown above a right child in the same column.  If no
child exists, [null] is displayed. 

*/

void downHeap(Node *n) {
    Node *curr = new Node();
    Node *mino = new Node();

  if (n == nullptr ){
    return;
  } else if (n->left->value > n->value & n->right->value > n->value){
    return;
  // } else if (n->left== nullptr & n->right== nullptr) {
  //   return;

  //   } 
  } else {
    // node* curr = new Node(n)
    // n = new Node((std::min(n->left->value, n->right->value));
    // if (n->left->value)
    while(n->left!= nullptr & n->right!= nullptr){
      if (n->left == nullptr){
        mino = n->right;
      } else if (n->right == nullptr) {
        mino = n->left;
      } else {
        mino = (std::min(n->left, n->right));
      }

      std::cout << n->value << std::endl;
      std::cout << mino->value << std::endl;

        if(n->value > mino-> value){
            curr->value = n->value;
            n->value = mino->value;
            mino->value = curr->value;
            std::cout << n->value << std::endl;
            std::cout << mino->value << std::endl;
            downHeap(mino);
          }
        }
        return;
      }
  }

  // Implement downHeap() here. 

// You can also use this compact printing function for debugging. 
void printTree(Node *n) {
  if (! n) return;
  std::cout << n->value << "(";
  printTree(n->left);
  std::cout << ")(";
  printTree(n->right);
  std::cout << ")";
}

int main() {
  Node *n = new Node(100);
  n->left = new Node(1);
  n->left->left = new Node(3);
  n->right = new Node(2);
  n->right->left = new Node(3);
  n->right->right = new Node(4);
  n->right->right->right = new Node(5);
  std::cout << std::endl << "BEFORE - Vertical printout:" << std::endl;
  printTreeVertical(n);

  downHeap(n);

  std::cout << "Compact printout:" << std::endl;
  printTree(n);
  std::cout << std::endl << " AFTER Vertical printout:" << std::endl;
  printTreeVertical(n);

  delete n;
  n = nullptr;

  return 0;
}

Please suggest what I am missing.  I feel I am making it too complicated.  Also, I do not have any other function like swap for converting the binary tree into heap min.  I am not using an array or vector as well.  So, if you can provide me simple solution I will appreciate it.  

A:

Your primary problem is this line of code:
    mino = (std::min(n->left, n->right));

Here, you're comparing two pointers when you really want to compare the values in the two objects you're referring to, and return a pointer to the object that has the smaller value.  That is:
mino = (n->left->value < n->right->value) ?  n->left : n->right;

Also in this line of code:
} else if (n->left->value > n->value & n->right->value > n->value){

You probably want && (logical AND) rather than & (bitwise AND).  See https://www.geeksforgeeks.org/what-are-the-differences-between-bitwise-and-logical-and-operators-in-cc/.
Finally, your code formatting is a little off so it's difficult to tell, but it looks like the return statement is outside the while loop in your downHeap function.  If it is outside the loop body, then that could lead to an infinite loop.