Skip to content

About

“C++ implementation of inserting a node in Binary Search Tree.”

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Insert Node in Binary Search Tree (BST)

C++ implementation of inserting a node into a Binary Search Tree (BST) with inorder traversal for verification.


📘 Overview

This project demonstrates how to insert a value into a Binary Search Tree using C++.
It includes a simple BST node structure, insertion logic, and traversal to verify correctness.


🧠 Concepts Covered

  • Binary Search Tree (BST)
  • Recursion
  • Tree traversal (Inorder)
  • Struct usage in C++

📂 Project Structure

INSERT_NODE_IN_BST ├── main.cpp └── README.md


⚙️ Implementation Details

The program includes:

  • A Node structure representing BST nodes
  • A recursive function to insert a node
  • Inorder traversal to display sorted values

▶️ How to Compile and Run

Compile

g++ main.cpp -o bst

Run:

./bst

⏱ Complexity

Insertion in BST:

Average Time Complexity: O(log n)

Worst Case: O(n)

🛠 Language Used C++


Example Output

Before insertion: 20 30 40 50 60 70 80

After inserting 65: 20 30 40 50 60 65 70 80


Problem explanation

A Binary Search Tree maintains elements in sorted order. Insertion places the new value in the correct position based on BST properties.

About

“C++ implementation of inserting a node in Binary Search Tree.”

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages