// Error a propósito: buscar en un heap como si fuera un árbol de búsqueda.
#include <cstddef>
#include <iostream>
#include <vector>

namespace {

// Baja a la izquierda si la clave es menor, y a la derecha si es mayor. En un heap, eso no sirve.
bool looks_like_bst_search(const std::vector<int>& heap, int key) {
    std::size_t i = 0;
    while (i < heap.size()) {
        if (heap[i] == key) {
            return true;
        }
        i = key < heap[i] ? 2 * i + 1 : 2 * i + 2;
    }
    return false;
}

}  // namespace

int main() {
    std::vector<int> heap = {1, 3, 8, 5, 4};
    for (int key : heap) {
        std::cout << "busca " << key << ": " << (looks_like_bst_search(heap, key) ? "esta" : "NO ESTA") << "\n";
    }
    return 0;
}
