A comprehensive collection of Data Structures and Algorithms implementations in C++ and other programming languages.
This repository contains implementations of various data structures and algorithms. The goal is to provide clear, well-documented code that can serve as a learning resource for students and developers.
- Binary Search
- Bubble Sort
- Insertion Sort
- Linear Search
- Merge Sort
- Selection Sort
-
Check Odd/Even (
check_odd_even.cpp
)- Determines if a number is odd or even using bitwise operations
-
Power of 2 (
Power_of_2.cpp
)- Contains two implementations to check if a number is a power of 2:
- Brute force approach using binary conversion
- Optimal solution using bitwise AND operation
- Contains two implementations to check if a number is a power of 2:
-
Bit Setting Operations
- Set ith bit (
set_ith_bit.cpp
) - Clear ith bit (
clear_ith_bit.cpp
) - Toggle ith bit (
toogle_ith_bit.cpp
) - Set rightmost unset bit (
set_rightMost_bit_unset.cpp
)
- Set ith bit (
-
Counting Operations
- Count set bits (
count_set_bit.cpp
) - Find numbers with odd occurrences (
odd_occurence_of_two_num.cpp
)
- Count set bits (
-
Binary Operations
- XOR operations from left to right (
XOR_left_to_right.cpp
) - Division operations using bits (
divided_divisor.cpp
,divisor_divided.cpp
)
- XOR operations from left to right (
-
Special Problems
- Find single occurrence in thrice occurring numbers (
imp_thrice_occur_find_once_occurence.cpp
) - Generate power set (
power_set.cpp
) - Flip bits (
flip_bits.cpp
)
- Find single occurrence in thrice occurring numbers (
- Binary Tree implementations
- Binary Search Tree (BST)
- Tree Properties (Height, Diameter, Balance, Symmetry)
- Lowest Common Ancestor problems
- Tree Views (Top, Bottom, Left, Right)
- Path Problems
- Tree Constructions
- AVL Tree
- Heap implementations
- C++ compiler (GCC recommended)
- Basic understanding of data structures and algorithms
To compile any program:
g++ filename.cpp -o output
Example:
g++ bubble_sort.cpp -o bubble_sort
./bubble_sort
We welcome contributions! Please see our CONTRIBUTING.md for detailed guidelines on how to contribute to this project.
- Fork the repository
- Create a new branch (
git checkout -b feature/algorithm-name
) - Add your algorithm with proper documentation
- Commit your changes (
git commit -m 'Add: Algorithm Name'
) - Push to the branch (
git push origin feature/algorithm-name
) - Open a Pull Request
Current issues that need to be addressed:
-
Code Structure
- Need to add proper header files
- Implement proper error handling
- Add input validation
-
Documentation
- Add detailed comments in each file
- Include time and space complexity analysis
- Add example usage for each algorithm
-
Testing
- Add unit tests
- Include edge cases
- Test with larger inputs
-
Build System
- Add CMake configuration
- Create proper build structure
- Add .gitignore for build artifacts
-
Code Quality
- Fix operator precedence issues
- Implement consistent coding style
- Add error handling for edge cases
This project is licensed under the MIT License - see the LICENSE file for details.
Thanks to all contributors who have helped build this repository!
Happy Coding! 💻