mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-11-06 07:38:47 +08:00
Documentation for c6af943508
This commit is contained in:
@@ -193,10 +193,12 @@ Functions</h2></td></tr>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p>for working with vectors </p>
|
||||
<p>for io operations</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a></p>
|
||||
<p>for returning multiple values form a function at once</p>
|
||||
<p>header files</p>
|
||||
<p>Sorting Algorithms.</p>
|
||||
<p>for std::assert</p>
|
||||
<p>for using <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></p>
|
||||
<p>for assert</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></p>
|
||||
<p>Sorting algorithms.</p>
|
||||
<p>for algorithm functions for assert for IO operations</p>
|
||||
@@ -204,23 +206,23 @@ Functions</h2></td></tr>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a> for assert for IO implementations for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/pair.html">std::pair</a>, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a> for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a>, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/push_back.html">std::vector::push_back</a>, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/size.html">std::vector::size</a></p>
|
||||
<p>for assert for typedef datatype uint64_t for IO operations</p>
|
||||
<p>Sorting algorithms</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a>, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a> for assert for io operations</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a>, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a> for io operations for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></p>
|
||||
<p>Sorting algorithms</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a> for assert for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a> and io operations</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a> for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a> and io operations for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></p>
|
||||
<p>@breif Sorting algorithms</p>
|
||||
<p>Sorting algorithms</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a> for assert function in testing for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> and <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a></p>
|
||||
<p>Contains sorting algorithms</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a> for std::assert for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/chrono/c/time.html">std::time</a> for IO operations</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a> for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/chrono/c/time.html">std::time</a> for IO operations for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></p>
|
||||
<p>Sorting algorithms</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a> for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/stack.html">std::stack</a> for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a> for assert</p>
|
||||
<p>header files for collection of functions for a macro called assert which can be used to verify assumptions for io operations</p>
|
||||
<p>for collection of functions for a macro called assert which can be used to verify assumptions for io operations for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></p>
|
||||
<p>Sorting algorithms</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted()</a>, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap()</a> for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a> for assert for initializing random number generator for IO operations</p>
|
||||
<p>Sorting algorithms</p>
|
||||
<p>for assert for IO operations for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a> for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a></p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a> for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/array.html">std::array</a> for IO operations for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></p>
|
||||
<p>Sorting algorithms</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a> for std::assert for IO operations</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a> for IO operations for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a> for assert for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a> and io operations</p>
|
||||
<p>Sorting algorithms</p>
|
||||
<p>for <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/is_sorted.html">std::is_sorted</a>, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a> for assert for IO operations</p>
|
||||
@@ -1193,22 +1195,22 @@ template<typename T > </div>
|
||||
<p>< base case; when size of the array is 1</p>
|
||||
<p>< iterating over the entire array</p>
|
||||
<p>< if a larger number appears before the smaller one, swap them.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 74</span> {</div>
|
||||
<div class="line"><span class="lineno"> 75</span> <span class="keywordflow">if</span> (n == 1) { <span class="comment">//!< base case; when size of the array is 1</span></div>
|
||||
<div class="line"><span class="lineno"> 76</span> <span class="keywordflow">return</span>;</div>
|
||||
<div class="line"><span class="lineno"> 77</span> }</div>
|
||||
<div class="line"><span class="lineno"> 78</span> </div>
|
||||
<div class="line"><span class="lineno"> 79</span> <span class="keywordflow">for</span> (uint64_t i = 0; i < n - 1; i++) { <span class="comment">//!< iterating over the entire array</span><span class="comment"></span></div>
|
||||
<div class="line"><span class="lineno"> 80</span><span class="comment"> //!< if a larger number appears before the smaller one, swap them.</span></div>
|
||||
<div class="line"><span class="lineno"> 81</span><span class="comment"></span> <span class="keywordflow">if</span> ((*nums)[i] > (*nums)[i + 1]) {</div>
|
||||
<div class="line"><span class="lineno"> 82</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a>((*nums)[i], (*nums)[i + 1]);</div>
|
||||
<div class="line"><span class="lineno"> 83</span> }</div>
|
||||
<div class="line"><span class="lineno"> 84</span> }</div>
|
||||
<div class="line"><span class="lineno"> 85</span><span class="comment"></span> </div>
|
||||
<div class="line"><span class="lineno"> 86</span><span class="comment"> //!< calling the function after we have fixed the last element</span></div>
|
||||
<div class="line"><span class="lineno"> 87</span><span class="comment"></span> <a class="code hl_function" href="#ae3a775d99dbbb94c130a973df0cfddcf">recursive_bubble_sort</a>(nums, n - 1);</div>
|
||||
<div class="line"><span class="lineno"> 88</span>}</div>
|
||||
<div class="ttc" id="anamespacesorting_html_ae3a775d99dbbb94c130a973df0cfddcf"><div class="ttname"><a href="#ae3a775d99dbbb94c130a973df0cfddcf">sorting::recursive_bubble_sort</a></div><div class="ttdeci">void recursive_bubble_sort(std::vector< T > *nums, uint64_t n)</div><div class="ttdoc">This is an implementation of the recursive_bubble_sort. A vector is passed to the function which is t...</div><div class="ttdef"><b>Definition</b> recursive_bubble_sort.cpp:74</div></div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 84</span> {</div>
|
||||
<div class="line"><span class="lineno"> 85</span> <span class="keywordflow">if</span> (n == 1) { <span class="comment">//!< base case; when size of the array is 1</span></div>
|
||||
<div class="line"><span class="lineno"> 86</span> <span class="keywordflow">return</span>;</div>
|
||||
<div class="line"><span class="lineno"> 87</span> }</div>
|
||||
<div class="line"><span class="lineno"> 88</span> </div>
|
||||
<div class="line"><span class="lineno"> 89</span> <span class="keywordflow">for</span> (uint64_t i = 0; i < n - 1; i++) { <span class="comment">//!< iterating over the entire array</span><span class="comment"></span></div>
|
||||
<div class="line"><span class="lineno"> 90</span><span class="comment"> //!< if a larger number appears before the smaller one, swap them.</span></div>
|
||||
<div class="line"><span class="lineno"> 91</span><span class="comment"></span> <span class="keywordflow">if</span> ((*nums)[i] > (*nums)[i + 1]) {</div>
|
||||
<div class="line"><span class="lineno"> 92</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a>((*nums)[i], (*nums)[i + 1]);</div>
|
||||
<div class="line"><span class="lineno"> 93</span> }</div>
|
||||
<div class="line"><span class="lineno"> 94</span> }</div>
|
||||
<div class="line"><span class="lineno"> 95</span><span class="comment"></span> </div>
|
||||
<div class="line"><span class="lineno"> 96</span><span class="comment"> //!< calling the function after we have fixed the last element</span></div>
|
||||
<div class="line"><span class="lineno"> 97</span><span class="comment"></span> <a class="code hl_function" href="#ae3a775d99dbbb94c130a973df0cfddcf">recursive_bubble_sort</a>(nums, n - 1);</div>
|
||||
<div class="line"><span class="lineno"> 98</span>}</div>
|
||||
<div class="ttc" id="anamespacesorting_html_ae3a775d99dbbb94c130a973df0cfddcf"><div class="ttname"><a href="#ae3a775d99dbbb94c130a973df0cfddcf">sorting::recursive_bubble_sort</a></div><div class="ttdeci">void recursive_bubble_sort(std::vector< T > *nums, uint64_t n)</div><div class="ttdoc">This is an implementation of the recursive_bubble_sort. A vector is passed to the function which is t...</div><div class="ttdef"><b>Definition</b> recursive_bubble_sort.cpp:84</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
@@ -1235,27 +1237,27 @@ Here is the call graph for this function:</div>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 48</span> {</div>
|
||||
<div class="line"><span class="lineno"> 49</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<uint64_t></a> array(</div>
|
||||
<div class="line"><span class="lineno"> 50</span> arr.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/begin.html">begin</a>(),</div>
|
||||
<div class="line"><span class="lineno"> 51</span> arr.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/end.html">end</a>()); <span class="comment">// declare a vector in which result will be stored</span></div>
|
||||
<div class="line"><span class="lineno"> 52</span> <span class="keywordflow">for</span> (uint64_t it = 0; it < len; ++it) {</div>
|
||||
<div class="line"><span class="lineno"> 53</span> uint64_t min = it; <span class="comment">// set min value</span></div>
|
||||
<div class="line"><span class="lineno"> 54</span> <span class="keywordflow">for</span> (uint64_t it2 = it + 1; it2 < len; ++it2) {</div>
|
||||
<div class="line"><span class="lineno"> 55</span> <span class="keywordflow">if</span> (array[it2] < array[min]) { <span class="comment">// check which element is smaller</span></div>
|
||||
<div class="line"><span class="lineno"> 56</span> min = it2; <span class="comment">// store index of smallest element to min</span></div>
|
||||
<div class="line"><span class="lineno"> 57</span> }</div>
|
||||
<div class="line"><span class="lineno"> 58</span> }</div>
|
||||
<div class="line"><span class="lineno"> 59</span> </div>
|
||||
<div class="line"><span class="lineno"> 60</span> <span class="keywordflow">if</span> (min != it) { <span class="comment">// swap if min does not match to i</span></div>
|
||||
<div class="line"><span class="lineno"> 61</span> uint64_t tmp = array[<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min.html">min</a>];</div>
|
||||
<div class="line"><span class="lineno"> 62</span> array[<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min.html">min</a>] = array[it];</div>
|
||||
<div class="line"><span class="lineno"> 63</span> array[it] = tmp;</div>
|
||||
<div class="line"><span class="lineno"> 64</span> }</div>
|
||||
<div class="line"><span class="lineno"> 65</span> }</div>
|
||||
<div class="line"><span class="lineno"> 66</span> </div>
|
||||
<div class="line"><span class="lineno"> 67</span> <span class="keywordflow">return</span> array; <span class="comment">// return sorted vector</span></div>
|
||||
<div class="line"><span class="lineno"> 68</span>}</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 49</span> {</div>
|
||||
<div class="line"><span class="lineno"> 50</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<uint64_t></a> array(</div>
|
||||
<div class="line"><span class="lineno"> 51</span> arr.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/begin.html">begin</a>(),</div>
|
||||
<div class="line"><span class="lineno"> 52</span> arr.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector/end.html">end</a>()); <span class="comment">// declare a vector in which result will be stored</span></div>
|
||||
<div class="line"><span class="lineno"> 53</span> <span class="keywordflow">for</span> (uint64_t it = 0; it < len; ++it) {</div>
|
||||
<div class="line"><span class="lineno"> 54</span> uint64_t min = it; <span class="comment">// set min value</span></div>
|
||||
<div class="line"><span class="lineno"> 55</span> <span class="keywordflow">for</span> (uint64_t it2 = it + 1; it2 < len; ++it2) {</div>
|
||||
<div class="line"><span class="lineno"> 56</span> <span class="keywordflow">if</span> (array[it2] < array[min]) { <span class="comment">// check which element is smaller</span></div>
|
||||
<div class="line"><span class="lineno"> 57</span> min = it2; <span class="comment">// store index of smallest element to min</span></div>
|
||||
<div class="line"><span class="lineno"> 58</span> }</div>
|
||||
<div class="line"><span class="lineno"> 59</span> }</div>
|
||||
<div class="line"><span class="lineno"> 60</span> </div>
|
||||
<div class="line"><span class="lineno"> 61</span> <span class="keywordflow">if</span> (min != it) { <span class="comment">// swap if min does not match to i</span></div>
|
||||
<div class="line"><span class="lineno"> 62</span> uint64_t tmp = array[<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min.html">min</a>];</div>
|
||||
<div class="line"><span class="lineno"> 63</span> array[<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min.html">min</a>] = array[it];</div>
|
||||
<div class="line"><span class="lineno"> 64</span> array[it] = tmp;</div>
|
||||
<div class="line"><span class="lineno"> 65</span> }</div>
|
||||
<div class="line"><span class="lineno"> 66</span> }</div>
|
||||
<div class="line"><span class="lineno"> 67</span> </div>
|
||||
<div class="line"><span class="lineno"> 68</span> <span class="keywordflow">return</span> array; <span class="comment">// return sorted vector</span></div>
|
||||
<div class="line"><span class="lineno"> 69</span>}</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="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
|
||||
Reference in New Issue
Block a user