Documentation for 8b1eab204b

This commit is contained in:
realstealthninja
2024-11-04 12:43:05 +00:00
parent 4fb6e622e9
commit a7bccf7d01
6732 changed files with 153919 additions and 365711 deletions

View File

@@ -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++: greedy_algorithms/binary_addition.cpp File Reference</title>
<title>TheAlgorithms/C++: greedy_algorithms/binary_addition.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">&#160;1.0.0</span>
<div id="projectname">TheAlgorithms/C++<span id="projectnumber">&#160;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>
@@ -123,7 +140,9 @@ Include dependency graph for binary_addition.cpp:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d5/d95/binary__addition_8cpp__incl.svg" width="347" 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="../../d9/d1f/binary__addition_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="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/df6/classgreedy__algorithms_1_1_binary_addition.html">greedy_algorithms::BinaryAddition</a></td></tr>
@@ -148,6 +167,8 @@ Functions</h2></td></tr>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Adds two binary numbers and outputs resulting string. </p>
<p>The algorithm for adding two binary strings works by processing them from right to left, similar to manual addition. It starts by determining the longer string's length to ensure both strings are fully traversed. For each pair of corresponding bits and any carry from the previous addition, it calculates the sum. If the sum exceeds 1, a carry is generated for the next bit. The results for each bit are collected in a result string, which is reversed at the end to present the final binary sum correctly. Additionally, the function validates the input to ensure that only valid binary strings (containing only '0' and '1') are processed. If invalid input is detected, it returns an empty string. </p><dl class="section author"><dt>Author</dt><dd><a href="https://github.com/mjk22071998" target="_blank">Muhammad Junaid Khalid</a> </dd></dl>
<p class="definition">Definition in file <a class="el" href="../../d9/d1f/binary__addition_8cpp_source.html">binary_addition.cpp</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">&#9670;&#160;</a></span>main()</h2>
@@ -167,17 +188,14 @@ Functions</h2></td></tr>
<p>main function </p>
<dl class="section return"><dt>Returns</dt><dd>0 on successful exit </dd></dl>
<p>To execute tests</p>
<p class="definition">Definition at line <a class="el" href="../../d9/d1f/binary__addition_8cpp_source.html#l00116">116</a> of file <a class="el" href="../../d9/d1f/binary__addition_8cpp_source.html">binary_addition.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 116</span> {</div>
<div class="line"><span class="lineno"> 117</span> <a class="code hl_function" href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>(); <span class="comment">/// To execute tests</span></div>
<div class="line"><span class="lineno"> 117</span> <a class="code hl_function" href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>(); </div>
<div class="line"><span class="lineno"> 118</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 119</span>}</div>
<div class="ttc" id="abinary__addition_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">run self test implementation.</div><div class="ttdef"><b>Definition</b> binary_addition.cpp:86</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><div class="zoom"><iframe scrolling="no" frameborder="0" src="../../d9/d1f/binary__addition_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="100%" height="487"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div></div>
</div>
<div class="ttc" id="abinary__addition_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">run self test implementation.</div><div class="ttdef"><b>Definition</b> <a href="../../d9/d1f/binary__addition_8cpp_source.html#l00086">binary_addition.cpp:86</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a483bb8ccf42aaf7375a83e91490eda1e" name="a483bb8ccf42aaf7375a83e91490eda1e"></a>
@@ -205,6 +223,8 @@ Here is the call graph for this function:</div>
<p>run self test implementation. </p>
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
<p class="definition">Definition at line <a class="el" href="../../d9/d1f/binary__addition_8cpp_source.html#l00086">86</a> of file <a class="el" href="../../d9/d1f/binary__addition_8cpp_source.html">binary_addition.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 86</span> {</div>
<div class="line"><span class="lineno"> 87</span> <a class="code hl_class" href="../../de/df6/classgreedy__algorithms_1_1_binary_addition.html">greedy_algorithms::BinaryAddition</a> binaryAddition;</div>
<div class="line"><span class="lineno"> 88</span> </div>
@@ -230,14 +250,9 @@ Here is the call graph for this function:</div>
<div class="line"><span class="lineno"> 108</span> assert(binaryAddition.<a class="code hl_function" href="../../de/df6/classgreedy__algorithms_1_1_binary_addition.html#a801fd1ec5cda76b0bb82cbf23ed4d527">addBinary</a>(<span class="stringliteral">&quot;1x1&quot;</span>, <span class="stringliteral">&quot;111&quot;</span>) == <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><span class="lineno"> 109</span> assert(binaryAddition.<a class="code hl_function" href="../../de/df6/classgreedy__algorithms_1_1_binary_addition.html#a801fd1ec5cda76b0bb82cbf23ed4d527">addBinary</a>(<span class="stringliteral">&quot;1234&quot;</span>, <span class="stringliteral">&quot;1101&quot;</span>) == <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><span class="lineno"> 110</span>}</div>
<div class="ttc" id="aclassgreedy__algorithms_1_1_binary_addition_html"><div class="ttname"><a href="../../de/df6/classgreedy__algorithms_1_1_binary_addition.html">greedy_algorithms::BinaryAddition</a></div><div class="ttdoc">A class to perform binary addition of two binary strings.</div><div class="ttdef"><b>Definition</b> binary_addition.cpp:31</div></div>
<div class="ttc" id="aclassgreedy__algorithms_1_1_binary_addition_html_a801fd1ec5cda76b0bb82cbf23ed4d527"><div class="ttname"><a href="../../de/df6/classgreedy__algorithms_1_1_binary_addition.html#a801fd1ec5cda76b0bb82cbf23ed4d527">greedy_algorithms::BinaryAddition::addBinary</a></div><div class="ttdeci">std::string addBinary(const std::string &amp;a, const std::string &amp;b)</div><div class="ttdoc">Adds two binary strings and returns the result as a binary string.</div><div class="ttdef"><b>Definition</b> binary_addition.cpp:40</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><div class="zoom"><iframe scrolling="no" frameborder="0" src="../../d9/d1f/binary__addition_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.svg" width="100%" height="487"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div></div>
</div>
<div class="ttc" id="aclassgreedy__algorithms_1_1_binary_addition_html"><div class="ttname"><a href="../../de/df6/classgreedy__algorithms_1_1_binary_addition.html">greedy_algorithms::BinaryAddition</a></div><div class="ttdoc">A class to perform binary addition of two binary strings.</div><div class="ttdef"><b>Definition</b> <a href="../../d9/d1f/binary__addition_8cpp_source.html#l00031">binary_addition.cpp:31</a></div></div>
<div class="ttc" id="aclassgreedy__algorithms_1_1_binary_addition_html_a801fd1ec5cda76b0bb82cbf23ed4d527"><div class="ttname"><a href="../../de/df6/classgreedy__algorithms_1_1_binary_addition.html#a801fd1ec5cda76b0bb82cbf23ed4d527">greedy_algorithms::BinaryAddition::addBinary</a></div><div class="ttdeci">std::string addBinary(const std::string &amp;a, const std::string &amp;b)</div><div class="ttdoc">Adds two binary strings and returns the result as a binary string.</div><div class="ttdef"><b>Definition</b> <a href="../../d9/d1f/binary__addition_8cpp_source.html#l00040">binary_addition.cpp:40</a></div></div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->