Data Structures Lerax  v3.0-101-gb1f7
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
bst.h File Reference
#include "../binary-tree.h"

Go to the source code of this file.

Macros

#define Type   BINARY_NODE_TYPE
#define BST_EMPTY   (BSTree*) 0

Typedefs

typedef struct BinaryNode BSTree
 This module define a Abstract Data Type for the structure Binary Search Tree.

Functions

BSTreebst_create_node (BSTree *left, BSTree *right, Type value)
 Creates a new BST node.
BSTreebst_create (void)
 Creates an empty BST.
int bst_empty (BSTree *t)
 Checks if a BST is empty.
int bst_exists (BSTree *t, Type c)
 Checks if a value exists in a BST.
BSTreebst_search (BSTree *t, Type c)
 Searches for a value in a BST.
void bst_print (BSTree *t)
 Prints the elements of a BST in in-order traversal.
int bst_height (BSTree *t)
 Returns the height of a BST.
BSTreebst_insert (BSTree *t, Type c)
 Inserts a value into a BST.
BSTreebst_remove (BSTree *t, Type c)
 Removes a value from a BST.
void bst_free (BSTree *t)
 Frees the memory allocated for a BST.
void bst_posfix (BSTree *t)
 Prints the elements of a BST in post-order traversal.
void bst_prefix (BSTree *t)
 Prints the elements of a BST in pre-order traversal.
void bst_infix (BSTree *t)
 Prints the elements of a BST in in-order traversal.
int bst_nodes (BSTree *t)
 Counts the number of nodes in a BST.
int bst_leafs_primes (BSTree *t)
 Counts the number of leaf nodes in a BST that are prime numbers.
int bst_two_children (BSTree *t)
 Counts the number of nodes in a BST that have two children.
int bst_nodes_equal_height (BSTree *t)
 Counts the number of nodes in a BST that have equal branch heights.
int bst_equals (BSTree *t1, BSTree *t2)
 Compares two BSTs for equality.

Macro Definition Documentation

◆ BST_EMPTY

#define BST_EMPTY   (BSTree*) 0

◆ Type

#define Type   BINARY_NODE_TYPE

Typedef Documentation

◆ BSTree

typedef struct BinaryNode BSTree

This module define a Abstract Data Type for the structure Binary Search Tree.


    Copyright 2017-2025 Manoel Vilela

    Author: Manoel Vilela
   Contact: manoel_vilela@engineer.com

Organization: UFC


A node in a Binary Search Tree (BST).

Each node contains a value and pointers to its left and right children.