Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,30 @@ if(USE_OPENMP)
endif()
endif()

add_subdirectory(math)
add_subdirectory(others)
add_subdirectory(search)
add_subdirectory(ciphers)
add_subdirectory(hashing)
add_subdirectory(strings)
add_subdirectory(sorting)
add_subdirectory(geometry)
add_subdirectory(graphics)
add_subdirectory(probability)
add_subdirectory(backtracking)
add_subdirectory(bit_manipulation)
add_subdirectory(ciphers)
add_subdirectory(cpu_scheduling_algorithms)
add_subdirectory(data_structures)
add_subdirectory(divide_and_conquer)
add_subdirectory(dynamic_programming)
add_subdirectory(games)
add_subdirectory(geometry)
add_subdirectory(graph)
add_subdirectory(graphics)
add_subdirectory(greedy_algorithms)
add_subdirectory(range_queries)
add_subdirectory(operations_on_datastructures)
add_subdirectory(data_structures)
add_subdirectory(hashing)
add_subdirectory(machine_learning)
add_subdirectory(math)
add_subdirectory(numerical_methods)
add_subdirectory(graph)
add_subdirectory(divide_and_conquer)
add_subdirectory(games)
add_subdirectory(cpu_scheduling_algorithms)
add_subdirectory(operations_on_datastructures)
add_subdirectory(others)
add_subdirectory(physics)
add_subdirectory(probability)
add_subdirectory(range_queries)
add_subdirectory(search)
add_subdirectory(sorting)
add_subdirectory(strings)

cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0057 NEW)
Expand Down
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,9 @@ static void test() {

/**
* @brief Main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* @returns 0 on exit
*/
int main(int argc, char *argv[]) {
int main() {
test(); // run self-test implementations
// code here
return 0;
Expand Down
2 changes: 1 addition & 1 deletion ciphers/uint256_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class uint256_t {
*/
template <typename T, typename = typename std::enable_if<
std::is_integral<T>::value, T>::type>
explicit uint256_t(T low) : s(low), f(0) {}
explicit uint256_t(T low) : f(0), s(low) {}

/**
* @brief Parameterized constructor
Expand Down
23 changes: 11 additions & 12 deletions data_structures/queue_using_array2.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
#include <iostream>
using namespace std;

int queue[10];
int front = 0;
int rear = 0;

void Enque(int x) {
if (rear == 10) {
cout << "\nOverflow";
std::cout << "\nOverflow";
} else {
queue[rear++] = x;
}
}

void Deque() {
if (front == rear) {
cout << "\nUnderflow";
std::cout << "\nUnderflow";
}

else {
cout << "\n" << queue[front++] << " deleted";
std::cout << "\n" << queue[front++] << " deleted";
for (int i = front; i < rear; i++) {
queue[i - front] = queue[i];
}
Expand All @@ -30,21 +29,21 @@ void Deque() {

void show() {
for (int i = front; i < rear; i++) {
cout << queue[i] << "\t";
std::cout << queue[i] << "\t";
}
}

int main() {
int ch, x;
do {
cout << "\n1. Enque";
cout << "\n2. Deque";
cout << "\n3. Print";
cout << "\nEnter Your Choice : ";
cin >> ch;
std::cout << "\n1. Enque";
std::cout << "\n2. Deque";
std::cout << "\n3. Print";
std::cout << "\nEnter Your Choice : ";
std::cin >> ch;
if (ch == 1) {
cout << "\nInsert : ";
cin >> x;
std::cout << "\nInsert : ";
std::cin >> x;
Enque(x);
} else if (ch == 2) {
Deque();
Expand Down
4 changes: 1 addition & 3 deletions data_structures/sparse_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,9 @@ static void test() {

/**
* @brief Main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* @returns 0 on exit
*/
int main(int argc, char *argv[]) {
int main() {
test(); // run self-test implementations
return 0;
}
2 changes: 1 addition & 1 deletion data_structures/stack_using_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Stack {
*
* @param size Maximum size of the stack
*/
Stack(int size) : stackSize(size), stackIndex(-1), stack(new T[size]) {}
Stack(int size) : stack(new T[size]), stackSize(size), stackIndex(-1) {}

/**
* @brief Checks if the stack is full
Expand Down
10 changes: 5 additions & 5 deletions data_structures/tree_234.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class Node {
* @param item the first value we insert to the node
*/
explicit Node(int64_t item)
: count(1),
items({{item, 0, 0}}),
children({{nullptr, nullptr, nullptr, nullptr}}) {}
: items({{item, 0, 0}}),
children({{nullptr, nullptr, nullptr, nullptr}}),
count(1) {}

/**
* @brief Get the item count that current saved in the node
Expand Down Expand Up @@ -1291,8 +1291,8 @@ static void test2(int64_t n) {

/**
* @brief Main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* @param argc commandline argument count
* @param argv commandline array of arguments
* @returns 0 on exit
*/
int main(int argc, char *argv[]) {
Expand Down
1 change: 1 addition & 0 deletions data_structures/trie_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
#include <array>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <memory>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion dynamic_programming/fibonacci_bottom_up.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int fib(int n) {
}
return res[1];
}
int main(int argc, char const *argv[]) {
int main() {
int n;
cout << "Enter n: ";
cin >> n;
Expand Down
4 changes: 1 addition & 3 deletions dynamic_programming/longest_increasing_subsequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,9 @@ static void test() {

/**
* @brief Main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* @returns 0 on exit
*/
int main(int argc, char const *argv[]) {
int main() {
uint32_t n = 0;

std::cout << "Enter size of array: ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int LIS(const std::vector<int>& arr, int n) {
}
return active.size(); // size of the LIS.
}
int main(int argc, char const* argv[]) {
int main() {
int n;
cout << "Enter size of array: ";
cin >> n;
Expand Down
4 changes: 1 addition & 3 deletions dynamic_programming/maximum_circular_subarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ static void test() {

/**
* @brief Main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* @returns 0 on exit
*/
int main(int argc, char *argv[]) {
int main() {
test(); // run self-test implementations
return 0;
}
4 changes: 1 addition & 3 deletions dynamic_programming/minimum_edit_distance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,9 @@ static void test() {

/**
* @brief main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* @returns 0 on exit
*/
int main(int argc, char *argv[]) {
int main() {
test(); // run self-test implementations
return 0;
}
4 changes: 1 addition & 3 deletions graph/hamiltons_cycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ static void test3() {
/**
* Main function
*
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
*/
int main(int argc, char **argv) {
int main() {
test1();
test2();
test3();
Expand Down
2 changes: 2 additions & 0 deletions machine_learning/a_star_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
#include <algorithm> /// for `std::reverse` function
#include <array> /// for `std::array`, representing `EightPuzzle` board
#include <cassert> /// for `assert`
#include <cstdint> /// for `std::uint32_t`
#include <functional> /// for `std::function` STL
#include <iostream> /// for IO operations
#include <map> /// for `std::map` STL
#include <memory> /// for `std::shared_ptr`
#include <set> /// for `std::set` STL
#include <vector> /// for `std::vector` STL

/**
* @namespace machine_learning
* @brief Machine learning algorithms
Expand Down
4 changes: 1 addition & 3 deletions machine_learning/k_nearest_neighbors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,9 @@ static void test() {

/**
* @brief Main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* @return int 0 on exit
*/
int main(int argc, char* argv[]) {
int main() {
test(); // run self-test implementations
return 0;
}
2 changes: 1 addition & 1 deletion machine_learning/kohonen_som_topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ double get_clock_diff(clock_t start_t, clock_t end_t) {
}

/** Main function */
int main(int argc, char **argv) {
int main() {
#ifdef _OPENMP
std::cout << "Using OpenMP based parallelization\n";
#else
Expand Down
2 changes: 1 addition & 1 deletion machine_learning/kohonen_som_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ double get_clock_diff(clock_t start_t, clock_t end_t) {
}

/** Main function */
int main(int argc, char **argv) {
int main() {
#ifdef _OPENMP
std::cout << "Using OpenMP based parallelization\n";
#else
Expand Down
4 changes: 1 addition & 3 deletions math/eulers_totient_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@ static void test() {

/**
* @brief Main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* @returns 0 on exit
*/
int main(int argc, char *argv[]) {
int main() {
test();
return 0;
}
4 changes: 1 addition & 3 deletions math/modular_division.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ static void test() {

/**
* @brief Main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* @returns 0 on exit
*/
int main(int argc, char *argv[]) {
int main() {
test(); // execute the tests
return 0;
}
4 changes: 1 addition & 3 deletions math/n_choose_r.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ static void test() {

/**
* @brief Main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* @returns 0 on exit
*/
int main(int argc, char *argv[]) {
int main() {
test(); // executing tests
return 0;
}
2 changes: 1 addition & 1 deletion math/realtime_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void test_function(const float *test_data, const int number_of_samples) {
}

/** Main function */
int main(int argc, char **argv) {
int main() {
const float test_data1[] = {3, 4, 5, -1.4, -3.6, 1.9, 1.};
test_function(test_data1, sizeof(test_data1) / sizeof(test_data1[0]));

Expand Down
4 changes: 1 addition & 3 deletions numerical_methods/babylonian_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ static void test() {

/**
* @brief Main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* calls automated test function to test the working of fast fourier transform.
* @returns 0 on exit
*/

int main(int argc, char const *argv[]) {
int main() {
test(); // run self-test implementations
// with 2 defined test cases
return 0;
Expand Down
4 changes: 2 additions & 2 deletions numerical_methods/composite_simpson_rule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ static void test(std::int32_t N, double h, double a, double b,

/**
* @brief Main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* @param argc commandline argument count
* @param argv commandline array of arguments
* @returns 0 on exit
*/
int main(int argc, char** argv) {
Expand Down
4 changes: 1 addition & 3 deletions numerical_methods/fast_fourier_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,11 @@ static void test() {

/**
* @brief Main function
* @param argc commandline argument count (ignored)
* @param argv commandline array of arguments (ignored)
* calls automated test function to test the working of fast fourier transform.
* @returns 0 on exit
*/

int main(int argc, char const *argv[]) {
int main() {
test(); // run self-test implementations
// with 2 defined test cases
return 0;
Expand Down
Loading
Loading