All Code Snippets
This C++ code implements a graph using an adjacency list representation. The graph can be either directed or undirected, and supports operations like adding edges, performing depth-first search (DFS), and breadth-first search (BFS). The adjacency list is efficient in terms of space, storing only the neighbors of each vertex, making it well-suited for sparse graphs. This implementation is widely used in various algorithms, including those for pathfinding, connectivity, and traversal.
This C++ code provides a simple implementation of a Binary Search Tree (BST), supporting core operations like insertion, searching, and in-order traversal. The tree maintains an ordered structure, where the left child of a node contains values smaller than the node, and the right child contains values greater or equal. BSTs offer efficient data management, making them essential for various algorithms and applications.
This C++ code implements an AVL Tree, a self-balancing binary search tree where the height difference (balance factor) of the left and right subtrees is maintained to be at most one. The tree supports operations like insertion, deletion, and searching while automatically performing rotations to maintain balance. By keeping the tree balanced, AVL Trees ensure efficient operations with guaranteed O(log n) time complexity for search, insert, and delete operations, making them ideal for applications where balanced data access is critical.
This C++ code implements a Splay Tree, a self-adjusting binary search tree where recently accessed elements are moved closer to the root. The tree supports operations like insertion, searching, and deletion, with each operation triggering a "splay" to reorganize the tree for improved access to frequently used nodes. Splay trees provide an efficient balance between dynamic data access and simplicity, making them suitable for scenarios with non-uniform access patterns.
This C++ code demonstrates a simple implementation of a singly linked list. The list consists of nodes where each node stores a data value and a pointer to the next node in the sequence. The implementation includes common operations such as insertion (at the beginning, end, or middle), deletion, traversal, and searching. Linked lists provide dynamic memory allocation and are useful for scenarios where frequent insertions and deletions are required without shifting elements.
This project is a simple C++ program that formats code files written in C, C++, or Java. It processes the given files by adding appropriate indentation, removing extra spaces, and ensuring that the code is easy to read and maintain.
This project demonstrates the implementation of the Heap Sort algorithm in C++. The code is designed to sort an array of integers using the heap data structure. Heap Sort is a comparison-based sorting technique that utilizes a binary heap. It first converts the array into a max heap, then repeatedly extracts the maximum element to produce the sorted array.