mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-24 22:02:20 +08:00
Documentation for f7a5aecce5
This commit is contained in:
@@ -150,7 +150,7 @@ Functions</h2></td></tr>
|
||||
<div class="textblock"><p >Simple C++ implementation of the <a href="https://en.wikipedia.org/wiki/SHA-1" target="_blank">SHA-1 Hashing Algorithm</a> </p>
|
||||
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/tGautot" target="_blank">tGautot</a></dd></dl>
|
||||
<p><a href="https://en.wikipedia.org/wiki/SHA-1" target="_blank">SHA-1</a> is a cryptographic hash function that was developped by the <a href="https://en.wikipedia.org/wiki/National_Security_Agency" target="_blank">NSA</a> 1995. SHA-1 is not considered secure since around 2010.</p>
|
||||
<h3><a class="anchor" id="autotoc_md74"></a>
|
||||
<h3><a class="anchor" id="autotoc_md75"></a>
|
||||
Algorithm</h3>
|
||||
<p >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</p>
|
||||
<p >Once this is done, the algo breaks down this padded message into 64 bytes chunks. Each chunk is used for one <em>round</em>, a round breaks the chunk into 16 blocks of 4 bytes. These 16 blocks are then extended to 80 blocks using <a class="el" href="../../d7/d47/namespace_x_o_r.html" title="Functions for XOR cipher algorithm.">XOR</a> 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 <a href="https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode" target="_blank">wikipedia article</a> for more precision on these operations </p><dl class="section note"><dt>Note</dt><dd>This is a simple implementation for a byte string but some implmenetations can work on bytestream, messages of unknown length. </dd></dl>
|
||||
|
||||
@@ -157,13 +157,13 @@ Functions</h2></td></tr>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p >Iterative version of Preorder, Postorder, and preorder <a href="https://en.wikipedia.org/wiki/Tree_traversal" target="_blank">Traversal of the Tree</a> </p>
|
||||
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/motasimmakki" target="_blank">Motasim</a></dd></dl>
|
||||
<h3><a class="anchor" id="autotoc_md83"></a>
|
||||
<h3><a class="anchor" id="autotoc_md84"></a>
|
||||
Iterative Preorder Traversal of a tree</h3>
|
||||
<p >Create a Stack that will store the <a class="el" href="../../db/d8b/struct_node.html">Node</a> 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.</p>
|
||||
<h3><a class="anchor" id="autotoc_md84"></a>
|
||||
<h3><a class="anchor" id="autotoc_md85"></a>
|
||||
Iterative Postorder Traversal of a tree</h3>
|
||||
<p >Create a Stack that will store the <a class="el" href="../../db/d8b/struct_node.html">Node</a> 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.</p>
|
||||
<h3><a class="anchor" id="autotoc_md85"></a>
|
||||
<h3><a class="anchor" id="autotoc_md86"></a>
|
||||
Iterative Inorder Traversal of a tree</h3>
|
||||
<p >Create a Stack that will store the <a class="el" href="../../db/d8b/struct_node.html">Node</a> 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. </p>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
|
||||
@@ -155,7 +155,7 @@ uint32_t </td><td class="memItemRight" valign="bottom"><b>graph::disjoint_u
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p ><a href="https://en.wikipedia.org/wiki/Disjoint_union" target="_blank">Disjoint union</a> </p>
|
||||
<p >The Disjoint union is the technique to find connected component in graph efficiently.</p>
|
||||
<h3><a class="anchor" id="autotoc_md66"></a>
|
||||
<h3><a class="anchor" id="autotoc_md67"></a>
|
||||
Algorithm</h3>
|
||||
<p >In <a class="el" href="../../da/d9a/class_graph.html">Graph</a>, if you have to find out the number of connected components, there are 2 options</p><ol type="1">
|
||||
<li>Depth first search</li>
|
||||
|
||||
Reference in New Issue
Block a user