DEV Community

Leo
Leo

Posted on

heap minchild

hpp

#ifndef heap_hpp
#define heap_hpp

#include <stdio.h>
#include <iostream>
#include <cassert>
using namespace std;

class heap {

  int parent(int i) { return (i - 1) / 2; }
  int left(int i) { return 2 * i + 1; }
  int right(int i) { return 2 * i + 2; }

  int n; // capacidad
  int s; // tamaño

  int *a; // arreglo

public:

  heap(int);
  ~heap();

void ins(int);
int tout();
int minChild(int);

int capacity() const { return n; }
int size() const { return s; }

bool empty() const { return s == 0; }
bool full() const { return s == n; }

void print();
};

#endif /* stack_hpp */
Enter fullscreen mode Exit fullscreen mode

Top comments (0)