#ifndef INT_BST_H
#define INT_BST_H

#include <stdio.h>
#include <stdlib.h>

#include <stdbool.h>

/* 
 * simple implementation of binary search tree of ints
 */

/* data structure for tree node */
typedef struct int_bst_node {
    int data;
    struct int_bst_node * left;
    struct int_bst_node * right;
} int_bst_node_t;

/* 
 * insert n into *t_p
 * does nothing if n is already in the tree
 * returns true if insertion succeeded, false otherwise (e.g., malloc error)
 */
bool int_bst_insert(int_bst_node_t ** t_p, int n);

/* 
 * find n in t
 */
bool int_bst_find(int_bst_node_t * t, int n);

/* 
 * remove n from *t_p
 * OPTIONAL operation -- your code can just print an error message
 * and otherwise do nothing
 */
void int_bst_remove(int_bst_node_t ** t_p, int n);

/*
 * remove all nodes from *t_p and set (*t_p) to NULL
 */
void int_bst_remove_all(int_bst_node_t ** t_p);

/*
 * print all elements of t to output stream f using format fmt
 */
void int_bst_print_elements(int_bst_node_t * t, FILE * f, char * fmt);

/*
 * print all elements of t to output stream f in tree form
 * (see sample output for one way to do this -- or you may have
 * a better idea)
 */
void int_bst_print_elements(int_bst_node_t * t, FILE * f, char * fmt);
void int_bst_print_as_tree(int_bst_node_t * t, FILE * f);

#endif /* ifndef INT_BST_H */