From 8808b968ea13f6d8703b36e2f00bad156ee0844f Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Fri, 24 Sep 2021 20:07:23 +0000 Subject: [PATCH] Documentation for 5245b3e4a930708a5631cf2ae316ee6d708d0114 --- d2/d26/count__inversions_8cpp.html | 2 +- d3/d4c/sha1_8cpp__incl.map | 10 + d3/d4c/sha1_8cpp__incl.md5 | 1 + d3/d4c/sha1_8cpp__incl.svg | 127 ++++ d3/db3/lru__cache_8cpp.html | 6 +- d3/df9/recursive__bubble__sort_8cpp.html | 2 +- d4/d32/inorder__successor__of__bst_8cpp.html | 8 +- d4/d38/power__of__two_8cpp.html | 2 +- d4/d9f/selection__sort__recursive_8cpp.html | 2 +- d5/d33/gram__schmidt_8cpp.html | 2 +- d5/d45/sublist__search_8cpp.html | 4 +- d5/d88/md__d_i_r_e_c_t_o_r_y.html | 1 + d5/ddb/bogo__sort_8cpp.html | 2 +- d6/d0c/namespacehashing.html | 3 +- d8/d7a/sha1_8cpp.html | 637 ++++++++++++++++++ d8/d7a/sha1_8cpp.js | 10 + ...397f2444a05e4d1487c67e215410d3c_cgraph.map | 4 + ...397f2444a05e4d1487c67e215410d3c_cgraph.md5 | 1 + ...397f2444a05e4d1487c67e215410d3c_cgraph.svg | 37 + ...be3471f7e489d7d0df42b97a48bf141_cgraph.map | 5 + ...be3471f7e489d7d0df42b97a48bf141_cgraph.md5 | 1 + ...be3471f7e489d7d0df42b97a48bf141_cgraph.svg | 52 ++ ...8dca7b867074164d5f45b0f3851269d_cgraph.map | 5 + ...8dca7b867074164d5f45b0f3851269d_cgraph.md5 | 1 + ...8dca7b867074164d5f45b0f3851269d_cgraph.svg | 52 ++ ...9e1a11f44135b890dd10a00e73b5661_cgraph.map | 6 + ...9e1a11f44135b890dd10a00e73b5661_cgraph.md5 | 1 + ...9e1a11f44135b890dd10a00e73b5661_cgraph.svg | 67 ++ ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map | 9 + ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 | 1 + ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg | 118 ++++ d8/d90/iterative__tree__traversals_8cpp.html | 6 +- dd/d47/namespacemath.html | 2 +- de/dd3/namespace_s_h_a.html | 112 +++ df/d66/vector__cross__product_8cpp.html | 2 +- dir_ece9b94c107bbaa1dd68197a8c9983b9.html | 3 + dir_ece9b94c107bbaa1dd68197a8c9983b9.js | 3 +- files.html | 1 + globals_func_i.html | 2 +- globals_func_m.html | 2 +- globals_func_t.html | 2 +- globals_i.html | 2 +- globals_m.html | 2 +- globals_t.html | 2 +- index.html | 8 +- namespaces.html | 71 +- namespaces_dup.js | 1 + navtreedata.js | 18 +- navtreeindex0.js | 496 +++++++------- navtreeindex1.js | 500 +++++++------- navtreeindex10.js | 40 +- navtreeindex11.js | 86 +-- navtreeindex12.js | 56 +- navtreeindex13.js | 49 +- navtreeindex2.js | 138 ++-- navtreeindex3.js | 60 +- navtreeindex4.js | 58 +- navtreeindex5.js | 58 +- navtreeindex6.js | 110 +-- navtreeindex7.js | 74 +- navtreeindex8.js | 86 +-- navtreeindex9.js | 66 +- search/all_14.js | 416 ++++++------ search/all_15.js | 8 +- search/all_9.js | 8 +- search/all_a.js | 405 ++++++----- search/all_d.js | 16 +- search/all_e.js | 6 +- search/files_13.js | 43 +- search/functions_13.js | 28 +- search/functions_14.js | 4 +- search/functions_8.js | 6 +- search/functions_9.js | 6 +- search/functions_c.js | 16 +- search/functions_d.js | 4 +- search/namespaces_11.js | 27 +- 76 files changed, 2783 insertions(+), 1505 deletions(-) create mode 100644 d3/d4c/sha1_8cpp__incl.map create mode 100644 d3/d4c/sha1_8cpp__incl.md5 create mode 100644 d3/d4c/sha1_8cpp__incl.svg create mode 100644 d8/d7a/sha1_8cpp.html create mode 100644 d8/d7a/sha1_8cpp.js create mode 100644 d8/d7a/sha1_8cpp_a2397f2444a05e4d1487c67e215410d3c_cgraph.map create mode 100644 d8/d7a/sha1_8cpp_a2397f2444a05e4d1487c67e215410d3c_cgraph.md5 create mode 100644 d8/d7a/sha1_8cpp_a2397f2444a05e4d1487c67e215410d3c_cgraph.svg create mode 100644 d8/d7a/sha1_8cpp_a7be3471f7e489d7d0df42b97a48bf141_cgraph.map create mode 100644 d8/d7a/sha1_8cpp_a7be3471f7e489d7d0df42b97a48bf141_cgraph.md5 create mode 100644 d8/d7a/sha1_8cpp_a7be3471f7e489d7d0df42b97a48bf141_cgraph.svg create mode 100644 d8/d7a/sha1_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map create mode 100644 d8/d7a/sha1_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 create mode 100644 d8/d7a/sha1_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg create mode 100644 d8/d7a/sha1_8cpp_ac9e1a11f44135b890dd10a00e73b5661_cgraph.map create mode 100644 d8/d7a/sha1_8cpp_ac9e1a11f44135b890dd10a00e73b5661_cgraph.md5 create mode 100644 d8/d7a/sha1_8cpp_ac9e1a11f44135b890dd10a00e73b5661_cgraph.svg create mode 100644 d8/d7a/sha1_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map create mode 100644 d8/d7a/sha1_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 create mode 100644 d8/d7a/sha1_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg create mode 100644 de/dd3/namespace_s_h_a.html diff --git a/d2/d26/count__inversions_8cpp.html b/d2/d26/count__inversions_8cpp.html index d5a0d6158..412a98020 100644 --- a/d2/d26/count__inversions_8cpp.html +++ b/d2/d26/count__inversions_8cpp.html @@ -151,7 +151,7 @@ Functions
two elements a[i] and a[j] form an inversion if a[i] > a[j] and i < j
Time Complexity --> O(n.log n)
Space Complexity --> O(n) ; additional array temp[1..n]
An implementation of LRU Cache. Lru is a part of cache algorithms (also frequently called cache replacement algorithms or cache replacement policies).
-For a cache of page frame x:
Every time a requested page is not found in cache, that is a miss or page fault, and if the page is present in cache, then its a hit.
-The working principle of the Bubble sort algorithm.
Bubble sort is a simple sorting algorithm used to rearrange a set of ascending or descending order elements. Bubble sort gets its name from the fact that data "bubbles" to the top of the dataset.
-What is Swap?
Swapping two numbers means that we interchange their values. Often, an additional variable is required for this operation. This is further illustrated in the following:
diff --git a/d4/d32/inorder__successor__of__bst_8cpp.html b/d4/d32/inorder__successor__of__bst_8cpp.html index e013eb776..272dc21ad 100644 --- a/d4/d32/inorder__successor__of__bst_8cpp.html +++ b/d4/d32/inorder__successor__of__bst_8cpp.html @@ -163,21 +163,21 @@ FunctionsAn implementation for finding the Inorder successor of a binary search tree Inorder successor of a node is the next node in Inorder traversal of the Binary Tree. Inorder Successor is NULL for the last node in Inorder traversal.
-* In this case, the left-most deepest node in the right subtree will
come just after the given node as we go to left deep in inorder.
Implementation to check whether a number is a power of 2 or not.
This algorithm uses bit manipulation to check if a number is a power of 2 or not.
-Let the input number be n, then the bitwise and between n and n-1 will let us know whether the number is power of 2 or not
For Example, If N= 32 then N-1 is 31, if we perform bitwise and of these two numbers then the result will be zero, which indicates that it is the power of 2 If N=23 then N-1 is 22, if we perform bitwise and of these two numbers then the result will not be zero , which indicates that it is not the power of 2
Implementation of the Selection sort implementation using recursion.
The selection sort algorithm divides the input list into two parts: a sorted sublist of items which is built up from left to right at the front (left) of the list, and a sublist of the remaining unsorted items that occupy the rest of the list. Initially, the sorted sublist is empty, and the unsorted sublist is the entire input list. The algorithm proceeds by finding the smallest (or largest, depending on the sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order), and moving the sublist boundaries one element to the right.
-FindMinIndex This function finds the minimum element of the array(list) recursively by simply comparing the minimum element of array reduced size by 1 and compares it to the last element of the array to find the minimum of the whole array.
SelectionSortRecursive Just like selection sort, it divides the list into two parts (i.e.: sorted and unsorted) and finds the minimum of the unsorted array. By calling the FindMinIndex function, it swaps the minimum element with the first element of the list, and then solves recursively for the remaining unsorted list.
Gram Schmidt Orthogonalisation Process
Takes the input of Linearly Independent Vectors, returns vectors orthogonal to each other.
-Take the first vector of given LI vectors as first vector of Orthogonal vectors. Take projection of second input vector on the first vector of Orthogonal vector and subtract it from the 2nd LI vector. Take projection of third vector on the second vector of Othogonal vectors and subtract it from the 3rd LI vector. Keep repeating the above process until all the vectors in the given input array are exhausted.
For Example: In R2, Input LI Vectors={(3,1),(2,2)} then Orthogonal Vectors= {(3, 1),(-0.4, 1.2)}
diff --git a/d5/d45/sublist__search_8cpp.html b/d5/d45/sublist__search_8cpp.html index 4e5a14e91..4479501ff 100644 --- a/d5/d45/sublist__search_8cpp.html +++ b/d5/d45/sublist__search_8cpp.html @@ -148,14 +148,14 @@ FunctionsImplementation of the Sublist Search Algorithm
-Implementation of Bogosort algorithm
In computer science, bogosort (also known as permutation sort, stupid sort, slowsort, shotgun sort, random sort, monkey sort, bobosort or shuffle sort) is a highly inefficient sorting algorithm based on the generate and test paradigm. Two versions of this algorithm exist: a deterministic version that enumerates all permutations until it hits a sorted one, and a randomized version that randomly permutes its input.Randomized version is implemented here.
-Shuffle the array untill array is sorted.
diff --git a/d6/d0c/namespacehashing.html b/d6/d0c/namespacehashing.html index 15bc289a9..676ec5947 100644 --- a/d6/d0c/namespacehashing.html +++ b/d6/d0c/namespacehashing.html @@ -98,7 +98,8 @@ $(document).ready(function(){initNavTree('d6/d0c/namespacehashing.html','../../' More...Hashing algorithms.
-Used for std::copy Used for std::array Used for assert Used for std::memcopy Used for IO operations Used for strings Used for std::vector
+Used for std::copy Used for std::array Used for assert Used for std::memcopy Used for IO operations Used for strings Used for std::vector
+For std::copy For std::array For assert For std::memcopy For IO operations For strings For std::vector
|
+ Algorithms_in_C++ 1.0.0
+
+ Set of algorithms implemented in C++.
+ |
+
Simple C++ implementation of the SHA-1 Hashing Algorithm +More...
+#include <algorithm>#include <array>#include <cassert>#include <cstring>#include <iostream>#include <string>#include <vector>+Namespaces | |
| namespace | hashing |
| Hashing algorithms. | |
| namespace | SHA |
| Functions for the SHA-1 algorithm implementation. | |
+Functions | |
| uint32_t | hashing::sha1::leftRotate32bits (uint32_t n, std::size_t rotate) |
| Rotates the bits of a 32-bit unsigned integer. More... | |
| std::string | hashing::sha1::sig2hex (void *sig) |
| Transforms the 160-bit SHA-1 signature into a 40 char hex string. More... | |
| void * | hashing::sha1::hash_bs (const void *input_bs, uint64_t input_size) |
| The SHA-1 algorithm itself, taking in a bytestring. More... | |
| void * | hashing::sha1::hash (const std::string &message) |
| Converts the string to bytestring and calls the main algorithm. More... | |
| static void | test () |
| Self-test implementations of well-known SHA-1 hashes. More... | |
| static void | interactive () |
| Puts user in a loop where inputs can be given and SHA-1 hash will be computed and printed. More... | |
| int | main () |
| Main function. More... | |
Simple C++ implementation of the SHA-1 Hashing Algorithm
+ +SHA-1 is a cryptographic hash function that was developped by the NSA 1995. SHA-1 is not considered secure since around 2010.
+The first step of the algorithm is to pad the message for its length to be a multiple of 64 (bytes). This is done by first adding 0x80 (10000000) and then only zeroes until the last 8 bytes must be filled, where then the 64 bit size of the input will be added
+Once this is done, the algo breaks down this padded message into 64 bytes chunks. Each chunk is used for one round, a round breaks the chunk into 16 blocks of 4 bytes. These 16 blocks are then extended to 80 blocks using XOR operations on existing blocks (see code for more details). The algorithm will then update its 160-bit state (here represented used 5 32-bits integer) using partial hashes computed using special functions on the blocks previously built. Please take a look at the wikipedia article for more precision on these operations
| void * hashing::sha1::hash | +( | +const std::string & | +message | ) | ++ |
Converts the string to bytestring and calls the main algorithm.
+| message | Plain character message to hash |
| void * hashing::sha1::hash_bs | +( | +const void * | +input_bs, | +
| + | + | uint64_t | +input_size | +
| + | ) | ++ |
The SHA-1 algorithm itself, taking in a bytestring.
+| input_bs | The bytestring to hash |
| input_size | The size (in BYTES) of the input |
+
|
+ +static | +
Puts user in a loop where inputs can be given and SHA-1 hash will be computed and printed.
+| uint32_t hashing::sha1::leftRotate32bits | +( | +uint32_t | +n, | +
| + | + | std::size_t | +rotate | +
| + | ) | ++ |
Rotates the bits of a 32-bit unsigned integer.
+| n | Integer to rotate |
| rotate | How many bits for the rotation |
| int main | +( | +void | +) | ++ |
Main function.
+| std::string hashing::sha1::sig2hex | +( | +void * | +sig | ) | ++ |
Transforms the 160-bit SHA-1 signature into a 40 char hex string.
+| sig | The SHA-1 signature (Expected 20 bytes) |
+
|
+ +static | +
Self-test implementations of well-known SHA-1 hashes.
+Iterative version of Preorder, Postorder, and preorder Traversal of the Tree
-Create a Stack that will store the Node of Tree. Push the root node into the stack. Save the root into the variabe named as current, and pop and elemnt from the stack. Store the data of current into the result array, and start traversing from it. Push both the child node of the current node into the stack, first right child then left child. Repeat the same set of steps untill the Stack becomes empty. And return the result array as the preorder traversal of a tree.
-Create a Stack that will store the Node of Tree. Push the root node into the stack. Save the root into the variabe named as current, and pop and elemnt from the stack. Store the data of current into the result array, and start traversing from it. Push both the child node of the current node into the stack, first left child then right child. Repeat the same set of steps untill the Stack becomes empty. Now reverse the result array and then return it to the calling function as a postorder traversal of a tree.
-Create a Stack that will store the Node of Tree. Push the root node into the stack. Save the root into the variabe named as current. Now iterate and take the current to the extreme left of the tree by traversing only to its left. Pop the elemnt from the stack and assign it to the current. Store the data of current into the result array. Repeat the same set of steps until the Stack becomes empty or the current becomes NULL. And return the result array as the inorder traversal of a tree.
Mathematical algorithms
Given a recurrence relation; evaluate the value of nth term. For e.g., For fibonacci series, recurrence series is f(n) = f(n-1) + f(n-2) where f(0) = 0 and f(1) = 1. Note that the method used only demonstrates recurrence relation with one variable (n), unlike nCr problem, since it has two (n, r)
This problem can be solved using matrix exponentiation method.
|
+ Algorithms_in_C++ 1.0.0
+
+ Set of algorithms implemented in C++.
+ |
+
The direction ratios (DR) are calculated as follows: 1st DR, J: (b * z) - (c * y) 2nd DR, A: -((a * z) - (c * x)) 3rd DR, N: (a * y) - (b * x)
Therefore, the direction ratios of the cross product are: J, A, N The following C++ Program calculates the direction ratios of the cross products of two vector. The program uses a function, cross() for doing so. The direction ratios for the first and the second vector has to be passed one by one seperated by a space character.
Magnitude of a vector is the square root of the sum of the squares of the direction ratios.
-An example of a running instance of the executable program:
Pass the first Vector: 1 2 3
Pass the second Vector: 4 5 6 The cross product is: -3 6 -3 Magnitude: 7.34847
diff --git a/dir_ece9b94c107bbaa1dd68197a8c9983b9.html b/dir_ece9b94c107bbaa1dd68197a8c9983b9.html index f9a98684d..11293f39e 100644 --- a/dir_ece9b94c107bbaa1dd68197a8c9983b9.html +++ b/dir_ece9b94c107bbaa1dd68197a8c9983b9.html @@ -111,6 +111,9 @@ FilesThis repository is a collection of open-source implementation of a variety of algorithms implemented in C++ and licensed under MIT License. These algorithms span a variety of topics from computer science, mathematics and statistics, data science, machine learning, engineering, etc.. The implementations and the associated documentation are meant to provide a learning resource for educators and students. Hence, one may find more than one implementation for the same objective but using a different algorithm strategies and optimizations.
-Online Documentation is generated from the repository source codes directly. The documentation contains all resources including source code snippets, details on execution of the programs, diagrammatic representation of program flow, and links to external resources where necessary. The documentation also introduces interactive source code with links to documentation for C++ STL library functions used. Click on Files menu to see the list of all the files documented with the code.
Documentation of Algorithms in C++ by The Algorithms Contributors is licensed under CC BY-SA 4.0
As a community developed and maintained repository, we welcome new un-plagiarized quality contributions. Please read our Contribution Guidelines.