mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-11-29 15:36:06 +08:00
Documentation for 8b1eab204b
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<!-- HTML header for doxygen 1.12.0-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<head>
|
||||
@@ -5,10 +6,15 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.12.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: search/exponential_search.cpp File Reference</title>
|
||||
<title>TheAlgorithms/C++: search/exponential_search.cpp File Reference</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../jquery.js"></script>
|
||||
<script type="text/javascript" src="../../dynsections.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
<script type="text/javascript" src="../../clipboard.js"></script>
|
||||
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../navtreedata.js"></script>
|
||||
@@ -18,14 +24,24 @@
|
||||
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../search/searchdata.js"></script>
|
||||
<script type="text/javascript" src="../../search/search.js"></script>
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
|
||||
jax: ["input/TeX","output/HTML-CSS"],
|
||||
});
|
||||
<script type="text/javascript">
|
||||
window.MathJax = {
|
||||
options: {
|
||||
ignoreHtmlClass: 'tex2jax_ignore',
|
||||
processHtmlClass: 'tex2jax_process'
|
||||
},
|
||||
loader: {
|
||||
load: ['[tex]/ams']
|
||||
},
|
||||
tex: {
|
||||
macros: {},
|
||||
packages: ['base','configmacros','ams']
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
|
||||
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
|
||||
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
@@ -33,10 +49,11 @@ MathJax.Hub.Config({
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
|
||||
<td id="projectalign">
|
||||
<div id="projectname">Algorithms_in_C++<span id="projectnumber"> 1.0.0</span>
|
||||
<div id="projectname">TheAlgorithms/C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">Set of algorithms implemented in C++.</div>
|
||||
<div id="projectbrief">All the algorithms implemented in C++</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -121,7 +138,9 @@ Include dependency graph for exponential_search.cpp:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/d3c/exponential__search_8cpp__incl.svg" width="326" height="126"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
</div><table class="memberdecls">
|
||||
</div>
|
||||
<p><a href="../../d8/d8a/exponential__search_8cpp_source.html">Go to the source code of this file.</a></p>
|
||||
<table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
||||
Functions</h2></td></tr>
|
||||
<tr class="memitem:ab06cedad209456eae95d37b7cd66acae" id="r_ab06cedad209456eae95d37b7cd66acae"><td class="memTemplParams" colspan="2">template<class Type > </td></tr>
|
||||
@@ -137,6 +156,8 @@ Functions</h2></td></tr>
|
||||
<div class="textblock"><p><a href="https://en.wikipedia.org/wiki/Exponential_search" target="_blank">Exponential search algorithm</a> </p>
|
||||
<dl class="section copyright"><dt>Copyright</dt><dd>2020 Divide-et-impera-11</dd></dl>
|
||||
<p>The algorithm try to search the range where the key should be. If it has been found we do a binary search there. The range of the search grows by exponential every time. If the key is larger than the last element of array, the start of block(block_front) will be equal to the end of block(block_size) and the algorithm return null ponter, every other cases the algoritm return fom the loop. </p>
|
||||
|
||||
<p class="definition">Definition in file <a class="el" href="../../d8/d8a/exponential__search_8cpp_source.html">exponential_search.cpp</a>.</p>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
<a id="ab06cedad209456eae95d37b7cd66acae" name="ab06cedad209456eae95d37b7cd66acae"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#ab06cedad209456eae95d37b7cd66acae">◆ </a></span>binary_s()</h2>
|
||||
@@ -182,11 +203,13 @@ template<class Type > </div>
|
||||
<code>nullptr</code> if value not found </dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../d8/d8a/exponential__search_8cpp_source.html#l00034">34</a> of file <a class="el" href="../../d8/d8a/exponential__search_8cpp_source.html">exponential_search.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 34</span> {</div>
|
||||
<div class="line"><span class="lineno"> 35</span> int32_t lower_index(0), upper_index(size - 1), middle_index;</div>
|
||||
<div class="line"><span class="lineno"> 36</span> </div>
|
||||
<div class="line"><span class="lineno"> 37</span> <span class="keywordflow">while</span> (lower_index <= upper_index) {</div>
|
||||
<div class="line"><span class="lineno"> 38</span> middle_index = <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/floor.html">std::floor</a>((lower_index + upper_index) / 2);</div>
|
||||
<div class="line"><span class="lineno"> 38</span> middle_index = std::floor((lower_index + upper_index) / 2);</div>
|
||||
<div class="line"><span class="lineno"> 39</span> </div>
|
||||
<div class="line"><span class="lineno"> 40</span> <span class="keywordflow">if</span> (*(array + middle_index) < key)</div>
|
||||
<div class="line"><span class="lineno"> 41</span> lower_index = (middle_index + 1);</div>
|
||||
@@ -198,13 +221,7 @@ template<class Type > </div>
|
||||
<div class="line"><span class="lineno"> 47</span> </div>
|
||||
<div class="line"><span class="lineno"> 48</span> <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div>
|
||||
<div class="line"><span class="lineno"> 49</span>}</div>
|
||||
<div class="ttc" id="afloor_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/floor.html">std::floor</a></div><div class="ttdeci">T floor(T... args)</div></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="../../d8/d8a/exponential__search_8cpp_ab06cedad209456eae95d37b7cd66acae_cgraph.svg" width="202" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
|
||||
@@ -222,6 +239,8 @@ Here is the call graph for this function:</div>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p>Main function </p>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../d8/d8a/exponential__search_8cpp_source.html#l00074">74</a> of file <a class="el" href="../../d8/d8a/exponential__search_8cpp_source.html">exponential_search.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 74</span> {</div>
|
||||
<div class="line"><span class="lineno"> 75</span> <span class="comment">// TEST CASES</span></div>
|
||||
<div class="line"><span class="lineno"> 76</span> <span class="keywordtype">int</span>* sorted_array = <span class="keyword">new</span> <span class="keywordtype">int</span>[7]{7, 10, 15, 23, 70, 105, 203};</div>
|
||||
@@ -233,13 +252,8 @@ Here is the call graph for this function:</div>
|
||||
<div class="line"><span class="lineno"> 82</span> <span class="keyword">delete</span>[] sorted_array;</div>
|
||||
<div class="line"><span class="lineno"> 83</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><span class="lineno"> 84</span>}</div>
|
||||
<div class="ttc" id="aexponential__search_8cpp_html_af421bf4b7b95f20ac86c233adfdb9208"><div class="ttname"><a href="#af421bf4b7b95f20ac86c233adfdb9208">struzik_search</a></div><div class="ttdeci">Type * struzik_search(Type *array, size_t size, Type key)</div><div class="ttdef"><b>Definition</b> exponential_search.cpp:59</div></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="../../d8/d8a/exponential__search_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="454" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="aexponential__search_8cpp_html_af421bf4b7b95f20ac86c233adfdb9208"><div class="ttname"><a href="#af421bf4b7b95f20ac86c233adfdb9208">struzik_search</a></div><div class="ttdeci">Type * struzik_search(Type *array, size_t size, Type key)</div><div class="ttdef"><b>Definition</b> <a href="../../d8/d8a/exponential__search_8cpp_source.html#l00059">exponential_search.cpp:59</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="af421bf4b7b95f20ac86c233adfdb9208" name="af421bf4b7b95f20ac86c233adfdb9208"></a>
|
||||
@@ -274,6 +288,8 @@ template<class Type > </div>
|
||||
<li>Space Complexity O(1)</li>
|
||||
<li>Auxiliary Space Complexity O(1) </li>
|
||||
</ul>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../d8/d8a/exponential__search_8cpp_source.html#l00059">59</a> of file <a class="el" href="../../d8/d8a/exponential__search_8cpp_source.html">exponential_search.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 59</span> {</div>
|
||||
<div class="line"><span class="lineno"> 60</span> uint32_t block_front(0), block_size = size == 0 ? 0 : 1;</div>
|
||||
<div class="line"><span class="lineno"> 61</span> <span class="keywordflow">while</span> (block_front != block_size) {</div>
|
||||
@@ -287,13 +303,8 @@ template<class Type > </div>
|
||||
<div class="line"><span class="lineno"> 69</span> }</div>
|
||||
<div class="line"><span class="lineno"> 70</span> <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div>
|
||||
<div class="line"><span class="lineno"> 71</span>}</div>
|
||||
<div class="ttc" id="aexponential__search_8cpp_html_ab06cedad209456eae95d37b7cd66acae"><div class="ttname"><a href="#ab06cedad209456eae95d37b7cd66acae">binary_s</a></div><div class="ttdeci">Type * binary_s(Type *array, size_t size, Type key)</div><div class="ttdef"><b>Definition</b> exponential_search.cpp:34</div></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="../../d8/d8a/exponential__search_8cpp_af421bf4b7b95f20ac86c233adfdb9208_cgraph.svg" width="356" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="aexponential__search_8cpp_html_ab06cedad209456eae95d37b7cd66acae"><div class="ttname"><a href="#ab06cedad209456eae95d37b7cd66acae">binary_s</a></div><div class="ttdeci">Type * binary_s(Type *array, size_t size, Type key)</div><div class="ttdef"><b>Definition</b> <a href="../../d8/d8a/exponential__search_8cpp_source.html#l00034">exponential_search.cpp:34</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- contents -->
|
||||
|
||||
Reference in New Issue
Block a user