Skip to content

Commit 61c980d

Browse files
Merge branch 'master' into ctest
2 parents bb5b955 + 769b3c7 commit 61c980d

File tree

125 files changed

+6982
-36211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+6982
-36211
lines changed

.github/workflows/gh-pages.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Doxygen CI
22

3-
on:
3+
on:
44
push:
55
branches: [master]
66

@@ -15,7 +15,7 @@ jobs:
1515
run: |
1616
brew install graphviz ninja doxygen
1717
- name: configure
18-
run: cmake -G Ninja -B ./build -S .
18+
run: cmake -G Ninja -Duse_libclang=ON -DCMAKE_CXX_COMPILER=clang++ -B ./build -S .
1919
- name: build
2020
run: cmake --build build -t doc
2121
- name: gh-pages
@@ -28,7 +28,7 @@ jobs:
2828
git config --global user.name "$GITHUB_ACTOR"
2929
git config --global user.email "[email protected]"
3030
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
31-
rm -rf d* && rm *.html && rm *.svg && rm *.map && rm *.md5 && rm *.png && rm *.js && rm *.css
31+
rm -rf d* && rm *.html && rm *.svg && rm *.map && rm *.md5 && rm *.png && rm *.js
3232
git add .
3333
cp -rp ./build/html/* . && rm -rf ./build && ls -lah
3434
git add .

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ a.out
3434
*.out
3535
*.app
3636

37+
# Cache
38+
.cache/
39+
40+
# Build
3741
build/
3842
git_diff.txt

CMakeLists.txt

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
cmake_minimum_required(VERSION 3.22)
2-
project(Algorithms_in_C++
2+
project(TheAlgorithms/C++
33
LANGUAGES CXX
44
VERSION 1.0.0
55
DESCRIPTION "Set of algorithms implemented in C++."
66
)
77

8-
# set(CMAKE_CXX_CPPLINT "~/anaconda3/bin/cpplint --filter=-legal/copyright --std=c++11")
9-
# find_program(CLANG_FORMAT "clang-format")
10-
11-
set(CMAKE_CXX_STANDARD 11)
8+
# C++ standard
9+
set(CMAKE_CXX_STANDARD 17)
1210
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1311

12+
1413
include(CTest) # for testing algorithms
1514

15+
# Additional warnings and errors
1616
if(MSVC)
17-
# set(CMAKE_CXX_STANDARD 14)
1817
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
19-
endif(MSVC)
18+
add_compile_options(/W4 /permissive-)
19+
else()
20+
add_compile_options(-Wall -Wextra -Wno-register -Werror=vla)
21+
endif()
2022

2123
option(USE_OPENMP "flag to use OpenMP for multithreading" ON)
2224
if(USE_OPENMP)
@@ -40,6 +42,10 @@ add_subdirectory(graphics)
4042
add_subdirectory(probability)
4143
add_subdirectory(backtracking)
4244
add_subdirectory(bit_manipulation)
45+
add_subdirectory(dynamic_programming)
46+
add_subdirectory(greedy_algorithms)
47+
add_subdirectory(range_queries)
48+
add_subdirectory(operations_on_datastructures)
4349
add_subdirectory(data_structures)
4450
add_subdirectory(machine_learning)
4551
add_subdirectory(numerical_methods)
@@ -51,47 +57,30 @@ add_subdirectory(physics)
5157

5258
cmake_policy(SET CMP0054 NEW)
5359
cmake_policy(SET CMP0057 NEW)
60+
5461
find_package(Doxygen OPTIONAL_COMPONENTS dot dia)
55-
if(DOXYGEN_FOUND)
56-
set(DOXYGEN_GENERATE_MAN NO)
57-
set(DOXYGEN_USE_MATHJAX YES)
58-
set(DOXYGEN_GENERATE_HTML YES)
59-
# set(DOXYGEN_HTML_TIMESTAMP YES)
60-
set(DOXYGEN_EXTRACT_STATIC YES)
61-
set(DOXYGEN_INLINE_SOURCES YES)
62-
set(DOXYGEN_CREATE_SUBDIRS YES)
63-
set(DOXYGEN_EXTRACT_PRIVATE YES)
64-
set(DOXYGEN_GENERATE_TREEVIEW YES)
65-
set(DOXYGEN_STRIP_CODE_COMMENTS NO)
66-
set(DOXYGEN_EXT_LINKS_IN_WINDOW YES)
67-
set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
68-
set(DOXYGEN_EXCLUDE_PATTERNS */build/*)
69-
set(DOXYGEN_ENABLE_PREPROCESSING YES)
70-
set(DOXYGEN_CLANG_ASSISTED_PARSING YES)
71-
set(DOXYGEN_FILE_PATTERNS *.cpp *.h *.hpp *.md)
72-
set(DOXYGEN_MATHJAX_EXTENSIONS TeX/AMSmath TeX/AMSsymbols)
73-
set(DOXYGEN_TAGFILES "doc/cppreference-doxygen-web.tag.xml=http://en.cppreference.com/w/")
62+
if(DOXYGEN_FOUND)
7463
if(MSVC)
7564
set(DOXYGEN_CPP_CLI_SUPPORT YES)
7665
endif()
77-
set(DOXYGEN_MATHJAX_RELPATH "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML")
66+
7867
if(Doxygen_dot_FOUND)
7968
set(DOXYGEN_HAVE_DOT YES)
80-
set(DOXYGEN_CALL_GRAPH YES)
81-
set(DOXYGEN_INTERACTIVE_SVG YES)
82-
set(DOXYGEN_DOT_IMAGE_FORMAT "svg")
8369
endif()
70+
8471
if(OPENMP_FOUND)
8572
set(DOXYGEN_PREDEFINED "_OPENMP=1")
8673
endif()
74+
8775
if(GLUT_FOUND)
8876
set(DOXYGEN_PREDEFINED ${DOXYGEN_PREDEFINED} "GLUT_FOUND=1")
8977
endif()
9078

9179
doxygen_add_docs(
9280
doc
93-
${PROJECT_SOURCE_DIR}
81+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
9482
COMMENT "Generate documentation"
83+
CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile
9584
)
9685
endif()
9786

DIRECTORY.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
## Cpu Scheduling Algorithms
4343
* [Fcfs Scheduling](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/cpu_scheduling_algorithms/fcfs_scheduling.cpp)
44+
* [Non Preemptive Sjf Scheduling](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/cpu_scheduling_algorithms/non_preemptive_sjf_scheduling.cpp)
4445

4546
## Data Structures
4647
* [Avltree](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/data_structures/avltree.cpp)
@@ -94,7 +95,7 @@
9495
## Dynamic Programming
9596
* [0 1 Knapsack](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/0_1_knapsack.cpp)
9697
* [Abbreviation](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/abbreviation.cpp)
97-
* [Armstrong Number](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/armstrong_number.cpp)
98+
* [Armstrong Number Templated](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/armstrong_number_templated.cpp)
9899
* [Bellman Ford](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/bellman_ford.cpp)
99100
* [Catalan Numbers](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/catalan_numbers.cpp)
100101
* [Coin Change](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/coin_change.cpp)
@@ -106,11 +107,10 @@
106107
* [Floyd Warshall](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/floyd_warshall.cpp)
107108
* [House Robber](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/house_robber.cpp)
108109
* [Kadane](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/kadane.cpp)
109-
* [Kadane2](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/kadane2.cpp)
110110
* [Longest Common String](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/longest_common_string.cpp)
111111
* [Longest Common Subsequence](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/longest_common_subsequence.cpp)
112112
* [Longest Increasing Subsequence](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/longest_increasing_subsequence.cpp)
113-
* [Longest Increasing Subsequence (Nlogn)](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/longest_increasing_subsequence_(nlogn).cpp)
113+
* [Longest Increasing Subsequence Nlogn](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/longest_increasing_subsequence_nlogn.cpp)
114114
* [Longest Palindromic Subsequence](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/longest_palindromic_subsequence.cpp)
115115
* [Matrix Chain Multiplication](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/matrix_chain_multiplication.cpp)
116116
* [Maximum Circular Subarray](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/maximum_circular_subarray.cpp)
@@ -119,7 +119,7 @@
119119
* [Partition Problem](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/partition_problem.cpp)
120120
* [Searching Of Element In Dynamic Array](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/searching_of_element_in_dynamic_array.cpp)
121121
* [Shortest Common Supersequence](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/shortest_common_supersequence.cpp)
122-
* [Subset Sum](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/subset_sum.cpp)
122+
* [Subset Sum Dynamic](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/subset_sum_dynamic.cpp)
123123
* [Trapped Rainwater](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/trapped_rainwater.cpp)
124124
* [Tree Height](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/tree_height.cpp)
125125
* [Unbounded 0 1 Knapsack](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/dynamic_programming/unbounded_0_1_knapsack.cpp)
@@ -164,7 +164,7 @@
164164
* [Binary Addition](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/greedy_algorithms/binary_addition.cpp)
165165
* [Boruvkas Minimum Spanning Tree](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/greedy_algorithms/boruvkas_minimum_spanning_tree.cpp)
166166
* [Digit Separation](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/greedy_algorithms/digit_separation.cpp)
167-
* [Dijkstra](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/greedy_algorithms/dijkstra.cpp)
167+
* [Dijkstra Greedy](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/greedy_algorithms/dijkstra_greedy.cpp)
168168
* [Gale Shapley](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/greedy_algorithms/gale_shapley.cpp)
169169
* [Huffman](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/greedy_algorithms/huffman.cpp)
170170
* [Jump Game](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/greedy_algorithms/jump_game.cpp)
@@ -340,7 +340,7 @@
340340
* [Persistent Seg Tree Lazy Prop](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/range_queries/persistent_seg_tree_lazy_prop.cpp)
341341
* [Prefix Sum Array](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/range_queries/prefix_sum_array.cpp)
342342
* [Segtree](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/range_queries/segtree.cpp)
343-
* [Sparse Table](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/range_queries/sparse_table.cpp)
343+
* [Sparse Table Range Queries](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/range_queries/sparse_table_range_queries.cpp)
344344

345345
## Search
346346
* [Binary Search](https://github.com/TheAlgorithms/C-Plus-Plus/blob/HEAD/search/binary_search.cpp)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This repository is a collection of open-source implementation of a variety of al
2222
* Well documented source code with detailed explanations provide a valuable resource for educators and students alike.
2323
* Each source code is atomic using [STL classes](https://en.wikipedia.org/wiki/Standard_Template_Library) and _no external libraries_ are required for their compilation and execution. Thus, the fundamentals of the algorithms can be studied in much depth.
2424
* Source codes are [compiled and tested](https://github.com/TheAlgorithms/C-Plus-Plus/actions?query=workflow%3A%22Awesome+CI+Workflow%22) for every commit on the latest versions of three major operating systems viz., Windows, MacOS, and Ubuntu (Linux) using MSVC 19 2022, AppleClang 14.0.0, and GNU 11.3.0 respectively.
25-
* Strict adherence to [C++11](https://en.wikipedia.org/wiki/C%2B%2B11) standard ensures portability of code to embedded systems as well like ESP32, ARM Cortex, etc. with little to no changes.
25+
* Strict adherence to [C++17](https://en.wikipedia.org/wiki/C%2B%2B17) standard ensures portability of code to embedded systems as well like [ESP32](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/cplusplus.html#c-language-standard), [ARM Cortex](https://developer.arm.com/documentation/101458/2404/Standards-support/Supported-C-C---standards-in-Arm-C-C---Compiler), etc. with little to no changes.
2626
* Self-checks within programs ensure correct implementations with confidence.
2727
* Modular implementations and OpenSource licensing enable the functions to be utilized conveniently in other applications.
2828

backtracking/subarray_sum.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
#include <cassert> /// for assert
17+
#include <cstdint>
1718
#include <iostream> /// for IO operations
1819
#include <unordered_map> /// for unordered_map
1920
#include <vector> /// for std::vector

backtracking/subset_sum.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#include <cassert> /// for assert
13+
#include <cstdint>
1314
#include <iostream> /// for IO operations
1415
#include <vector> /// for std::vector
1516

backtracking/wildcard_matching.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313

1414
#include <cassert> /// for assert
15+
#include <cstdint>
1516
#include <iostream> /// for IO operations
1617
#include <vector> /// for std::vector
1718

bit_manipulation/count_bits_flip.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* @author [Yash Raj Singh](https://github.com/yashrajyash)
2121
*/
2222
#include <cassert> /// for assert
23+
#include <cstdint>
2324
#include <iostream> /// for IO operations
2425
/**
2526
* @namespace bit_manipulation

bit_manipulation/count_of_set_bits.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* @author [Prashant Thakur](https://github.com/prashant-th18)
1717
*/
1818
#include <cassert> /// for assert
19+
#include <cstdint>
1920
#include <iostream> /// for IO operations
2021
/**
2122
* @namespace bit_manipulation

0 commit comments

Comments
 (0)