mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-29 04:53:55 +08:00
Documentation for 2882b7bec2
This commit is contained in:
@@ -137,9 +137,6 @@ Functions</h2></td></tr>
|
||||
<tr class="memitem:ae97f4dd815654c4682f564afd718e824"><td class="memTemplItemLeft" align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d5/d91/namespacesorting.html#ae97f4dd815654c4682f564afd718e824">non_recursive_merge_sort</a> (const Iterator first, const Iterator last)</td></tr>
|
||||
<tr class="memdesc:ae97f4dd815654c4682f564afd718e824"><td class="mdescLeft"> </td><td class="mdescRight">bottom-up merge sort which sorts elements in a non-decreasing order <a href="../../d5/d91/namespacesorting.html#ae97f4dd815654c4682f564afd718e824">More...</a><br /></td></tr>
|
||||
<tr class="separator:ae97f4dd815654c4682f564afd718e824"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a2f6a7a66934f345f86038a280234e706"><td class="memTemplParams" colspan="2">template<std::size_t N> </td></tr>
|
||||
<tr class="memitem:a2f6a7a66934f345f86038a280234e706"><td class="memTemplItemLeft" align="right" valign="top"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>< int, N > </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d5/d91/namespacesorting.html#a2f6a7a66934f345f86038a280234e706">pigeonSort</a> (<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>< int, N > arr)</td></tr>
|
||||
<tr class="separator:a2f6a7a66934f345f86038a280234e706"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a7e7f25f31c50523990437abf2ac3907e"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d5/d91/namespacesorting.html#a7e7f25f31c50523990437abf2ac3907e">partition</a> (int arr[], int low, int high)</td></tr>
|
||||
<tr class="separator:a7e7f25f31c50523990437abf2ac3907e"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a50b66a1c652291b9a346ec7342967178"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d5/d91/namespacesorting.html#a50b66a1c652291b9a346ec7342967178">quickSort</a> (int arr[], int low, int high)</td></tr>
|
||||
@@ -668,66 +665,6 @@ Here is the call graph for this function:</div>
|
||||
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <span class="keywordflow">return</span> (i + 1);</div>
|
||||
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span> }</div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="a2f6a7a66934f345f86038a280234e706"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a2f6a7a66934f345f86038a280234e706">◆ </a></span>pigeonSort()</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
<div class="memtemplate">
|
||||
template<std::size_t N> </div>
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a><int, N> sorting::pigeonSort </td>
|
||||
<td>(</td>
|
||||
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a>< int, N > </td>
|
||||
<td class="paramname"><em>arr</em></td><td>)</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p>Pigeonhole sorting of array of size n The function will sort the array through Pigeonhole algorithm and print </p><dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">arr</td><td>unsorted array of elements </td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>sorted array of elements </dd></dl>
|
||||
<div class="fragment"><div class="line"><a name="l00034"></a><span class="lineno"> 34</span>  {</div>
|
||||
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>  <span class="comment">// Finding min and max*</span></div>
|
||||
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>  <span class="keyword">auto</span> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min.html">min</a> = <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min_element.html">std::min_element</a>(<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr), <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr));</div>
|
||||
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>  <span class="keyword">auto</span> <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">max</a> = <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max_element.html">std::max_element</a>(<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a>(arr), <a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a>(arr));</div>
|
||||
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>  </div>
|
||||
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  <span class="comment">// Range refers to the number of holes required</span></div>
|
||||
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  <span class="keywordtype">int</span> range = *<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max.html">max</a> - *<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min.html">min</a> + 1;</div>
|
||||
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  <span class="keywordtype">int</span> *hole = <span class="keyword">new</span> <span class="keywordtype">int</span>[range]();</div>
|
||||
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  </div>
|
||||
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  <span class="comment">// Copying all array values to pigeonhole</span></div>
|
||||
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < N; i++) {</div>
|
||||
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  hole[arr[i] - *<a class="codeRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min.html">min</a>] = arr[i];</div>
|
||||
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  }</div>
|
||||
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  </div>
|
||||
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  <span class="comment">// Deleting elements from list and storing to original array</span></div>
|
||||
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <span class="keywordtype">int</span> count = 0;</div>
|
||||
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < range; i++) {</div>
|
||||
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  <span class="keywordflow">while</span> (hole[i] != <span class="charliteral">'\0'</span>) {</div>
|
||||
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  arr[count] = hole[i];</div>
|
||||
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  hole[i] = {};</div>
|
||||
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  count++;</div>
|
||||
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  }</div>
|
||||
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  }</div>
|
||||
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  <span class="keyword">delete</span>[] hole;</div>
|
||||
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  </div>
|
||||
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  <span class="keywordflow">return</span> arr;</div>
|
||||
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span> }</div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d5/d91/namespacesorting_a2f6a7a66934f345f86038a280234e706_cgraph.svg" width="316" height="190"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a id="a50b66a1c652291b9a346ec7342967178"></a>
|
||||
@@ -1120,21 +1057,16 @@ Here is the call graph for this function:</div>
|
||||
</div>
|
||||
</div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<div class="ttc" id="amax_element_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/max_element.html">std::max_element</a></div><div class="ttdeci">T max_element(T... args)</div></div>
|
||||
<div class="ttc" id="anamespacesorting_html_a9d4eb6ea3c35540d804d451f1716622d"><div class="ttname"><a href="../../d5/d91/namespacesorting.html#a9d4eb6ea3c35540d804d451f1716622d">sorting::quicksort</a></div><div class="ttdeci">std::vector< T > quicksort(std::vector< T > arr, int32_t low, int32_t high)</div><div class="ttdef"><b>Definition:</b> quick_sort_3.cpp:119</div></div>
|
||||
<div class="ttc" id="amove_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/utility/move.html">std::move</a></div><div class="ttdeci">T move(T... args)</div></div>
|
||||
<div class="ttc" id="anamespacesorting_html_a7e7f25f31c50523990437abf2ac3907e"><div class="ttname"><a href="../../d5/d91/namespacesorting.html#a7e7f25f31c50523990437abf2ac3907e">sorting::partition</a></div><div class="ttdeci">int partition(int arr[], int low, int high)</div><div class="ttdef"><b>Definition:</b> quick_sort.cpp:37</div></div>
|
||||
<div class="ttc" id="ais_sorted_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a></div><div class="ttdeci">T is_sorted(T... args)</div></div>
|
||||
<div class="ttc" id="agroup__sorting_html_ga460c61cd948203b4816bef2accb3fc73"><div class="ttname"><a href="../../d5/d4c/group__sorting.html#ga460c61cd948203b4816bef2accb3fc73">merge</a></div><div class="ttdeci">void merge(int *arr, int l, int m, int r)</div><div class="ttdef"><b>Definition:</b> merge_sort.cpp:33</div></div>
|
||||
<div class="ttc" id="anamespacesorting_html_ae97f4dd815654c4682f564afd718e824"><div class="ttname"><a href="../../d5/d91/namespacesorting.html#ae97f4dd815654c4682f564afd718e824">sorting::non_recursive_merge_sort</a></div><div class="ttdeci">void non_recursive_merge_sort(const Iterator first, const Iterator last)</div><div class="ttdoc">bottom-up merge sort which sorts elements in a non-decreasing order</div><div class="ttdef"><b>Definition:</b> non_recursive_merge_sort.cpp:86</div></div>
|
||||
<div class="ttc" id="amin_element_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/min_element.html">std::min_element</a></div><div class="ttdeci">T min_element(T... args)</div></div>
|
||||
<div class="ttc" id="arand_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/random/rand.html">std::rand</a></div><div class="ttdeci">T rand(T... args)</div></div>
|
||||
<div class="ttc" id="aswap_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a></div><div class="ttdeci">T swap(T... args)</div></div>
|
||||
<div class="ttc" id="amin_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/min.html">std::min</a></div><div class="ttdeci">T min(T... args)</div></div>
|
||||
<div class="ttc" id="aleft_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/manip/left.html">std::left</a></div><div class="ttdeci">T left(T... args)</div></div>
|
||||
<div class="ttc" id="abegin_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/iterator/begin.html">std::begin</a></div><div class="ttdeci">T begin(T... args)</div></div>
|
||||
<div class="ttc" id="aend_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/iterator/end.html">std::end</a></div><div class="ttdeci">T end(T... args)</div></div>
|
||||
<div class="ttc" id="amax_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/max.html">std::max</a></div><div class="ttdeci">T max(T... args)</div></div>
|
||||
<div class="ttc" id="arandom_shuffle_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/random_shuffle.html">std::random_shuffle</a></div><div class="ttdeci">T random_shuffle(T... args)</div></div>
|
||||
<div class="ttc" id="anamespacesorting_html_a50b66a1c652291b9a346ec7342967178"><div class="ttname"><a href="../../d5/d91/namespacesorting.html#a50b66a1c652291b9a346ec7342967178">sorting::quickSort</a></div><div class="ttdeci">void quickSort(int arr[], int low, int high)</div><div class="ttdef"><b>Definition:</b> quick_sort.cpp:63</div></div>
|
||||
<div class="ttc" id="anamespacesorting_html_af2c5b92cbfe73f63f6074c61b0a45331"><div class="ttname"><a href="../../d5/d91/namespacesorting.html#af2c5b92cbfe73f63f6074c61b0a45331">sorting::shell_sort</a></div><div class="ttdeci">void shell_sort(std::vector< T > *arr)</div><div class="ttdef"><b>Definition:</b> shell_sort2.cpp:75</div></div>
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<map id="sorting::pigeonSort" name="sorting::pigeonSort">
|
||||
<area shape="rect" id="node1" title=" " alt="" coords="5,81,136,108"/>
|
||||
<area shape="rect" id="node2" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/iterator/begin.html#" title=" " alt="" coords="208,5,287,32"/>
|
||||
<area shape="rect" id="node3" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/iterator/end.html#" title=" " alt="" coords="213,56,282,83"/>
|
||||
<area shape="rect" id="node4" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/max_element.html#" title=" " alt="" coords="184,107,311,133"/>
|
||||
<area shape="rect" id="node5" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/algorithm/min_element.html#" title=" " alt="" coords="186,157,309,184"/>
|
||||
</map>
|
||||
@@ -1 +0,0 @@
|
||||
ae87d545c12dd7f91d2543b27aed7fb9
|
||||
@@ -1,82 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 2.44.1 (20200629.0846)
|
||||
-->
|
||||
<!-- Title: sorting::pigeonSort Pages: 1 -->
|
||||
<svg width="237pt" height="142pt"
|
||||
viewBox="0.00 0.00 237.00 142.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 138)">
|
||||
<title>sorting::pigeonSort</title>
|
||||
<polygon fill="white" stroke="transparent" points="-4,4 -4,-138 233,-138 233,4 -4,4"/>
|
||||
<!-- Node1 -->
|
||||
<g id="node1" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_node1"><a xlink:title=" ">
|
||||
<polygon fill="#bfbfbf" stroke="black" points="0,-57.5 0,-76.5 98,-76.5 98,-57.5 0,-57.5"/>
|
||||
<text text-anchor="middle" x="49" y="-64.5" font-family="Helvetica,sans-Serif" font-size="10.00">sorting::pigeonSort</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="node2" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_node2"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/iterator/begin.html#" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="black" points="152,-114.5 152,-133.5 211,-133.5 211,-114.5 152,-114.5"/>
|
||||
<text text-anchor="middle" x="181.5" y="-121.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::begin</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<path fill="none" stroke="midnightblue" d="M70.62,-76.58C87.56,-84.4 112.24,-95.64 134,-105 138.17,-106.79 142.56,-108.64 146.92,-110.45"/>
|
||||
<polygon fill="midnightblue" stroke="midnightblue" points="145.72,-113.74 156.29,-114.31 148.38,-107.27 145.72,-113.74"/>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="node3" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_node3"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/iterator/end.html#" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="black" points="155.5,-76.5 155.5,-95.5 207.5,-95.5 207.5,-76.5 155.5,-76.5"/>
|
||||
<text text-anchor="middle" x="181.5" y="-83.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::end</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node3 -->
|
||||
<g id="edge2" class="edge">
|
||||
<title>Node1->Node3</title>
|
||||
<path fill="none" stroke="midnightblue" d="M98.22,-74.02C113.76,-76.28 130.69,-78.75 145.13,-80.85"/>
|
||||
<polygon fill="midnightblue" stroke="midnightblue" points="144.75,-84.33 155.15,-82.31 145.75,-77.4 144.75,-84.33"/>
|
||||
</g>
|
||||
<!-- Node4 -->
|
||||
<g id="node4" class="node">
|
||||
<title>Node4</title>
|
||||
<g id="a_node4"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/max_element.html#" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="black" points="134,-38.5 134,-57.5 229,-57.5 229,-38.5 134,-38.5"/>
|
||||
<text text-anchor="middle" x="181.5" y="-45.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::max_element</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node4 -->
|
||||
<g id="edge3" class="edge">
|
||||
<title>Node1->Node4</title>
|
||||
<path fill="none" stroke="midnightblue" d="M98.22,-59.98C106.57,-58.76 115.32,-57.49 123.87,-56.24"/>
|
||||
<polygon fill="midnightblue" stroke="midnightblue" points="124.39,-59.71 133.78,-54.8 123.38,-52.78 124.39,-59.71"/>
|
||||
</g>
|
||||
<!-- Node5 -->
|
||||
<g id="node5" class="node">
|
||||
<title>Node5</title>
|
||||
<g id="a_node5"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/algorithm/min_element.html#" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="black" points="135.5,-0.5 135.5,-19.5 227.5,-19.5 227.5,-0.5 135.5,-0.5"/>
|
||||
<text text-anchor="middle" x="181.5" y="-7.5" font-family="Helvetica,sans-Serif" font-size="10.00">std::min_element</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node5 -->
|
||||
<g id="edge4" class="edge">
|
||||
<title>Node1->Node5</title>
|
||||
<path fill="none" stroke="midnightblue" d="M70.62,-57.42C87.56,-49.6 112.24,-38.36 134,-29 138.17,-27.21 142.56,-25.36 146.92,-23.55"/>
|
||||
<polygon fill="midnightblue" stroke="midnightblue" points="148.38,-26.73 156.29,-19.69 145.72,-20.26 148.38,-26.73"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 4.0 KiB |
Reference in New Issue
Block a user