<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.categories.acsl.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Marc</id>
	<title>ACSL Category Descriptions - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://www.categories.acsl.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Marc"/>
	<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Special:Contributions/Marc"/>
	<updated>2026-04-24T00:20:31Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Boolean_Algebra&amp;diff=899</id>
		<title>Boolean Algebra</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Boolean_Algebra&amp;diff=899"/>
		<updated>2026-03-19T03:04:42Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Fundamental Identities */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;Boolean algebra&amp;#039;&amp;#039; is the branch of algebra in which the values of the variables and constants have exactly two values: &amp;#039;&amp;#039;true&amp;#039;&amp;#039; and &amp;#039;&amp;#039;false&amp;#039;&amp;#039;, usually denoted 1 and 0 respectively. &lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
&lt;br /&gt;
The basic operators in Boolean algebra are &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039;. The secondary operators are &amp;#039;&amp;#039;eXclusive OR&amp;#039;&amp;#039; (often called &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039;) and &amp;#039;&amp;#039;eXclusive NOR&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;XNOR&amp;#039;&amp;#039;&amp;#039;, sometimes called &amp;#039;&amp;#039;&amp;#039;equivalence&amp;#039;&amp;#039;&amp;#039;). They are secondary in the sense that they &lt;br /&gt;
can be composed from the basic operators.&lt;br /&gt;
&lt;br /&gt;
*The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of two values is true only whenever both values are true. It is written as $xy$ or $x \cdot y$. The values of  &amp;#039;&amp;#039;and&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x  y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of two values is true whenever either or both values are true. It is written as $x+y$. The values of  &amp;#039;&amp;#039;or&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x + y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; of  a value is its opposite; that is, the &amp;#039;&amp;#039;not&amp;#039;&amp;#039; of a true value is false whereas the &amp;#039;&amp;#039;not&amp;#039;&amp;#039; of a false value is true. It is written as $\overline{x}$ or $\neg{x}$. The values of  &amp;#039;&amp;#039;not&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ \overline{x}\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of two values is true whenever the values are different.  It uses the $\oplus$ operator, and can be built from the basic operators: $x \oplus y = x\ \overline{y}\ \ +\ \overline{x}\ \ y$ The values of  &amp;#039;&amp;#039;xor&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x \oplus y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 0&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
*The &amp;#039;&amp;#039;&amp;#039;XNOR&amp;#039;&amp;#039;&amp;#039; of two values is true whenever the values are the same. It is the &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; of the &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; function. It uses the $\odot$ operator: $x \odot y = \overline{x \oplus y}$. The &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039; can be built from basic operators: $x \odot y = x  y + \overline{x}  \overline{y}$ The values of  &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x \odot y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 0&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 1&lt;br /&gt;
|} &lt;br /&gt;
 &lt;br /&gt;
Just as algebra has basic rules for simplifying and evaluating expressions, so does Boolean algebra.&lt;br /&gt;
&lt;br /&gt;
== Why is Boolean Algebra Important for ACSL Students? ==&lt;br /&gt;
&lt;br /&gt;
Boolean algebra is important to programmers, computer scientists, and the general population. &lt;br /&gt;
&lt;br /&gt;
*For programmers, Boolean expressions are used for conditionals and loops. For example, the following snippet of code sums the even numbers that are not also multiples of 3, stopping when the sum hits 100:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
s = 0&lt;br /&gt;
x = 1&lt;br /&gt;
while (s &amp;lt; 100):&lt;br /&gt;
    if (x % 2 == 0) and (x % 3 != 0)&lt;br /&gt;
        then s = s + x&lt;br /&gt;
    x = x + 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Both the conditional statement &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;s &amp;lt; 100&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
and the Boolean expression with 2 conditional statements  &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(x % 2 == 0) and (x % 3 != 0)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
evaluate to &amp;#039;&amp;#039;true&amp;#039;&amp;#039; or &amp;#039;&amp;#039;false&amp;#039;&amp;#039;. &lt;br /&gt;
&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*For computer scientists, Boolean algebra is the basis for digital circuits that make up a computer&amp;#039;s hardware. The [[Digital Electronics]] category concerns a graphical representation of a circuit. That circuit is typically easiest to understand and evaluate by converting it to its Boolean algebra representation. &lt;br /&gt;
 &lt;br /&gt;
* The general population uses Boolean algebra, probably without knowing that they are doing so, when they enter search terms in Internet search engines. For example, the search expression &amp;#039;&amp;#039;jaguar speed -car&amp;#039;&amp;#039; is parsed by the search engine as the Boolean expression &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;&amp;quot;jaguar&amp;quot; and &amp;quot;car&amp;quot; and not &amp;quot;speed&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;; it returns pages about the speed of the jaguar animal, not the Jaguar car.&lt;br /&gt;
&lt;br /&gt;
==Laws==&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;law&amp;#039;&amp;#039;&amp;#039; of Boolean algebra is an identity such as &amp;lt;math&amp;gt;x + (y + z) = (x + y) + z&amp;lt;/math&amp;gt;&lt;br /&gt;
between two Boolean terms, where a &amp;#039;&amp;#039;&amp;#039;Boolean term&amp;#039;&amp;#039;&amp;#039; is defined as an expression built up from variables,  the constants 0 and 1, and operations &amp;#039;&amp;#039;and&amp;#039;&amp;#039;, &amp;#039;&amp;#039;or&amp;#039;&amp;#039;, &amp;#039;&amp;#039;not&amp;#039;&amp;#039;, &amp;#039;&amp;#039;xor&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
Like ordinary algebra, parentheses are used to group terms. When a &amp;#039;&amp;#039;not&amp;#039;&amp;#039; is represented with an overhead horizontal line, there is an implicit grouping of the terms under the line. That is, $x \cdot \overline{y + z}$ is evaluated as if it were written $x \cdot \overline{(y + z)}.$&lt;br /&gt;
&lt;br /&gt;
=== Order of Precedence ===&lt;br /&gt;
&lt;br /&gt;
The order of operator precedence is &amp;#039;&amp;#039;not&amp;#039;&amp;#039;; then &amp;#039;&amp;#039;and&amp;#039;&amp;#039;; then &amp;#039;&amp;#039;xor&amp;#039;&amp;#039; and &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039;; and finally &amp;#039;&amp;#039;or&amp;#039;&amp;#039;. Operators with the same level of precedence are evaluated from left-to-right. &lt;br /&gt;
 &lt;br /&gt;
=== Fundamental Identities ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Commutative Law – The order of application of two separate terms is not important. || $x+y = y+x$ || $x \cdot y = y \cdot x$ &lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Associative Law – Regrouping of the terms in an expression doesn&amp;#039;t change the value of the expression. ||$(x + y) + z$ = $x + (y + z)$ || $x \cdot (y \cdot z) = (x \cdot y) \cdot z$ &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Idempotent Law – A term that is &amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039;´ed or &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with itself is equal to that term. || $ x +x = x $ || $x \cdot x = x$&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Annihilator Law – A term that is &amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039;´ed with 1 is 1; a term &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with 0 is 0. || $x + 1 = 1$ || $ x \cdot 0 = 0 $ &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Identity Law – A term &amp;#039;&amp;#039;or&amp;#039;&amp;#039;´ed 0 or  &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with a 1 will always equal that term. || $x + 0 = x$  || $x \cdot 1 = x$&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Complement Law – A term &amp;#039;&amp;#039;or&amp;#039;&amp;#039;´ed with its complement equals 1 and a term &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with its complement equals 0. || $x + \overline{x} = 1 $ || $x \cdot \overline{x} = 0$&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Absorptive Law – Complex expressions can be reduced to a simpler ones by absorbing like terms. ||colspan=2|&lt;br /&gt;
$x+x  y = x$&lt;br /&gt;
&lt;br /&gt;
$ x +\bar{x}y = x + y $&lt;br /&gt;
&lt;br /&gt;
$x  (x+y) = x$&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Distributive Law – It&amp;#039;s OK to multiply or factor-out an expression.||colspan=2|&lt;br /&gt;
&lt;br /&gt;
$x \cdot (y + z) = xy + xz$&lt;br /&gt;
&lt;br /&gt;
$(x+y) \cdot (p + q) = xp + xq +yp + yq$&lt;br /&gt;
&lt;br /&gt;
$(x+y)(x+z)=x + yz $&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | DeMorgan&amp;#039;s Law – An &amp;#039;&amp;#039;or&amp;#039;&amp;#039; (&amp;#039;&amp;#039;and&amp;#039;&amp;#039;) expression that is negated is equal to the &amp;#039;&amp;#039;and&amp;#039;&amp;#039; (&amp;#039;&amp;#039;or&amp;#039;&amp;#039;) of the negation of each term.|| $\overline{x+y} = \overline{x} \cdot \overline{y}$||$\overline{x \cdot y} = \overline{x} + \overline{y}$&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Double Negation – A term that is inverted twice is equal to the original term.||colspan=2| $\overline{\overline{x}} = x $ &lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Relationship between XOR and XNOR|| colspan=2 | $ x\odot y = \overline{x\oplus y} = x \oplus \overline{y} =\overline{x} \oplus {y}$ &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
Problems in this category are typically of the form &amp;quot;Given a Boolean expression, simplify it as much as possible&amp;quot; or &amp;quot;Given a Boolean expression,&lt;br /&gt;
find the values of all possible inputs that make the expression &amp;#039;&amp;#039;true&amp;#039;&amp;#039;.&amp;quot;  Simplify means writing an equivalent expression using the fewest number of operators.&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: Simplify the Expression ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Simplify the following expression as much as possible:&lt;br /&gt;
$ \overline{ \overline{A(A+B)} + B\overline{A}}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The simplification proceeds as follows:&lt;br /&gt;
&lt;br /&gt;
:$\overline{ \overline{A(A+B)} + B\overline{A}}$&lt;br /&gt;
::{| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  &amp;lt;math&amp;gt;= \left(\overline{ \overline{A(A+B)}}\right) \cdot \left(\overline{ B\overline{A}}\right)&amp;lt;/math&amp;gt; ||&lt;br /&gt;
|  (DeMorgan&amp;#039;s Law)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;= \left(A(A+B)\right) \cdot \left( \overline{B}+\overline{\overline{A}}\right)&amp;lt;/math&amp;gt; ||&lt;br /&gt;
|  (Double Negation; DeMorgan&amp;#039;s Law)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;= A \cdot \left( \overline{B}+A\right)&amp;lt;/math&amp;gt; ||&lt;br /&gt;
|  (Absorption; Double Negation)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;=A&amp;lt;/math&amp;gt;  || &lt;br /&gt;
| (Absorption)&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Find Solutions ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Find all orderd pairs $(A,B)$ that make the following expression &amp;#039;&amp;#039;true&amp;#039;&amp;#039;:&lt;br /&gt;
$ \overline{ \overline{(A+B)} + \overline{A}B }$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
There are typically two approaches to solving this type of problem. One approach is to simplify the expression as much as possible, until&lt;br /&gt;
it&amp;#039;s obvious what the solutions are. The other approach is to create a truth table of all possible inputs, with columns for each subexpression.&lt;br /&gt;
&lt;br /&gt;
The simplification approach is as following:&lt;br /&gt;
:$ \overline{\overline{(A+B)} + \overline{A}B}$&lt;br /&gt;
::$= \overline{\overline{A+B}} \cdot \overline{\overline{A}B}$ &lt;br /&gt;
::$= (A+B) \cdot (\overline{\overline{A}}+\overline{B} ) $ &lt;br /&gt;
::$= (A+B) \cdot (A+\overline{B}) $ &lt;br /&gt;
::$= AA + A\overline{B} + BA + B\overline{B} $ &lt;br /&gt;
::$= A + A(\overline{B} + B) + 0 $ &lt;br /&gt;
::$= A + A(1)$ &lt;br /&gt;
::$= A + A$ &lt;br /&gt;
::$=A$&lt;br /&gt;
This means that all inputs are valid whenever $A$ is &amp;#039;&amp;#039;true&amp;#039;&amp;#039;: $(1,0)$ and $(1,1)$&lt;br /&gt;
&lt;br /&gt;
The truth table approach is as following. Each column is the result of a basic operation on two other columns. &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#1&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#2&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#3 &lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#4&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#5&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#6&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#7&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#8&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff&amp;quot;|&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff&amp;quot;|&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |OR of Col#1, Col#2&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |NOT of Col#3&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |NOT of Col#1&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |ADD of Col#1, Col#2&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |OR of Col#4, Col#6&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |NOT of Col#7 &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;A+B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A+B}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A}B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A+B} + \overline{A}B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{\overline{A+B} + \overline{A}B}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
!0&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
!0&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
!1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
!1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The rightmost column is the expression we are solving; it is &amp;#039;&amp;#039;true&amp;#039;&amp;#039; for the 3rd and 4th rows, where the inputs are $(1,0)$ and $(1,1)$.&lt;br /&gt;
&lt;br /&gt;
== Online Resources ==&lt;br /&gt;
&lt;br /&gt;
===Websites===&lt;br /&gt;
A great online tutorial on Boolean Algebra is part of [https://ryanstutorials.net/boolean-algebra-tutorial/ Ryan&amp;#039;s Tutorials]. There are many online Boolean Calculators.  This one gives Truth Tables [https://sheabunge.github.io/boolcalc/ calculator ]. This link that has ads also simplifies and uses ! for NOT [https://www.boolean-algebra.com/ calculator].&lt;br /&gt;
&lt;br /&gt;
===Videos===&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some previous problems. To access the YouTube page with the video, click on the title of the video in the icon. (You can also play the video directly by clicking on the arrow in the center of the image; however, you&amp;#039;ll &lt;br /&gt;
probably want to have a larger viewing of the video since it contains writing on a whiteboard.) Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/HJdhEjpVYsY&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/HJdhEjpVYsY &amp;#039;&amp;#039;ACSL Boolean Algebra Contest 2 Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Mr. Minich is an ACSL advisor. This video was one of two he created to help prepare his students for the ACSL Boolean algebra category. It shows solutions to 5 different problems that have&lt;br /&gt;
appeared in recent years. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/4io6xgz8Zwk&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/4io6xgz8Zwk &amp;#039;&amp;#039;ACSL Boolean Algebra Contest 2 Worksheet 2&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;) ]&lt;br /&gt;
&lt;br /&gt;
Mr. Minich is an ACSL advisor. This video was one of two he created to help prepare his students for the ACSL Boolean algebra category. It shows solutions to 5 different problems that have&lt;br /&gt;
appeared in recent years. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/6vI1mO1XOjQ&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/6vI1mO1XOjQ &amp;#039;&amp;#039;ACSL 3 13-14 #1 - AM&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Gordon Campbell&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video walks through the solution to finding all ordered triples that make the following&lt;br /&gt;
Boolean expression &amp;#039;&amp;#039;true&amp;#039;&amp;#039;:&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
(AB+\overline{C})(\overline{A}+BC)(A+\overline{B}+C)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
This problem appeared in 2013-2014 in the Senior Division, Contest #3.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/KRKTbAZYlLM&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/KRKTbAZYlLM &amp;#039;&amp;#039;ACSL 3 #1 14-15 - AM&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Gordon Campbell&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video walks through the simplification of the expression:&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
\overline{(\overline{A}+B)}(B+C)\overline{(A+\overline{C})}(A\overline{B}+BC)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
This problem appeared in 2014-2015 in the Senior Division, Contest #3.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jDnni-zm2g8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jDnni-zm2g8 &amp;#039;&amp;#039;A general tutorial on boolean algebra that can be used for American Computer Science League.&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Walks through the simplification of the following Boolean expression:&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
\overline{ (\overline{A + \overline{B}})(AB)} +&lt;br /&gt;
\overline{ (A+B)(\overline{\overline{A}B})}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=896</id>
		<title>What Does This Program Do?</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=896"/>
		<updated>2025-10-07T17:43:38Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Description of the ACSL Pseudo-code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Frequently, one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, and documentation is, unfortunately,&lt;br /&gt;
not always available or sufficient, it is essential to be able to read and understand an arbitrary program.  &lt;br /&gt;
&lt;br /&gt;
This category presents a program and asks the student to determine that the program does. The programs are written using a pseudocode that&lt;br /&gt;
should be readily understandable by all programmers familiar with a high-level programming language, such as Python, Java, or C.&lt;br /&gt;
&lt;br /&gt;
= Description of the ACSL Pseudo-code =&lt;br /&gt;
&lt;br /&gt;
We will use the following constructs in writing this code for this topic in ACSL:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Construct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Code Segment&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|Operators&lt;br /&gt;
|! (not) , ^ or ↑(exponent), *, / (real division), % (modulus), +, -, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, !=, ==, &amp;amp;&amp;amp; (and), &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt; (or) in that order of precedence&lt;br /&gt;
|-&lt;br /&gt;
|Functions&lt;br /&gt;
|abs(x) - absolute value, sqrt(x) - square root, int(x) - greatest integer &amp;lt;= x&lt;br /&gt;
|-&lt;br /&gt;
|Variables&lt;br /&gt;
|Start with a letter, only letters and digits&lt;br /&gt;
|-&lt;br /&gt;
|Sequential statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|INPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|variable = expression (assignment)&lt;br /&gt;
|-&lt;br /&gt;
|OUTPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|On occasion, sequential statements may be grouped on a single line by using a colon separator.&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Decision statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|IF boolean expression THEN&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|ELSE   (optional)&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END IF&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Indefinite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|WHILE Boolean expression&lt;br /&gt;
|-&lt;br /&gt;
|     Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END WHILE&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Definite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|FOR variable = start TO end STEP increment&lt;br /&gt;
|-&lt;br /&gt;
|    Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|NEXT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Arrays:&lt;br /&gt;
|1 dimensional  arrays use a single subscript such as A(5).  2 dimensional arrays use (row, col) order such as A(2,3).  Arrays can start at location 0 for 1 dimensional arrays and location (0,0) for 2 dimensional arrays.  Most ACSL past problems start with either A(1) or A(1,1).  The size of the array will usually be specified in the problem statement.&lt;br /&gt;
|-&lt;br /&gt;
|Strings:&lt;br /&gt;
|Strings can contain 0 or more characters and the indexed position starts with 0 at the first character.  An empty string has a length of 0.  Errors occur if accessing a character that is in a negative position or equal to the length of the string or larger.  The len(A) function will find the length of the string which is the total number of characters.  Strings are identified with surrounding double quotes. Use [ ] for identifying the characters in a substring of a given string as follows:  &lt;br /&gt;
S = “ACSL WDTPD” (S has a length of 10 and D is at location 9)&lt;br /&gt;
&lt;br /&gt;
S[:3] = “ACS” (take the first 3 characters starting on the left) &lt;br /&gt;
&lt;br /&gt;
S[4:] = “DTPD” (take the last 4 characters starting on the right) &lt;br /&gt;
&lt;br /&gt;
S[2:6] = “SL WD” (take the characters starting at location 2 and ending at location 6)&lt;br /&gt;
&lt;br /&gt;
S[0] = “A” (position 0 only). &lt;br /&gt;
&lt;br /&gt;
String concatenation is accomplished using the + symbol&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The questions in this topic will cover any of the above constructs in the Intermediate and Senior Division.  &lt;br /&gt;
In the Junior Division, Contest 1 will use branching, Contest 2 will use loops, Contest 3 will use arrays, and Contest 4&lt;br /&gt;
will use strings.&lt;br /&gt;
&lt;br /&gt;
= Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
After this program is executed, what is the value of b that is printed if the input values are 50 and 10?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
input h, r&lt;br /&gt;
b = 0&lt;br /&gt;
if h &amp;gt; 48 then&lt;br /&gt;
    b = b + (h - 48) * 2 * r&lt;br /&gt;
    h = 48&lt;br /&gt;
end if&lt;br /&gt;
if h &amp;gt; 40 then&lt;br /&gt;
   b = b + (h - 40) * (3/2) * r&lt;br /&gt;
   h = 40&lt;br /&gt;
end if&lt;br /&gt;
b = b + h * r&lt;br /&gt;
output b&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This program computes an employee’s weekly salary, given the hourly rate (r) and the number of hours worked in the week (h).  The employee is paid an hourly rate for the number of hours worked, up to 40, time and a half for the overtime hours, up to 48 hours, and double for all hours over 48.  The table monitors variables b and h:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! | b || h&lt;br /&gt;
|-&lt;br /&gt;
| | 0 || 50&lt;br /&gt;
|-&lt;br /&gt;
| | 40 || 48&lt;br /&gt;
|-&lt;br /&gt;
| | 160 || 40&lt;br /&gt;
|-&lt;br /&gt;
| | 560 || 40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the final value of b is 2*2*10 + 8*3/2*10 + 40*10 = 40 + 120 + 400 = 560.&lt;br /&gt;
&lt;br /&gt;
== Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of num?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
a = “BANANAS”&lt;br /&gt;
num = 0; t = “”&lt;br /&gt;
for j = len(a)-1 to 0 step –1&lt;br /&gt;
     t = t + a[j]&lt;br /&gt;
next j&lt;br /&gt;
for j = 0 to len(a) - 1&lt;br /&gt;
    if a[j] == t[j] then&lt;br /&gt;
       num = num + 1&lt;br /&gt;
    end if&lt;br /&gt;
next j&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The program first stores the reverse of string variable a into string variable t and then counts the number of letters that are in the same position in both strings.&lt;br /&gt;
Variable num is incremented each time a character at position x of a is the same as the character in position x of string a. There are 5 such positions: 1, 2, 3, 4, and 5.&lt;br /&gt;
&lt;br /&gt;
== Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of C(4)?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A(0) = 12; A(1) = 41; A(2) = 52&lt;br /&gt;
A(3) = 57; A(4) = 77; A(5) = -100&lt;br /&gt;
B(0) = 17; B(1) = 34; B(2) = 81&lt;br /&gt;
j = 0; k = 0; n = 0&lt;br /&gt;
while A(k) &amp;gt; 0&lt;br /&gt;
  while B(k) &amp;lt;= A(j)&lt;br /&gt;
    C(n) = B(k)&lt;br /&gt;
    n = n + 1&lt;br /&gt;
    k = k + 1&lt;br /&gt;
  end while&lt;br /&gt;
  C(n) = A(j)&lt;br /&gt;
  n = n + 1&lt;br /&gt;
  j = j + 1&lt;br /&gt;
end while&lt;br /&gt;
C(n) = B(k)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following table traces the variables through the execution of the program. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!j&lt;br /&gt;
!k&lt;br /&gt;
!n&lt;br /&gt;
!A(j)&lt;br /&gt;
!B(k)&lt;br /&gt;
!C(n)&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0  || 0  || 12 || 17 || 12&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 41 || 17 || 17&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 2 || 41 || 34 || 34&lt;br /&gt;
|-&lt;br /&gt;
|1 || 2 || 3 || 41 || 81 || 41&lt;br /&gt;
|-&lt;br /&gt;
|2 || 2 || 4 || 52 || 81 || 52&lt;br /&gt;
|-&lt;br /&gt;
|3 || 2 || 5 || 57 || 81 || 57&lt;br /&gt;
|-&lt;br /&gt;
|4 || 2 || 6 || 77 || 81 || 77&lt;br /&gt;
|-&lt;br /&gt;
|5 || 2 || 7 || -100 || 81 || 81&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thus, the value of C(4) is 52.  Note that this program merges two arrays in increasing order into one array until a negative number is input.&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IBlXLEWeHjc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IBlXLEWeHjc &amp;#039;&amp;#039;ACSL Math: What Does This Program Do?&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=895</id>
		<title>What Does This Program Do?</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=895"/>
		<updated>2025-10-07T17:41:27Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Problem 3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Frequently, one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, and documentation is, unfortunately,&lt;br /&gt;
not always available or sufficient, it is essential to be able to read and understand an arbitrary program.  &lt;br /&gt;
&lt;br /&gt;
This category presents a program and asks the student to determine that the program does. The programs are written using a pseudocode that&lt;br /&gt;
should be readily understandable by all programmers familiar with a high-level programming language, such as Python, Java, or C.&lt;br /&gt;
&lt;br /&gt;
= Description of the ACSL Pseudo-code =&lt;br /&gt;
&lt;br /&gt;
We will use the following constructs in writing this code for this topic in ACSL:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Construct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Code Segment&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|Operators&lt;br /&gt;
|! (not) , ^ or ↑(exponent), *, / (real division), % (modulus), +, -, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, !=, ==, &amp;amp;&amp;amp; (and), &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt; (or) in that order of precedence&lt;br /&gt;
|-&lt;br /&gt;
|Functions&lt;br /&gt;
|abs(x) - absolute value, sqrt(x) - square root, int(x) - greatest integer &amp;lt;= x&lt;br /&gt;
|-&lt;br /&gt;
|Variables&lt;br /&gt;
|Start with a letter, only letters and digits&lt;br /&gt;
|-&lt;br /&gt;
|Sequential statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|INPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|variable = expression (assignment)&lt;br /&gt;
|-&lt;br /&gt;
|OUTPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|On occasion, sequential statements may be grouped on a single line by using a semicolon.&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Decision statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|IF boolean expression THEN&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|ELSE   (optional)&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END IF&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Indefinite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|WHILE Boolean expression&lt;br /&gt;
|-&lt;br /&gt;
|     Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END WHILE&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Definite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|FOR variable = start TO end STEP increment&lt;br /&gt;
|-&lt;br /&gt;
|    Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|NEXT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Arrays:&lt;br /&gt;
|1 dimensional  arrays use a single subscript such as A(5).  2 dimensional arrays use (row, col) order such as A(2,3).  Arrays can start at location 0 for 1 dimensional arrays and location (0,0) for 2 dimensional arrays.  Most ACSL past problems start with either A(1) or A(1,1).  The size of the array will usually be specified in the problem statement.&lt;br /&gt;
|-&lt;br /&gt;
|Strings:&lt;br /&gt;
|Strings can contain 0 or more characters and the indexed position starts with 0 at the first character.  An empty string has a length of 0.  Errors occur if accessing a character that is in a negative position or equal to the length of the string or larger.  The len(A) function will find the length of the string which is the total number of characters.  Strings are identified with surrounding double quotes. Use [ ] for identifying the characters in a substring of a given string as follows:  &lt;br /&gt;
S = “ACSL WDTPD” (S has a length of 10 and D is at location 9)&lt;br /&gt;
&lt;br /&gt;
S[:3] = “ACS” (take the first 3 characters starting on the left) &lt;br /&gt;
&lt;br /&gt;
S[4:] = “DTPD” (take the last 4 characters starting on the right) &lt;br /&gt;
&lt;br /&gt;
S[2:6] = “SL WD” (take the characters starting at location 2 and ending at location 6)&lt;br /&gt;
&lt;br /&gt;
S[0] = “A” (position 0 only). &lt;br /&gt;
&lt;br /&gt;
String concatenation is accomplished using the + symbol&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The questions in this topic will cover any of the above constructs in the Intermediate and Senior Division.  &lt;br /&gt;
In the Junior Division, Contest 1 will use branching, Contest 2 will use loops, Contest 3 will use arrays, and Contest 4&lt;br /&gt;
will use strings.&lt;br /&gt;
&lt;br /&gt;
= Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
After this program is executed, what is the value of b that is printed if the input values are 50 and 10?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
input h, r&lt;br /&gt;
b = 0&lt;br /&gt;
if h &amp;gt; 48 then&lt;br /&gt;
    b = b + (h - 48) * 2 * r&lt;br /&gt;
    h = 48&lt;br /&gt;
end if&lt;br /&gt;
if h &amp;gt; 40 then&lt;br /&gt;
   b = b + (h - 40) * (3/2) * r&lt;br /&gt;
   h = 40&lt;br /&gt;
end if&lt;br /&gt;
b = b + h * r&lt;br /&gt;
output b&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This program computes an employee’s weekly salary, given the hourly rate (r) and the number of hours worked in the week (h).  The employee is paid an hourly rate for the number of hours worked, up to 40, time and a half for the overtime hours, up to 48 hours, and double for all hours over 48.  The table monitors variables b and h:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! | b || h&lt;br /&gt;
|-&lt;br /&gt;
| | 0 || 50&lt;br /&gt;
|-&lt;br /&gt;
| | 40 || 48&lt;br /&gt;
|-&lt;br /&gt;
| | 160 || 40&lt;br /&gt;
|-&lt;br /&gt;
| | 560 || 40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the final value of b is 2*2*10 + 8*3/2*10 + 40*10 = 40 + 120 + 400 = 560.&lt;br /&gt;
&lt;br /&gt;
== Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of num?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
a = “BANANAS”&lt;br /&gt;
num = 0; t = “”&lt;br /&gt;
for j = len(a)-1 to 0 step –1&lt;br /&gt;
     t = t + a[j]&lt;br /&gt;
next j&lt;br /&gt;
for j = 0 to len(a) - 1&lt;br /&gt;
    if a[j] == t[j] then&lt;br /&gt;
       num = num + 1&lt;br /&gt;
    end if&lt;br /&gt;
next j&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The program first stores the reverse of string variable a into string variable t and then counts the number of letters that are in the same position in both strings.&lt;br /&gt;
Variable num is incremented each time a character at position x of a is the same as the character in position x of string a. There are 5 such positions: 1, 2, 3, 4, and 5.&lt;br /&gt;
&lt;br /&gt;
== Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of C(4)?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A(0) = 12; A(1) = 41; A(2) = 52&lt;br /&gt;
A(3) = 57; A(4) = 77; A(5) = -100&lt;br /&gt;
B(0) = 17; B(1) = 34; B(2) = 81&lt;br /&gt;
j = 0; k = 0; n = 0&lt;br /&gt;
while A(k) &amp;gt; 0&lt;br /&gt;
  while B(k) &amp;lt;= A(j)&lt;br /&gt;
    C(n) = B(k)&lt;br /&gt;
    n = n + 1&lt;br /&gt;
    k = k + 1&lt;br /&gt;
  end while&lt;br /&gt;
  C(n) = A(j)&lt;br /&gt;
  n = n + 1&lt;br /&gt;
  j = j + 1&lt;br /&gt;
end while&lt;br /&gt;
C(n) = B(k)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following table traces the variables through the execution of the program. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!j&lt;br /&gt;
!k&lt;br /&gt;
!n&lt;br /&gt;
!A(j)&lt;br /&gt;
!B(k)&lt;br /&gt;
!C(n)&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0  || 0  || 12 || 17 || 12&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 41 || 17 || 17&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 2 || 41 || 34 || 34&lt;br /&gt;
|-&lt;br /&gt;
|1 || 2 || 3 || 41 || 81 || 41&lt;br /&gt;
|-&lt;br /&gt;
|2 || 2 || 4 || 52 || 81 || 52&lt;br /&gt;
|-&lt;br /&gt;
|3 || 2 || 5 || 57 || 81 || 57&lt;br /&gt;
|-&lt;br /&gt;
|4 || 2 || 6 || 77 || 81 || 77&lt;br /&gt;
|-&lt;br /&gt;
|5 || 2 || 7 || -100 || 81 || 81&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thus, the value of C(4) is 52.  Note that this program merges two arrays in increasing order into one array until a negative number is input.&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IBlXLEWeHjc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IBlXLEWeHjc &amp;#039;&amp;#039;ACSL Math: What Does This Program Do?&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=894</id>
		<title>What Does This Program Do?</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=894"/>
		<updated>2025-10-07T17:40:38Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Problem 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Frequently, one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, and documentation is, unfortunately,&lt;br /&gt;
not always available or sufficient, it is essential to be able to read and understand an arbitrary program.  &lt;br /&gt;
&lt;br /&gt;
This category presents a program and asks the student to determine that the program does. The programs are written using a pseudocode that&lt;br /&gt;
should be readily understandable by all programmers familiar with a high-level programming language, such as Python, Java, or C.&lt;br /&gt;
&lt;br /&gt;
= Description of the ACSL Pseudo-code =&lt;br /&gt;
&lt;br /&gt;
We will use the following constructs in writing this code for this topic in ACSL:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Construct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Code Segment&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|Operators&lt;br /&gt;
|! (not) , ^ or ↑(exponent), *, / (real division), % (modulus), +, -, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, !=, ==, &amp;amp;&amp;amp; (and), &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt; (or) in that order of precedence&lt;br /&gt;
|-&lt;br /&gt;
|Functions&lt;br /&gt;
|abs(x) - absolute value, sqrt(x) - square root, int(x) - greatest integer &amp;lt;= x&lt;br /&gt;
|-&lt;br /&gt;
|Variables&lt;br /&gt;
|Start with a letter, only letters and digits&lt;br /&gt;
|-&lt;br /&gt;
|Sequential statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|INPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|variable = expression (assignment)&lt;br /&gt;
|-&lt;br /&gt;
|OUTPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|On occasion, sequential statements may be grouped on a single line by using a semicolon.&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Decision statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|IF boolean expression THEN&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|ELSE   (optional)&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END IF&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Indefinite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|WHILE Boolean expression&lt;br /&gt;
|-&lt;br /&gt;
|     Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END WHILE&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Definite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|FOR variable = start TO end STEP increment&lt;br /&gt;
|-&lt;br /&gt;
|    Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|NEXT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Arrays:&lt;br /&gt;
|1 dimensional  arrays use a single subscript such as A(5).  2 dimensional arrays use (row, col) order such as A(2,3).  Arrays can start at location 0 for 1 dimensional arrays and location (0,0) for 2 dimensional arrays.  Most ACSL past problems start with either A(1) or A(1,1).  The size of the array will usually be specified in the problem statement.&lt;br /&gt;
|-&lt;br /&gt;
|Strings:&lt;br /&gt;
|Strings can contain 0 or more characters and the indexed position starts with 0 at the first character.  An empty string has a length of 0.  Errors occur if accessing a character that is in a negative position or equal to the length of the string or larger.  The len(A) function will find the length of the string which is the total number of characters.  Strings are identified with surrounding double quotes. Use [ ] for identifying the characters in a substring of a given string as follows:  &lt;br /&gt;
S = “ACSL WDTPD” (S has a length of 10 and D is at location 9)&lt;br /&gt;
&lt;br /&gt;
S[:3] = “ACS” (take the first 3 characters starting on the left) &lt;br /&gt;
&lt;br /&gt;
S[4:] = “DTPD” (take the last 4 characters starting on the right) &lt;br /&gt;
&lt;br /&gt;
S[2:6] = “SL WD” (take the characters starting at location 2 and ending at location 6)&lt;br /&gt;
&lt;br /&gt;
S[0] = “A” (position 0 only). &lt;br /&gt;
&lt;br /&gt;
String concatenation is accomplished using the + symbol&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The questions in this topic will cover any of the above constructs in the Intermediate and Senior Division.  &lt;br /&gt;
In the Junior Division, Contest 1 will use branching, Contest 2 will use loops, Contest 3 will use arrays, and Contest 4&lt;br /&gt;
will use strings.&lt;br /&gt;
&lt;br /&gt;
= Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
After this program is executed, what is the value of b that is printed if the input values are 50 and 10?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
input h, r&lt;br /&gt;
b = 0&lt;br /&gt;
if h &amp;gt; 48 then&lt;br /&gt;
    b = b + (h - 48) * 2 * r&lt;br /&gt;
    h = 48&lt;br /&gt;
end if&lt;br /&gt;
if h &amp;gt; 40 then&lt;br /&gt;
   b = b + (h - 40) * (3/2) * r&lt;br /&gt;
   h = 40&lt;br /&gt;
end if&lt;br /&gt;
b = b + h * r&lt;br /&gt;
output b&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This program computes an employee’s weekly salary, given the hourly rate (r) and the number of hours worked in the week (h).  The employee is paid an hourly rate for the number of hours worked, up to 40, time and a half for the overtime hours, up to 48 hours, and double for all hours over 48.  The table monitors variables b and h:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! | b || h&lt;br /&gt;
|-&lt;br /&gt;
| | 0 || 50&lt;br /&gt;
|-&lt;br /&gt;
| | 40 || 48&lt;br /&gt;
|-&lt;br /&gt;
| | 160 || 40&lt;br /&gt;
|-&lt;br /&gt;
| | 560 || 40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the final value of b is 2*2*10 + 8*3/2*10 + 40*10 = 40 + 120 + 400 = 560.&lt;br /&gt;
&lt;br /&gt;
== Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of num?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
a = “BANANAS”&lt;br /&gt;
num = 0; t = “”&lt;br /&gt;
for j = len(a)-1 to 0 step –1&lt;br /&gt;
     t = t + a[j]&lt;br /&gt;
next j&lt;br /&gt;
for j = 0 to len(a) - 1&lt;br /&gt;
    if a[j] == t[j] then&lt;br /&gt;
       num = num + 1&lt;br /&gt;
    end if&lt;br /&gt;
next j&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The program first stores the reverse of string variable a into string variable t and then counts the number of letters that are in the same position in both strings.&lt;br /&gt;
Variable num is incremented each time a character at position x of a is the same as the character in position x of string a. There are 5 such positions: 1, 2, 3, 4, and 5.&lt;br /&gt;
&lt;br /&gt;
== Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of C(4)?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A(0) = 12: A(1) = 41: A(2) = 52&lt;br /&gt;
A(3) = 57: A(4) = 77: A(5) = -100&lt;br /&gt;
B(0) = 17: B(1) = 34: B(2) = 81&lt;br /&gt;
j = 0: k = 0: n = 0&lt;br /&gt;
while A(k) &amp;gt; 0&lt;br /&gt;
  while B(k) &amp;lt;= A(j)&lt;br /&gt;
    C(n) = B(k)&lt;br /&gt;
    n = n + 1&lt;br /&gt;
    k = k + 1&lt;br /&gt;
  end while&lt;br /&gt;
  C(n) = A(j)&lt;br /&gt;
  n = n + 1&lt;br /&gt;
  j = j + 1&lt;br /&gt;
end while&lt;br /&gt;
C(n) = B(k)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following table traces the variables through the execution of the program. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!j&lt;br /&gt;
!k&lt;br /&gt;
!n&lt;br /&gt;
!A(j)&lt;br /&gt;
!B(k)&lt;br /&gt;
!C(n)&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0  || 0  || 12 || 17 || 12&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 41 || 17 || 17&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 2 || 41 || 34 || 34&lt;br /&gt;
|-&lt;br /&gt;
|1 || 2 || 3 || 41 || 81 || 41&lt;br /&gt;
|-&lt;br /&gt;
|2 || 2 || 4 || 52 || 81 || 52&lt;br /&gt;
|-&lt;br /&gt;
|3 || 2 || 5 || 57 || 81 || 57&lt;br /&gt;
|-&lt;br /&gt;
|4 || 2 || 6 || 77 || 81 || 77&lt;br /&gt;
|-&lt;br /&gt;
|5 || 2 || 7 || -100 || 81 || 81&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thus, the value of C(4) is 52.  Note that this program merges two arrays in increasing order into one array until a negative number is input.&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IBlXLEWeHjc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IBlXLEWeHjc &amp;#039;&amp;#039;ACSL Math: What Does This Program Do?&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=893</id>
		<title>What Does This Program Do?</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=893"/>
		<updated>2025-10-07T17:40:06Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Description of the ACSL Pseudo-code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Frequently, one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, and documentation is, unfortunately,&lt;br /&gt;
not always available or sufficient, it is essential to be able to read and understand an arbitrary program.  &lt;br /&gt;
&lt;br /&gt;
This category presents a program and asks the student to determine that the program does. The programs are written using a pseudocode that&lt;br /&gt;
should be readily understandable by all programmers familiar with a high-level programming language, such as Python, Java, or C.&lt;br /&gt;
&lt;br /&gt;
= Description of the ACSL Pseudo-code =&lt;br /&gt;
&lt;br /&gt;
We will use the following constructs in writing this code for this topic in ACSL:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Construct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Code Segment&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|Operators&lt;br /&gt;
|! (not) , ^ or ↑(exponent), *, / (real division), % (modulus), +, -, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, !=, ==, &amp;amp;&amp;amp; (and), &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt; (or) in that order of precedence&lt;br /&gt;
|-&lt;br /&gt;
|Functions&lt;br /&gt;
|abs(x) - absolute value, sqrt(x) - square root, int(x) - greatest integer &amp;lt;= x&lt;br /&gt;
|-&lt;br /&gt;
|Variables&lt;br /&gt;
|Start with a letter, only letters and digits&lt;br /&gt;
|-&lt;br /&gt;
|Sequential statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|INPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|variable = expression (assignment)&lt;br /&gt;
|-&lt;br /&gt;
|OUTPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|On occasion, sequential statements may be grouped on a single line by using a semicolon.&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Decision statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|IF boolean expression THEN&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|ELSE   (optional)&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END IF&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Indefinite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|WHILE Boolean expression&lt;br /&gt;
|-&lt;br /&gt;
|     Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END WHILE&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Definite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|FOR variable = start TO end STEP increment&lt;br /&gt;
|-&lt;br /&gt;
|    Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|NEXT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Arrays:&lt;br /&gt;
|1 dimensional  arrays use a single subscript such as A(5).  2 dimensional arrays use (row, col) order such as A(2,3).  Arrays can start at location 0 for 1 dimensional arrays and location (0,0) for 2 dimensional arrays.  Most ACSL past problems start with either A(1) or A(1,1).  The size of the array will usually be specified in the problem statement.&lt;br /&gt;
|-&lt;br /&gt;
|Strings:&lt;br /&gt;
|Strings can contain 0 or more characters and the indexed position starts with 0 at the first character.  An empty string has a length of 0.  Errors occur if accessing a character that is in a negative position or equal to the length of the string or larger.  The len(A) function will find the length of the string which is the total number of characters.  Strings are identified with surrounding double quotes. Use [ ] for identifying the characters in a substring of a given string as follows:  &lt;br /&gt;
S = “ACSL WDTPD” (S has a length of 10 and D is at location 9)&lt;br /&gt;
&lt;br /&gt;
S[:3] = “ACS” (take the first 3 characters starting on the left) &lt;br /&gt;
&lt;br /&gt;
S[4:] = “DTPD” (take the last 4 characters starting on the right) &lt;br /&gt;
&lt;br /&gt;
S[2:6] = “SL WD” (take the characters starting at location 2 and ending at location 6)&lt;br /&gt;
&lt;br /&gt;
S[0] = “A” (position 0 only). &lt;br /&gt;
&lt;br /&gt;
String concatenation is accomplished using the + symbol&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The questions in this topic will cover any of the above constructs in the Intermediate and Senior Division.  &lt;br /&gt;
In the Junior Division, Contest 1 will use branching, Contest 2 will use loops, Contest 3 will use arrays, and Contest 4&lt;br /&gt;
will use strings.&lt;br /&gt;
&lt;br /&gt;
= Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
After this program is executed, what is the value of b that is printed if the input values are 50 and 10?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
input h, r&lt;br /&gt;
b = 0&lt;br /&gt;
if h &amp;gt; 48 then&lt;br /&gt;
    b = b + (h - 48) * 2 * r&lt;br /&gt;
    h = 48&lt;br /&gt;
end if&lt;br /&gt;
if h &amp;gt; 40 then&lt;br /&gt;
   b = b + (h - 40) * (3/2) * r&lt;br /&gt;
   h = 40&lt;br /&gt;
end if&lt;br /&gt;
b = b + h * r&lt;br /&gt;
output b&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This program computes an employee’s weekly salary, given the hourly rate (r) and the number of hours worked in the week (h).  The employee is paid an hourly rate for the number of hours worked, up to 40, time and a half for the overtime hours, up to 48 hours, and double for all hours over 48.  The table monitors variables b and h:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! | b || h&lt;br /&gt;
|-&lt;br /&gt;
| | 0 || 50&lt;br /&gt;
|-&lt;br /&gt;
| | 40 || 48&lt;br /&gt;
|-&lt;br /&gt;
| | 160 || 40&lt;br /&gt;
|-&lt;br /&gt;
| | 560 || 40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the final value of b is 2*2*10 + 8*3/2*10 + 40*10 = 40 + 120 + 400 = 560.&lt;br /&gt;
&lt;br /&gt;
== Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of num?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
a = “BANANAS”&lt;br /&gt;
num = 0: t = “”&lt;br /&gt;
for j = len(a)-1 to 0 step –1&lt;br /&gt;
     t = t + a[j]&lt;br /&gt;
next j&lt;br /&gt;
for j = 0 to len(a) - 1&lt;br /&gt;
    if a[j] == t[j] then&lt;br /&gt;
       num = num + 1&lt;br /&gt;
    end if&lt;br /&gt;
next j&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The program first stores the reverse of string variable a into string variable t and then counts the number of letters that are in the same position in both strings.&lt;br /&gt;
Variable num is incremented each time a character at position x of a is the same as the character in position x of string a. There are 5 such positions: 1, 2, 3, 4, and 5.&lt;br /&gt;
&lt;br /&gt;
== Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of C(4)?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A(0) = 12: A(1) = 41: A(2) = 52&lt;br /&gt;
A(3) = 57: A(4) = 77: A(5) = -100&lt;br /&gt;
B(0) = 17: B(1) = 34: B(2) = 81&lt;br /&gt;
j = 0: k = 0: n = 0&lt;br /&gt;
while A(k) &amp;gt; 0&lt;br /&gt;
  while B(k) &amp;lt;= A(j)&lt;br /&gt;
    C(n) = B(k)&lt;br /&gt;
    n = n + 1&lt;br /&gt;
    k = k + 1&lt;br /&gt;
  end while&lt;br /&gt;
  C(n) = A(j)&lt;br /&gt;
  n = n + 1&lt;br /&gt;
  j = j + 1&lt;br /&gt;
end while&lt;br /&gt;
C(n) = B(k)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following table traces the variables through the execution of the program. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!j&lt;br /&gt;
!k&lt;br /&gt;
!n&lt;br /&gt;
!A(j)&lt;br /&gt;
!B(k)&lt;br /&gt;
!C(n)&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0  || 0  || 12 || 17 || 12&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 41 || 17 || 17&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 2 || 41 || 34 || 34&lt;br /&gt;
|-&lt;br /&gt;
|1 || 2 || 3 || 41 || 81 || 41&lt;br /&gt;
|-&lt;br /&gt;
|2 || 2 || 4 || 52 || 81 || 52&lt;br /&gt;
|-&lt;br /&gt;
|3 || 2 || 5 || 57 || 81 || 57&lt;br /&gt;
|-&lt;br /&gt;
|4 || 2 || 6 || 77 || 81 || 77&lt;br /&gt;
|-&lt;br /&gt;
|5 || 2 || 7 || -100 || 81 || 81&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thus, the value of C(4) is 52.  Note that this program merges two arrays in increasing order into one array until a negative number is input.&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IBlXLEWeHjc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IBlXLEWeHjc &amp;#039;&amp;#039;ACSL Math: What Does This Program Do?&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=892</id>
		<title>What Does This Program Do?</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=892"/>
		<updated>2025-10-07T17:37:30Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Description of the ACSL Pseudo-code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Frequently, one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, and documentation is, unfortunately,&lt;br /&gt;
not always available or sufficient, it is essential to be able to read and understand an arbitrary program.  &lt;br /&gt;
&lt;br /&gt;
This category presents a program and asks the student to determine that the program does. The programs are written using a pseudocode that&lt;br /&gt;
should be readily understandable by all programmers familiar with a high-level programming language, such as Python, Java, or C.&lt;br /&gt;
&lt;br /&gt;
= Description of the ACSL Pseudo-code =&lt;br /&gt;
&lt;br /&gt;
We will use the following constructs in writing this code for this topic in ACSL:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Construct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Code Segment&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|Operators&lt;br /&gt;
|! (not) , ^ or ↑(exponent), *, / (real division), % (modulus), +, -, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, !=, ==, &amp;amp;&amp;amp; (and), &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt; (or) in that order of precedence&lt;br /&gt;
|-&lt;br /&gt;
|Functions&lt;br /&gt;
|abs(x) - absolute value, sqrt(x) - square root, int(x) - greatest integer &amp;lt;= x&lt;br /&gt;
|-&lt;br /&gt;
|Variables&lt;br /&gt;
|Start with a letter, only letters and digits&lt;br /&gt;
|-&lt;br /&gt;
|Sequential statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|INPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|variable = expression (assignment)&lt;br /&gt;
|-&lt;br /&gt;
|OUTPUT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Decision statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|IF boolean expression THEN&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|ELSE   (optional)&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END IF&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Indefinite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|WHILE Boolean expression&lt;br /&gt;
|-&lt;br /&gt;
|     Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END WHILE&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Definite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|FOR variable = start TO end STEP increment&lt;br /&gt;
|-&lt;br /&gt;
|    Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|NEXT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Arrays:&lt;br /&gt;
|1 dimensional  arrays use a single subscript such as A(5).  2 dimensional arrays use (row, col) order such as A(2,3).  Arrays can start at location 0 for 1 dimensional arrays and location (0,0) for 2 dimensional arrays.  Most ACSL past problems start with either A(1) or A(1,1).  The size of the array will usually be specified in the problem statement.&lt;br /&gt;
|-&lt;br /&gt;
|Strings:&lt;br /&gt;
|Strings can contain 0 or more characters and the indexed position starts with 0 at the first character.  An empty string has a length of 0.  Errors occur if accessing a character that is in a negative position or equal to the length of the string or larger.  The len(A) function will find the length of the string which is the total number of characters.  Strings are identified with surrounding double quotes. Use [ ] for identifying the characters in a substring of a given string as follows:  &lt;br /&gt;
S = “ACSL WDTPD” (S has a length of 10 and D is at location 9)&lt;br /&gt;
&lt;br /&gt;
S[:3] = “ACS” (take the first 3 characters starting on the left) &lt;br /&gt;
&lt;br /&gt;
S[4:] = “DTPD” (take the last 4 characters starting on the right) &lt;br /&gt;
&lt;br /&gt;
S[2:6] = “SL WD” (take the characters starting at location 2 and ending at location 6)&lt;br /&gt;
&lt;br /&gt;
S[0] = “A” (position 0 only). &lt;br /&gt;
&lt;br /&gt;
String concatenation is accomplished using the + symbol&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The questions in this topic will cover any of the above constructs in the Intermediate and Senior Division.  &lt;br /&gt;
In the Junior Division, Contest 1 will use branching, Contest 2 will use loops, Contest 3 will use arrays, and Contest 4&lt;br /&gt;
will use strings.&lt;br /&gt;
&lt;br /&gt;
= Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
After this program is executed, what is the value of b that is printed if the input values are 50 and 10?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
input h, r&lt;br /&gt;
b = 0&lt;br /&gt;
if h &amp;gt; 48 then&lt;br /&gt;
    b = b + (h - 48) * 2 * r&lt;br /&gt;
    h = 48&lt;br /&gt;
end if&lt;br /&gt;
if h &amp;gt; 40 then&lt;br /&gt;
   b = b + (h - 40) * (3/2) * r&lt;br /&gt;
   h = 40&lt;br /&gt;
end if&lt;br /&gt;
b = b + h * r&lt;br /&gt;
output b&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This program computes an employee’s weekly salary, given the hourly rate (r) and the number of hours worked in the week (h).  The employee is paid an hourly rate for the number of hours worked, up to 40, time and a half for the overtime hours, up to 48 hours, and double for all hours over 48.  The table monitors variables b and h:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! | b || h&lt;br /&gt;
|-&lt;br /&gt;
| | 0 || 50&lt;br /&gt;
|-&lt;br /&gt;
| | 40 || 48&lt;br /&gt;
|-&lt;br /&gt;
| | 160 || 40&lt;br /&gt;
|-&lt;br /&gt;
| | 560 || 40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the final value of b is 2*2*10 + 8*3/2*10 + 40*10 = 40 + 120 + 400 = 560.&lt;br /&gt;
&lt;br /&gt;
== Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of num?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
a = “BANANAS”&lt;br /&gt;
num = 0: t = “”&lt;br /&gt;
for j = len(a)-1 to 0 step –1&lt;br /&gt;
     t = t + a[j]&lt;br /&gt;
next j&lt;br /&gt;
for j = 0 to len(a) - 1&lt;br /&gt;
    if a[j] == t[j] then&lt;br /&gt;
       num = num + 1&lt;br /&gt;
    end if&lt;br /&gt;
next j&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The program first stores the reverse of string variable a into string variable t and then counts the number of letters that are in the same position in both strings.&lt;br /&gt;
Variable num is incremented each time a character at position x of a is the same as the character in position x of string a. There are 5 such positions: 1, 2, 3, 4, and 5.&lt;br /&gt;
&lt;br /&gt;
== Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of C(4)?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A(0) = 12: A(1) = 41: A(2) = 52&lt;br /&gt;
A(3) = 57: A(4) = 77: A(5) = -100&lt;br /&gt;
B(0) = 17: B(1) = 34: B(2) = 81&lt;br /&gt;
j = 0: k = 0: n = 0&lt;br /&gt;
while A(k) &amp;gt; 0&lt;br /&gt;
  while B(k) &amp;lt;= A(j)&lt;br /&gt;
    C(n) = B(k)&lt;br /&gt;
    n = n + 1&lt;br /&gt;
    k = k + 1&lt;br /&gt;
  end while&lt;br /&gt;
  C(n) = A(j)&lt;br /&gt;
  n = n + 1&lt;br /&gt;
  j = j + 1&lt;br /&gt;
end while&lt;br /&gt;
C(n) = B(k)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following table traces the variables through the execution of the program. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!j&lt;br /&gt;
!k&lt;br /&gt;
!n&lt;br /&gt;
!A(j)&lt;br /&gt;
!B(k)&lt;br /&gt;
!C(n)&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0  || 0  || 12 || 17 || 12&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 41 || 17 || 17&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 2 || 41 || 34 || 34&lt;br /&gt;
|-&lt;br /&gt;
|1 || 2 || 3 || 41 || 81 || 41&lt;br /&gt;
|-&lt;br /&gt;
|2 || 2 || 4 || 52 || 81 || 52&lt;br /&gt;
|-&lt;br /&gt;
|3 || 2 || 5 || 57 || 81 || 57&lt;br /&gt;
|-&lt;br /&gt;
|4 || 2 || 6 || 77 || 81 || 77&lt;br /&gt;
|-&lt;br /&gt;
|5 || 2 || 7 || -100 || 81 || 81&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thus, the value of C(4) is 52.  Note that this program merges two arrays in increasing order into one array until a negative number is input.&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IBlXLEWeHjc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IBlXLEWeHjc &amp;#039;&amp;#039;ACSL Math: What Does This Program Do?&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=891</id>
		<title>What Does This Program Do?</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=891"/>
		<updated>2025-10-07T17:36:28Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Problem 2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Frequently, one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, and documentation is, unfortunately,&lt;br /&gt;
not always available or sufficient, it is essential to be able to read and understand an arbitrary program.  &lt;br /&gt;
&lt;br /&gt;
This category presents a program and asks the student to determine that the program does. The programs are written using a pseudocode that&lt;br /&gt;
should be readily understandable by all programmers familiar with a high-level programming language, such as Python, Java, or C.&lt;br /&gt;
&lt;br /&gt;
= Description of the ACSL Pseudo-code =&lt;br /&gt;
&lt;br /&gt;
We will use the following constructs in writing this code for this topic in ACSL:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Construct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Code Segment&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|Operators&lt;br /&gt;
|! (not) , ^ or ↑(exponent), *, / (real division), % (modulus), +, -, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, !=, ==, &amp;amp;&amp;amp; (and), &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt; (or) in that order of precedence&lt;br /&gt;
|-&lt;br /&gt;
|Functions&lt;br /&gt;
|abs(x) - absolute value, sqrt(x) - square root, int(x) - greatest integer &amp;lt;= x&lt;br /&gt;
|-&lt;br /&gt;
|Variables&lt;br /&gt;
|Start with a letter, only letters and digits&lt;br /&gt;
|-&lt;br /&gt;
|Sequential statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|INPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|variable = expression (assignment)&lt;br /&gt;
|-&lt;br /&gt;
|OUTPUT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Decision statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|IF boolean expression THEN&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|ELSE   (optional)&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END IF&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Indefinite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|WHILE Boolean expression&lt;br /&gt;
|-&lt;br /&gt;
|     Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END WHILE&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Definite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|FOR variable = start TO end STEP increment&lt;br /&gt;
|-&lt;br /&gt;
|    Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|NEXT&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Arrays:&lt;br /&gt;
|1 dimensional  arrays use a single subscript such as A(5).  2 dimensional arrays use (row, col) order such as A(2,3).  Arrays can start at location 0 for 1 dimensional arrays and location (0,0) for 2 dimensional arrays.  Most ACSL past problems start with either A(1) or A(1,1).  The size of the array will usually be specified in the problem statement.&lt;br /&gt;
|-&lt;br /&gt;
|Strings:&lt;br /&gt;
|Strings can contain 0 or more characters and the indexed position starts with 0 at the first character.  An empty string has a length of 0.  Errors occur if accessing a character that is in a negative position or equal to the length of the string or larger.  The len(A) function will find the length of the string which is the total number of characters.  Strings are identified with surrounding double quotes. Use [ ] for identifying the characters in a substring of a given string as follows:  &lt;br /&gt;
S = “ACSL WDTPD” (S has a length of 10 and D is at location 9)&lt;br /&gt;
&lt;br /&gt;
S[:3] = “ACS” (take the first 3 characters starting on the left) &lt;br /&gt;
&lt;br /&gt;
S[4:] = “DTPD” (take the last 4 characters starting on the right) &lt;br /&gt;
&lt;br /&gt;
S[2:6] = “SL WD” (take the characters starting at location 2 and ending at location 6)&lt;br /&gt;
&lt;br /&gt;
S[0] = “A” (position 0 only). &lt;br /&gt;
&lt;br /&gt;
String concatenation is accomplished using the + symbol&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The questions in this topic will cover any of the above constructs in the Intermediate and Senior Division.  &lt;br /&gt;
In the Junior Division, Contest 1 will use branching, Contest 2 will use loops, Contest 3 will use arrays, and Contest 4&lt;br /&gt;
will use strings.&lt;br /&gt;
&lt;br /&gt;
= Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
After this program is executed, what is the value of b that is printed if the input values are 50 and 10?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
input h, r&lt;br /&gt;
b = 0&lt;br /&gt;
if h &amp;gt; 48 then&lt;br /&gt;
    b = b + (h - 48) * 2 * r&lt;br /&gt;
    h = 48&lt;br /&gt;
end if&lt;br /&gt;
if h &amp;gt; 40 then&lt;br /&gt;
   b = b + (h - 40) * (3/2) * r&lt;br /&gt;
   h = 40&lt;br /&gt;
end if&lt;br /&gt;
b = b + h * r&lt;br /&gt;
output b&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This program computes an employee’s weekly salary, given the hourly rate (r) and the number of hours worked in the week (h).  The employee is paid an hourly rate for the number of hours worked, up to 40, time and a half for the overtime hours, up to 48 hours, and double for all hours over 48.  The table monitors variables b and h:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! | b || h&lt;br /&gt;
|-&lt;br /&gt;
| | 0 || 50&lt;br /&gt;
|-&lt;br /&gt;
| | 40 || 48&lt;br /&gt;
|-&lt;br /&gt;
| | 160 || 40&lt;br /&gt;
|-&lt;br /&gt;
| | 560 || 40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the final value of b is 2*2*10 + 8*3/2*10 + 40*10 = 40 + 120 + 400 = 560.&lt;br /&gt;
&lt;br /&gt;
== Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of num?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
a = “BANANAS”&lt;br /&gt;
num = 0: t = “”&lt;br /&gt;
for j = len(a)-1 to 0 step –1&lt;br /&gt;
     t = t + a[j]&lt;br /&gt;
next j&lt;br /&gt;
for j = 0 to len(a) - 1&lt;br /&gt;
    if a[j] == t[j] then&lt;br /&gt;
       num = num + 1&lt;br /&gt;
    end if&lt;br /&gt;
next j&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The program first stores the reverse of string variable a into string variable t and then counts the number of letters that are in the same position in both strings.&lt;br /&gt;
Variable num is incremented each time a character at position x of a is the same as the character in position x of string a. There are 5 such positions: 1, 2, 3, 4, and 5.&lt;br /&gt;
&lt;br /&gt;
== Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of C(4)?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A(0) = 12: A(1) = 41: A(2) = 52&lt;br /&gt;
A(3) = 57: A(4) = 77: A(5) = -100&lt;br /&gt;
B(0) = 17: B(1) = 34: B(2) = 81&lt;br /&gt;
j = 0: k = 0: n = 0&lt;br /&gt;
while A(k) &amp;gt; 0&lt;br /&gt;
  while B(k) &amp;lt;= A(j)&lt;br /&gt;
    C(n) = B(k)&lt;br /&gt;
    n = n + 1&lt;br /&gt;
    k = k + 1&lt;br /&gt;
  end while&lt;br /&gt;
  C(n) = A(j)&lt;br /&gt;
  n = n + 1&lt;br /&gt;
  j = j + 1&lt;br /&gt;
end while&lt;br /&gt;
C(n) = B(k)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following table traces the variables through the execution of the program. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!j&lt;br /&gt;
!k&lt;br /&gt;
!n&lt;br /&gt;
!A(j)&lt;br /&gt;
!B(k)&lt;br /&gt;
!C(n)&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0  || 0  || 12 || 17 || 12&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 41 || 17 || 17&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 2 || 41 || 34 || 34&lt;br /&gt;
|-&lt;br /&gt;
|1 || 2 || 3 || 41 || 81 || 41&lt;br /&gt;
|-&lt;br /&gt;
|2 || 2 || 4 || 52 || 81 || 52&lt;br /&gt;
|-&lt;br /&gt;
|3 || 2 || 5 || 57 || 81 || 57&lt;br /&gt;
|-&lt;br /&gt;
|4 || 2 || 6 || 77 || 81 || 77&lt;br /&gt;
|-&lt;br /&gt;
|5 || 2 || 7 || -100 || 81 || 81&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thus, the value of C(4) is 52.  Note that this program merges two arrays in increasing order into one array until a negative number is input.&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IBlXLEWeHjc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IBlXLEWeHjc &amp;#039;&amp;#039;ACSL Math: What Does This Program Do?&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=890</id>
		<title>What Does This Program Do?</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=890"/>
		<updated>2025-10-07T17:32:31Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Problem 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Frequently, one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, and documentation is, unfortunately,&lt;br /&gt;
not always available or sufficient, it is essential to be able to read and understand an arbitrary program.  &lt;br /&gt;
&lt;br /&gt;
This category presents a program and asks the student to determine that the program does. The programs are written using a pseudocode that&lt;br /&gt;
should be readily understandable by all programmers familiar with a high-level programming language, such as Python, Java, or C.&lt;br /&gt;
&lt;br /&gt;
= Description of the ACSL Pseudo-code =&lt;br /&gt;
&lt;br /&gt;
We will use the following constructs in writing this code for this topic in ACSL:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Construct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Code Segment&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|Operators&lt;br /&gt;
|! (not) , ^ or ↑(exponent), *, / (real division), % (modulus), +, -, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, !=, ==, &amp;amp;&amp;amp; (and), &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt; (or) in that order of precedence&lt;br /&gt;
|-&lt;br /&gt;
|Functions&lt;br /&gt;
|abs(x) - absolute value, sqrt(x) - square root, int(x) - greatest integer &amp;lt;= x&lt;br /&gt;
|-&lt;br /&gt;
|Variables&lt;br /&gt;
|Start with a letter, only letters and digits&lt;br /&gt;
|-&lt;br /&gt;
|Sequential statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|INPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|variable = expression (assignment)&lt;br /&gt;
|-&lt;br /&gt;
|OUTPUT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Decision statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|IF boolean expression THEN&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|ELSE   (optional)&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END IF&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Indefinite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|WHILE Boolean expression&lt;br /&gt;
|-&lt;br /&gt;
|     Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END WHILE&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Definite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|FOR variable = start TO end STEP increment&lt;br /&gt;
|-&lt;br /&gt;
|    Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|NEXT&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Arrays:&lt;br /&gt;
|1 dimensional  arrays use a single subscript such as A(5).  2 dimensional arrays use (row, col) order such as A(2,3).  Arrays can start at location 0 for 1 dimensional arrays and location (0,0) for 2 dimensional arrays.  Most ACSL past problems start with either A(1) or A(1,1).  The size of the array will usually be specified in the problem statement.&lt;br /&gt;
|-&lt;br /&gt;
|Strings:&lt;br /&gt;
|Strings can contain 0 or more characters and the indexed position starts with 0 at the first character.  An empty string has a length of 0.  Errors occur if accessing a character that is in a negative position or equal to the length of the string or larger.  The len(A) function will find the length of the string which is the total number of characters.  Strings are identified with surrounding double quotes. Use [ ] for identifying the characters in a substring of a given string as follows:  &lt;br /&gt;
S = “ACSL WDTPD” (S has a length of 10 and D is at location 9)&lt;br /&gt;
&lt;br /&gt;
S[:3] = “ACS” (take the first 3 characters starting on the left) &lt;br /&gt;
&lt;br /&gt;
S[4:] = “DTPD” (take the last 4 characters starting on the right) &lt;br /&gt;
&lt;br /&gt;
S[2:6] = “SL WD” (take the characters starting at location 2 and ending at location 6)&lt;br /&gt;
&lt;br /&gt;
S[0] = “A” (position 0 only). &lt;br /&gt;
&lt;br /&gt;
String concatenation is accomplished using the + symbol&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The questions in this topic will cover any of the above constructs in the Intermediate and Senior Division.  &lt;br /&gt;
In the Junior Division, Contest 1 will use branching, Contest 2 will use loops, Contest 3 will use arrays, and Contest 4&lt;br /&gt;
will use strings.&lt;br /&gt;
&lt;br /&gt;
= Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
After this program is executed, what is the value of b that is printed if the input values are 50 and 10?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
input h, r&lt;br /&gt;
b = 0&lt;br /&gt;
if h &amp;gt; 48 then&lt;br /&gt;
    b = b + (h - 48) * 2 * r&lt;br /&gt;
    h = 48&lt;br /&gt;
end if&lt;br /&gt;
if h &amp;gt; 40 then&lt;br /&gt;
   b = b + (h - 40) * (3/2) * r&lt;br /&gt;
   h = 40&lt;br /&gt;
end if&lt;br /&gt;
b = b + h * r&lt;br /&gt;
output b&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This program computes an employee’s weekly salary, given the hourly rate (r) and the number of hours worked in the week (h).  The employee is paid an hourly rate for the number of hours worked, up to 40, time and a half for the overtime hours, up to 48 hours, and double for all hours over 48.  The table monitors variables b and h:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! | b || h&lt;br /&gt;
|-&lt;br /&gt;
| | 0 || 50&lt;br /&gt;
|-&lt;br /&gt;
| | 40 || 48&lt;br /&gt;
|-&lt;br /&gt;
| | 160 || 40&lt;br /&gt;
|-&lt;br /&gt;
| | 560 || 40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the final value of b is 2*2*10 + 8*3/2*10 + 40*10 = 40 + 120 + 400 = 560.&lt;br /&gt;
&lt;br /&gt;
== Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of NUM?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A = “BANANAS”&lt;br /&gt;
NUM = 0: T = “”&lt;br /&gt;
for J = len(A) - 1 to 0 step –1&lt;br /&gt;
     T = T + A[j]&lt;br /&gt;
next &lt;br /&gt;
for J = 0 to len(A) - 1&lt;br /&gt;
    if A[J] == T[J] then NUM = NUM + 1&lt;br /&gt;
next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The program first stores the reverse of variable A into variable T and then counts the number of letters that are in the same position in both strings.&lt;br /&gt;
Variable NUM is incremented each time a character at position x of A is the same as the character in position x of string T. There are 5 such positions: 1, 2, 3, 4, and 5.&lt;br /&gt;
&lt;br /&gt;
== Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of C(4)?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A(0) = 12: A(1) = 41: A(2) = 52&lt;br /&gt;
A(3) = 57: A(4) = 77: A(5) = -100&lt;br /&gt;
B(0) = 17: B(1) = 34: B(2) = 81&lt;br /&gt;
j = 0: k = 0: n = 0&lt;br /&gt;
while A(k) &amp;gt; 0&lt;br /&gt;
  while B(k) &amp;lt;= A(j)&lt;br /&gt;
    C(n) = B(k)&lt;br /&gt;
    n = n + 1&lt;br /&gt;
    k = k + 1&lt;br /&gt;
  end while&lt;br /&gt;
  C(n) = A(j)&lt;br /&gt;
  n = n + 1&lt;br /&gt;
  j = j + 1&lt;br /&gt;
end while&lt;br /&gt;
C(n) = B(k)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following table traces the variables through the execution of the program. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!j&lt;br /&gt;
!k&lt;br /&gt;
!n&lt;br /&gt;
!A(j)&lt;br /&gt;
!B(k)&lt;br /&gt;
!C(n)&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0  || 0  || 12 || 17 || 12&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 41 || 17 || 17&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 2 || 41 || 34 || 34&lt;br /&gt;
|-&lt;br /&gt;
|1 || 2 || 3 || 41 || 81 || 41&lt;br /&gt;
|-&lt;br /&gt;
|2 || 2 || 4 || 52 || 81 || 52&lt;br /&gt;
|-&lt;br /&gt;
|3 || 2 || 5 || 57 || 81 || 57&lt;br /&gt;
|-&lt;br /&gt;
|4 || 2 || 6 || 77 || 81 || 77&lt;br /&gt;
|-&lt;br /&gt;
|5 || 2 || 7 || -100 || 81 || 81&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thus, the value of C(4) is 52.  Note that this program merges two arrays in increasing order into one array until a negative number is input.&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IBlXLEWeHjc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IBlXLEWeHjc &amp;#039;&amp;#039;ACSL Math: What Does This Program Do?&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=889</id>
		<title>What Does This Program Do?</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=889"/>
		<updated>2025-10-07T17:29:35Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Problem 3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Frequently, one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, and documentation is, unfortunately,&lt;br /&gt;
not always available or sufficient, it is essential to be able to read and understand an arbitrary program.  &lt;br /&gt;
&lt;br /&gt;
This category presents a program and asks the student to determine that the program does. The programs are written using a pseudocode that&lt;br /&gt;
should be readily understandable by all programmers familiar with a high-level programming language, such as Python, Java, or C.&lt;br /&gt;
&lt;br /&gt;
= Description of the ACSL Pseudo-code =&lt;br /&gt;
&lt;br /&gt;
We will use the following constructs in writing this code for this topic in ACSL:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Construct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Code Segment&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|Operators&lt;br /&gt;
|! (not) , ^ or ↑(exponent), *, / (real division), % (modulus), +, -, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, !=, ==, &amp;amp;&amp;amp; (and), &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt; (or) in that order of precedence&lt;br /&gt;
|-&lt;br /&gt;
|Functions&lt;br /&gt;
|abs(x) - absolute value, sqrt(x) - square root, int(x) - greatest integer &amp;lt;= x&lt;br /&gt;
|-&lt;br /&gt;
|Variables&lt;br /&gt;
|Start with a letter, only letters and digits&lt;br /&gt;
|-&lt;br /&gt;
|Sequential statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|INPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|variable = expression (assignment)&lt;br /&gt;
|-&lt;br /&gt;
|OUTPUT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Decision statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|IF boolean expression THEN&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|ELSE   (optional)&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END IF&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Indefinite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|WHILE Boolean expression&lt;br /&gt;
|-&lt;br /&gt;
|     Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END WHILE&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Definite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|FOR variable = start TO end STEP increment&lt;br /&gt;
|-&lt;br /&gt;
|    Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|NEXT&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Arrays:&lt;br /&gt;
|1 dimensional  arrays use a single subscript such as A(5).  2 dimensional arrays use (row, col) order such as A(2,3).  Arrays can start at location 0 for 1 dimensional arrays and location (0,0) for 2 dimensional arrays.  Most ACSL past problems start with either A(1) or A(1,1).  The size of the array will usually be specified in the problem statement.&lt;br /&gt;
|-&lt;br /&gt;
|Strings:&lt;br /&gt;
|Strings can contain 0 or more characters and the indexed position starts with 0 at the first character.  An empty string has a length of 0.  Errors occur if accessing a character that is in a negative position or equal to the length of the string or larger.  The len(A) function will find the length of the string which is the total number of characters.  Strings are identified with surrounding double quotes. Use [ ] for identifying the characters in a substring of a given string as follows:  &lt;br /&gt;
S = “ACSL WDTPD” (S has a length of 10 and D is at location 9)&lt;br /&gt;
&lt;br /&gt;
S[:3] = “ACS” (take the first 3 characters starting on the left) &lt;br /&gt;
&lt;br /&gt;
S[4:] = “DTPD” (take the last 4 characters starting on the right) &lt;br /&gt;
&lt;br /&gt;
S[2:6] = “SL WD” (take the characters starting at location 2 and ending at location 6)&lt;br /&gt;
&lt;br /&gt;
S[0] = “A” (position 0 only). &lt;br /&gt;
&lt;br /&gt;
String concatenation is accomplished using the + symbol&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The questions in this topic will cover any of the above constructs in the Intermediate and Senior Division.  &lt;br /&gt;
In the Junior Division, Contest 1 will use branching, Contest 2 will use loops, Contest 3 will use arrays, and Contest 4&lt;br /&gt;
will use strings.&lt;br /&gt;
&lt;br /&gt;
= Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
After this program is executed, what is the value of B that is printed if the input values are 50 and 10?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
input H, R&lt;br /&gt;
B = 0&lt;br /&gt;
if H&amp;gt;48 then&lt;br /&gt;
    B = B + (H - 48) * 2 * R&lt;br /&gt;
    H = 48&lt;br /&gt;
end if&lt;br /&gt;
if H&amp;gt;40 then&lt;br /&gt;
   B = B + (H - 40) * (3/2) * R&lt;br /&gt;
   H = 40&lt;br /&gt;
end if&lt;br /&gt;
B = B + H * R&lt;br /&gt;
output B&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This program computes an employee’s weekly salary, given the hourly rate (R) and the number of hours worked in the week (H).  The employee is paid an hourly rate for the number of hours worked, up to 40, time and a half for the overtime hours, up to 48 hours, and double for all hours over 48.  The table monitors variables B and H:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! | B || H&lt;br /&gt;
|-&lt;br /&gt;
| | 0 || 50&lt;br /&gt;
|-&lt;br /&gt;
| | 40 || 48&lt;br /&gt;
|-&lt;br /&gt;
| | 160 || 40&lt;br /&gt;
|-&lt;br /&gt;
| | 560 || 40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the final value of B is 2*2*10 + 8*3/2*10 + 40*10 = 40 + 120 + 400 = 560.&lt;br /&gt;
&lt;br /&gt;
== Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of NUM?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A = “BANANAS”&lt;br /&gt;
NUM = 0: T = “”&lt;br /&gt;
for J = len(A) - 1 to 0 step –1&lt;br /&gt;
     T = T + A[j]&lt;br /&gt;
next &lt;br /&gt;
for J = 0 to len(A) - 1&lt;br /&gt;
    if A[J] == T[J] then NUM = NUM + 1&lt;br /&gt;
next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The program first stores the reverse of variable A into variable T and then counts the number of letters that are in the same position in both strings.&lt;br /&gt;
Variable NUM is incremented each time a character at position x of A is the same as the character in position x of string T. There are 5 such positions: 1, 2, 3, 4, and 5.&lt;br /&gt;
&lt;br /&gt;
== Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of C(4)?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A(0) = 12: A(1) = 41: A(2) = 52&lt;br /&gt;
A(3) = 57: A(4) = 77: A(5) = -100&lt;br /&gt;
B(0) = 17: B(1) = 34: B(2) = 81&lt;br /&gt;
j = 0: k = 0: n = 0&lt;br /&gt;
while A(k) &amp;gt; 0&lt;br /&gt;
  while B(k) &amp;lt;= A(j)&lt;br /&gt;
    C(n) = B(k)&lt;br /&gt;
    n = n + 1&lt;br /&gt;
    k = k + 1&lt;br /&gt;
  end while&lt;br /&gt;
  C(n) = A(j)&lt;br /&gt;
  n = n + 1&lt;br /&gt;
  j = j + 1&lt;br /&gt;
end while&lt;br /&gt;
C(n) = B(k)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following table traces the variables through the execution of the program. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!j&lt;br /&gt;
!k&lt;br /&gt;
!n&lt;br /&gt;
!A(j)&lt;br /&gt;
!B(k)&lt;br /&gt;
!C(n)&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0  || 0  || 12 || 17 || 12&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 41 || 17 || 17&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 2 || 41 || 34 || 34&lt;br /&gt;
|-&lt;br /&gt;
|1 || 2 || 3 || 41 || 81 || 41&lt;br /&gt;
|-&lt;br /&gt;
|2 || 2 || 4 || 52 || 81 || 52&lt;br /&gt;
|-&lt;br /&gt;
|3 || 2 || 5 || 57 || 81 || 57&lt;br /&gt;
|-&lt;br /&gt;
|4 || 2 || 6 || 77 || 81 || 77&lt;br /&gt;
|-&lt;br /&gt;
|5 || 2 || 7 || -100 || 81 || 81&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thus, the value of C(4) is 52.  Note that this program merges two arrays in increasing order into one array until a negative number is input.&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IBlXLEWeHjc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IBlXLEWeHjc &amp;#039;&amp;#039;ACSL Math: What Does This Program Do?&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Graph_Theory&amp;diff=888</id>
		<title>Graph Theory</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Graph_Theory&amp;diff=888"/>
		<updated>2024-09-23T17:42:27Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Terminology */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many problems are naturally formulated in terms of points and connections between them.  For example, a computer network has PCs connected by cables, an airline map has cities connected by routes, and a school has rooms connected by hallways.  A graph is a mathematical object which models such situations.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;graph&amp;#039;&amp;#039; is a collection of vertices and edges.  An &amp;#039;&amp;#039;edge&amp;#039;&amp;#039; is a connection between two &amp;#039;&amp;#039;vertices&amp;#039;&amp;#039; (sometimes referred to as &amp;#039;&amp;#039;nodes&amp;#039;&amp;#039;).  One can draw a graph by marking points for the vertices and drawing lines connecting them for the edges, but the graph is defined independently of the visual representation.  For example, the following two drawings represent the same graph:&lt;br /&gt;
&lt;br /&gt;
::[[File:Graph fig1a.svg|150px]] &amp;lt;span style=&amp;quot;display:inline-block; width: 5em;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[File:Graph fig1b.svg|150px]]&lt;br /&gt;
&lt;br /&gt;
The precise way to represent this graph is to identify its set of vertices {A, B, C, D, E, F, G}, and its set of edges between these vertices {AB, AD, BD, CF, FG, GH, GE, HE}.&lt;br /&gt;
&lt;br /&gt;
== Terminology ==&lt;br /&gt;
&lt;br /&gt;
The edges of the above graph have no directions meaning that the edge from one vertex A to another vertex B is the same as from vertex B to vertex A. Such a graph is called an &amp;#039;&amp;#039;undirected graph&amp;#039;&amp;#039;. Similarly, a graph having a direction associated with each edge is known as a &amp;#039;&amp;#039;directed graph&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;path&amp;#039;&amp;#039; from vertex x to y in a graph is a list of vertices, in which successive vertices are connected by edges in the graph.  For example, FGHE is path from F to E in the graph above.  A &amp;#039;&amp;#039;simple path&amp;#039;&amp;#039; is a path with no vertex repeated.  For example, FGHEG is not a simple path.  &lt;br /&gt;
&lt;br /&gt;
A graph is &amp;#039;&amp;#039;connected&amp;#039;&amp;#039; if there is a path from every vertex to every other vertex in the graph.  Intuitively, if the vertices were physical objects and the edges were strings connecting them, a connected graph would stay in one piece if picked up by any vertex.  A graph which is not connected is made up of &amp;#039;&amp;#039;connected components&amp;#039;&amp;#039;.  For example, the graph above has two connected components: {A, B, D} and {C, E, F, G, H}.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;cycle&amp;#039;&amp;#039; is a path, which is simple except that the first and last vertex are the same (a path from a point back to itself).  For example, the path HEGH is a cycle in our example.  Vertices must be listed in the order that they are traveled to make the path; any of the vertices may be listed first.  Thus, HEGH and EHGE are different ways to identify the same cycle.  For clarity, we list the start / end vertex twice: once at the start of the cycle and once at the end.&lt;br /&gt;
&lt;br /&gt;
We’ll denote the number of vertices in a given graph by V and the number of edges by E. Graphs with all edges present are called &amp;#039;&amp;#039;complete graphs&amp;#039;&amp;#039;; graphs with relatively few edges present (say less than $V log(V)$) are called &amp;#039;&amp;#039;sparse&amp;#039;&amp;#039;; graphs with relatively few edges missing are called &amp;#039;&amp;#039;dense.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== Directed Graphs ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Directed graphs&amp;#039;&amp;#039; are graphs which have a direction associated with each edge.  An edge xy in a directed graph can be used in a path that goes from x to y but not necessarily from y to x.  For example, a directed graph similar to our example graph is drawn below:&lt;br /&gt;
&lt;br /&gt;
[[File:Graph fig1a directed.svg|150px]]&lt;br /&gt;
&lt;br /&gt;
This graph is defined as the set of vertices V = {A,B,C,D,E,F,G,H} and the set of edges {AB,AD,DA,DB,EG,GE,HG,HE,GF,CF,FC}.  There is one directed path from G to C (namely, GFC); however, there are no directed paths from C to G.  Note that a few of the edges have arrows on both ends, such as the edge between A and D.  These dual arrows indicate that there is an edge in each direction, which essentially makes an undirected edge.  An &amp;#039;&amp;#039;undirected graph&amp;#039;&amp;#039; can be thought of as a directed graph with all edges occurring in pairs in this way.  A directed graph with no cycles is called a &amp;#039;&amp;#039;dag&amp;#039;&amp;#039; (directed acyclic graph).&lt;br /&gt;
&lt;br /&gt;
== Trees &amp;amp; Forests ==&lt;br /&gt;
&lt;br /&gt;
A graph with no cycles is called a &amp;#039;&amp;#039;tree&amp;#039;&amp;#039;.  There is only one path between any two nodes in a tree.  A tree with $N$ vertices contains exactly $N-1$ edges.&lt;br /&gt;
&lt;br /&gt;
[[File:forest.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The two graphs shown above are trees because neither has any cycles and all vertices are connected. The graph &lt;br /&gt;
on the left has 4 vertices and 3 edges; the graph on the right has 8 vertices and 7 edges. Note that in both cases, because they &lt;br /&gt;
are trees,  &lt;br /&gt;
the number of edges is one less than the number of vertices. &lt;br /&gt;
&lt;br /&gt;
A group of disconnected trees is called a &amp;#039;&amp;#039;forest&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;weighted graph&amp;#039;&amp;#039; is a graph that has a weight (also referred to as a cost) associated with each edge. &lt;br /&gt;
For example, in a graph &lt;br /&gt;
used by airlines where cities are vertices and edges are cities with direct flights connecting them,&lt;br /&gt;
the weight for each edge might be the distance between the cities. &lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;spanning tree&amp;#039;&amp;#039; of a graph is a subgraph that contains all the vertices and forms a tree.  &lt;br /&gt;
A &amp;#039;&amp;#039;minimal spanning tree&amp;#039;&amp;#039;&lt;br /&gt;
can be found for weighted graphs&lt;br /&gt;
in order to minimize the cost across an entire network.&lt;br /&gt;
&lt;br /&gt;
== Adjacency Matrices ==&lt;br /&gt;
&lt;br /&gt;
It is frequently convenient to represent a graph by a matrix known as an &amp;#039;&amp;#039;adjacency matrix.&amp;#039;&amp;#039;  Consider&lt;br /&gt;
the following directed graph:&lt;br /&gt;
&lt;br /&gt;
[[File:DirectedGraph.png|200px]]&lt;br /&gt;
&lt;br /&gt;
To draw the adjacency matrix, we create an $N$ by $N$ grid and label the rows and columns for each vertex (diagram at the left). Then, place a 1 for each edge in the cell whose row and column correspond to the&lt;br /&gt;
starting and ending vertices of the edge (diagram in the middle). Finally, place  &lt;br /&gt;
a 0 in all other cells (diagram at the right).  &lt;br /&gt;
&lt;br /&gt;
[[File:AdjMatrix.png|600px]]&lt;br /&gt;
&lt;br /&gt;
By construction, cell $(i,j)$ in the matrix with a value of 1 indicates a direct path from vertex $i$ to vertex $j$. &lt;br /&gt;
If we square the &lt;br /&gt;
matrix, the value in cell $(i,j)$ indicates the number of paths of length 2 from vertex $i$ to vertex $j$.&lt;br /&gt;
&lt;br /&gt;
[[File:AdjMatrix2.png|250px]]&lt;br /&gt;
&lt;br /&gt;
For example, the $M^2$ says that there 2 paths of length 2 from A to C (A → B → C and A → D → C).  This also says that there is exactly 1 path of length 2 from A to D (A → B → D), exactly 1 path of length 2 from B to B (B → C → B), and so on.&lt;br /&gt;
&lt;br /&gt;
In general, if we raise $M$ to the &amp;#039;&amp;#039;pth&amp;#039;&amp;#039; power, the resulting matrix indicates which paths of length $p$ exist in the graph. &lt;br /&gt;
The value in $M^p(i,j)$ is the number of paths from vertex $i$ to vertex $j$.&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Find the number of different cycles contained in the directed graph with vertices {A, B, C, D, E} and edges {AB, BA, BC, CD, DC, DB, DE}.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The graph is as follows:&lt;br /&gt;
&lt;br /&gt;
::[[File:graph sample1.svg|196px]]&lt;br /&gt;
&lt;br /&gt;
By inspection, the cycles are: ABA, BCDB, and CDC.  Thus, there are 3 cycles in the graph.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Given the directed graph below, how many more paths of length 3 would exist if edges AE and EA were added?&lt;br /&gt;
&lt;br /&gt;
[[File:graph_s1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
By using adjacency matrices, the current one is&lt;br /&gt;
&lt;br /&gt;
[[File:matrix1_s2.png]]&lt;br /&gt;
&lt;br /&gt;
After adding edges AE and EA, the matrices are:&lt;br /&gt;
&lt;br /&gt;
[[File:matrix2_s2.png]]&lt;br /&gt;
&lt;br /&gt;
There are 6 more paths of length 2 since 16 – 10 = 6.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2===&lt;br /&gt;
&lt;br /&gt;
In the following directed graph, find the total number of different paths from vertex A to vertex C of length 2 or 4.&lt;br /&gt;
&lt;br /&gt;
::[[File:graph sample3.svg|128px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Let matrix $M$ represent the graph.  Recall that the number of paths from vertex $i$ to vertex $j$ of length $p$ equals $M^p[i,j]$.  The values of $M$, $M^2$ and $M^4$ are:&lt;br /&gt;
&lt;br /&gt;
[[File:matrix_s3.png]]&lt;br /&gt;
&lt;br /&gt;
There is 1 path of length 2 from A to C (cell [1,3] in $M^2$).  By inspection, the only path of length 2 is A → A → C.&lt;br /&gt;
&lt;br /&gt;
There are 3 paths of length 4 (cell [1,3] in $M^4$) and they are A → A → A → A → C, A → A → C → A → C, A → C → A → A → C.&lt;br /&gt;
&lt;br /&gt;
=== Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
Given the adjacency matrix, draw the directed graph.&lt;br /&gt;
&lt;br /&gt;
[[File:matrix_s4.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
There must be exactly 4 vertices:  V = {A, B, C, D}. There must be be exactly 7 edges: E = {AB, AD, BA, BD, CA, DB, DC}.  Here are two valid drawings of the graph:&lt;br /&gt;
&lt;br /&gt;
: [[File:Graph sample4soln-a.svg|128px]] &amp;lt;span style=&amp;quot;display:inline-block; width: 5em;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[File:Graph sample4soln-d.svg|128px]]&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
===ACSL Videos===&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/pWCuRRqBGvw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/pWCuRRqBGvw &amp;#039;&amp;#039;ACSL Math: Graph Theory&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/H96Lo2q_FSk&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/H96Lo2q_FSk &amp;#039;&amp;#039;ACSL - Graph Theory Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Shows the solution to the ACSL problem: &amp;#039;&amp;#039;&amp;#039;Draw the directed graph with vertices A, B, C, D, E and the directed edges AB, BC, AD, BC, DC, ED, and EA.&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/y1fdIb_oNG0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/y1fdIb_oNG0 &amp;#039;&amp;#039;ACSL Graph Theory Worksheet 3&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Shows the solution to an ACSL problem asking to find how many paths of a specific length there are in a specific directed graph.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/vtTCRMGB0K8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/vtTCRMGB0K8 &amp;#039;&amp;#039;Graph Theory ACSL Example Problem&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Shows the solution to an ACSL problem asking to find how many different cycles there are from a specific vertex in a specific directed graph.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/ivhOH6crQ1w&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/ivhOH6crQ1w &amp;#039;&amp;#039;ACSL Test Prep - Graph Theory&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Mrs. Goopta&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A talked-over presentation discussing graph theory as needed for the American Computer Science League and its tests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Videos===&lt;br /&gt;
&lt;br /&gt;
There are dozens of YouTube videos that provide an introduction to graph theory. The following are a couple that we found particularly well done.  Be aware that the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt; https://youtu.be/gXgEDyodOJU&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/gXgEDyodOJU &amp;#039;&amp;#039;Data structures: Introduction to Graphs&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;(mycodeschool)&amp;#039;&amp;#039;&amp;#039;]&lt;br /&gt;
&lt;br /&gt;
A nice introduction to the fundamental concepts of graphs. &lt;br /&gt;
 &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=887</id>
		<title>What Does This Program Do?</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=887"/>
		<updated>2024-09-12T18:41:03Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Description of the ACSL Pseudo-code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Frequently, one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, and documentation is, unfortunately,&lt;br /&gt;
not always available or sufficient, it is essential to be able to read and understand an arbitrary program.  &lt;br /&gt;
&lt;br /&gt;
This category presents a program and asks the student to determine that the program does. The programs are written using a pseudocode that&lt;br /&gt;
should be readily understandable by all programmers familiar with a high-level programming language, such as Python, Java, or C.&lt;br /&gt;
&lt;br /&gt;
= Description of the ACSL Pseudo-code =&lt;br /&gt;
&lt;br /&gt;
We will use the following constructs in writing this code for this topic in ACSL:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Construct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Code Segment&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|Operators&lt;br /&gt;
|! (not) , ^ or ↑(exponent), *, / (real division), % (modulus), +, -, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, !=, ==, &amp;amp;&amp;amp; (and), &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt; (or) in that order of precedence&lt;br /&gt;
|-&lt;br /&gt;
|Functions&lt;br /&gt;
|abs(x) - absolute value, sqrt(x) - square root, int(x) - greatest integer &amp;lt;= x&lt;br /&gt;
|-&lt;br /&gt;
|Variables&lt;br /&gt;
|Start with a letter, only letters and digits&lt;br /&gt;
|-&lt;br /&gt;
|Sequential statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|INPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|variable = expression (assignment)&lt;br /&gt;
|-&lt;br /&gt;
|OUTPUT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Decision statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|IF boolean expression THEN&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|ELSE   (optional)&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END IF&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Indefinite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|WHILE Boolean expression&lt;br /&gt;
|-&lt;br /&gt;
|     Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END WHILE&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Definite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|FOR variable = start TO end STEP increment&lt;br /&gt;
|-&lt;br /&gt;
|    Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|NEXT&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Arrays:&lt;br /&gt;
|1 dimensional  arrays use a single subscript such as A(5).  2 dimensional arrays use (row, col) order such as A(2,3).  Arrays can start at location 0 for 1 dimensional arrays and location (0,0) for 2 dimensional arrays.  Most ACSL past problems start with either A(1) or A(1,1).  The size of the array will usually be specified in the problem statement.&lt;br /&gt;
|-&lt;br /&gt;
|Strings:&lt;br /&gt;
|Strings can contain 0 or more characters and the indexed position starts with 0 at the first character.  An empty string has a length of 0.  Errors occur if accessing a character that is in a negative position or equal to the length of the string or larger.  The len(A) function will find the length of the string which is the total number of characters.  Strings are identified with surrounding double quotes. Use [ ] for identifying the characters in a substring of a given string as follows:  &lt;br /&gt;
S = “ACSL WDTPD” (S has a length of 10 and D is at location 9)&lt;br /&gt;
&lt;br /&gt;
S[:3] = “ACS” (take the first 3 characters starting on the left) &lt;br /&gt;
&lt;br /&gt;
S[4:] = “DTPD” (take the last 4 characters starting on the right) &lt;br /&gt;
&lt;br /&gt;
S[2:6] = “SL WD” (take the characters starting at location 2 and ending at location 6)&lt;br /&gt;
&lt;br /&gt;
S[0] = “A” (position 0 only). &lt;br /&gt;
&lt;br /&gt;
String concatenation is accomplished using the + symbol&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The questions in this topic will cover any of the above constructs in the Intermediate and Senior Division.  &lt;br /&gt;
In the Junior Division, Contest 1 will use branching, Contest 2 will use loops, Contest 3 will use arrays, and Contest 4&lt;br /&gt;
will use strings.&lt;br /&gt;
&lt;br /&gt;
= Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
After this program is executed, what is the value of B that is printed if the input values are 50 and 10?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
input H, R&lt;br /&gt;
B = 0&lt;br /&gt;
if H&amp;gt;48 then&lt;br /&gt;
    B = B + (H - 48) * 2 * R&lt;br /&gt;
    H = 48&lt;br /&gt;
end if&lt;br /&gt;
if H&amp;gt;40 then&lt;br /&gt;
   B = B + (H - 40) * (3/2) * R&lt;br /&gt;
   H = 40&lt;br /&gt;
end if&lt;br /&gt;
B = B + H * R&lt;br /&gt;
output B&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This program computes an employee’s weekly salary, given the hourly rate (R) and the number of hours worked in the week (H).  The employee is paid an hourly rate for the number of hours worked, up to 40, time and a half for the overtime hours, up to 48 hours, and double for all hours over 48.  The table monitors variables B and H:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! | B || H&lt;br /&gt;
|-&lt;br /&gt;
| | 0 || 50&lt;br /&gt;
|-&lt;br /&gt;
| | 40 || 48&lt;br /&gt;
|-&lt;br /&gt;
| | 160 || 40&lt;br /&gt;
|-&lt;br /&gt;
| | 560 || 40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the final value of B is 2*2*10 + 8*3/2*10 + 40*10 = 40 + 120 + 400 = 560.&lt;br /&gt;
&lt;br /&gt;
== Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of NUM?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A = “BANANAS”&lt;br /&gt;
NUM = 0: T = “”&lt;br /&gt;
for J = len(A) - 1 to 0 step –1&lt;br /&gt;
     T = T + A[j]&lt;br /&gt;
next &lt;br /&gt;
for J = 0 to len(A) - 1&lt;br /&gt;
    if A[J] == T[J] then NUM = NUM + 1&lt;br /&gt;
next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The program first stores the reverse of variable A into variable T and then counts the number of letters that are in the same position in both strings.&lt;br /&gt;
Variable NUM is incremented each time a character at position x of A is the same as the character in position x of string T. There are 5 such positions: 1, 2, 3, 4, and 5.&lt;br /&gt;
&lt;br /&gt;
== Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of C[4]?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A(0) = 12: A(1) = 41: A(2) = 52&lt;br /&gt;
A(3) = 57: A(4) = 77: A(5) = -100&lt;br /&gt;
B(0) = 17: B(1) = 34: B(20 = 81&lt;br /&gt;
J = 0: K = 0: N = 0&lt;br /&gt;
while A(J) &amp;gt; 0&lt;br /&gt;
  while B(K) &amp;lt;= A(J)&lt;br /&gt;
    C(N) = B(K)&lt;br /&gt;
    N = N + 1&lt;br /&gt;
    k = k + 1&lt;br /&gt;
  end while&lt;br /&gt;
  C(N) = A(J): N = N + 1: J = J + 1&lt;br /&gt;
end while&lt;br /&gt;
C(N) = B(K)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following table traces the variables through the execution of the program. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!J&lt;br /&gt;
!K&lt;br /&gt;
!N&lt;br /&gt;
!A(J)&lt;br /&gt;
!B(K)&lt;br /&gt;
!C(N)&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0  || 0  || 12 || 17 || 12&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 41 || 17 || 17&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 2 || 41 || 34 || 34&lt;br /&gt;
|-&lt;br /&gt;
|1 || 2 || 3 || 41 || 81 || 41&lt;br /&gt;
|-&lt;br /&gt;
|2 || 2 || 4 || 52 || 81 || 52&lt;br /&gt;
|-&lt;br /&gt;
|3 || 2 || 5 || 57 || 81 || 57&lt;br /&gt;
|-&lt;br /&gt;
|4 || 2 || 6 || 77 || 81 || 77&lt;br /&gt;
|-&lt;br /&gt;
|5 || 2 || 7 || -100 || 81 || 81&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thus, the value of C(4) is 52.  Note that this program merges two arrays in increasing order into one array until a negative number is input.&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IBlXLEWeHjc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IBlXLEWeHjc &amp;#039;&amp;#039;ACSL Math: What Does This Program Do?&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=886</id>
		<title>What Does This Program Do?</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=886"/>
		<updated>2024-09-12T18:38:23Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Description of the ACSL Pseudo-code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Frequently, one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, and documentation is, unfortunately,&lt;br /&gt;
not always available or sufficient, it is essential to be able to read and understand an arbitrary program.  &lt;br /&gt;
&lt;br /&gt;
This category presents a program and asks the student to determine that the program does. The programs are written using a pseudocode that&lt;br /&gt;
should be readily understandable by all programmers familiar with a high-level programming language, such as Python, Java, or C.&lt;br /&gt;
&lt;br /&gt;
= Description of the ACSL Pseudo-code =&lt;br /&gt;
&lt;br /&gt;
We will use the following constructs in writing this code for this topic in ACSL:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Construct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Code Segment&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|Operators&lt;br /&gt;
|! (not) , ^ or ↑(exponent), *, / (real division), % (modulus), +, -, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, !=, ==, &amp;amp;&amp;amp; (and), &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt; (or) in that order of precedence&lt;br /&gt;
|-&lt;br /&gt;
|Functions&lt;br /&gt;
|abs(x) - absolute value, sqrt(x) - square root, int(x) - greatest integer &amp;lt;= x&lt;br /&gt;
|-&lt;br /&gt;
|Variables&lt;br /&gt;
|Start with a letter, only letters and digits&lt;br /&gt;
|-&lt;br /&gt;
|Sequential statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|INPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|variable = expression (assignment)&lt;br /&gt;
|-&lt;br /&gt;
|OUTPUT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Decision statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|IF boolean expression THEN&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|ELSE   (optional)&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END IF&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Indefinite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|WHILE Boolean expression&lt;br /&gt;
|-&lt;br /&gt;
|     Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END WHILE&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Definite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|FOR variable = start TO end STEP increment&lt;br /&gt;
|-&lt;br /&gt;
|    Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|NEXT&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Arrays:&lt;br /&gt;
|1 dimensional  arrays use a single subscript such as A(5).  2 dimensional arrays use (row, col) order such as A(2,3).  Arrays can start at location 0 for 1 dimensional arrays and location (0,0) for 2 dimensional arrays.  Most ACSL past problems start with either A(1) or A(1,1).  The size of the array will usually be specified in the problem statement.&lt;br /&gt;
|-&lt;br /&gt;
|Strings:&lt;br /&gt;
|Strings can contain 0 or more characters and the indexed position starts with 0 at the first character.  An empty string has a length of 0.  Errors occur if accessing a character that is in a negative position or equal to the length of the string or larger.  The len(A) function will find the length of the string which is the total number of characters.  Strings are identified with surrounding double quotes. Use [ ] for identifying the characters in a substring of a given string as follows:  &lt;br /&gt;
S = “ACSL WDTPD” (S has a length of 10 and D is at location 9)&lt;br /&gt;
&lt;br /&gt;
S[:3] = “ACS” (take the first 3 characters starting on the left) &lt;br /&gt;
&lt;br /&gt;
S[4:] = “DTPD” (take the last 4 characters starting on the right) &lt;br /&gt;
&lt;br /&gt;
S[2:6] = “SL WD” (take the characters starting at location 2 and ending at location 6)&lt;br /&gt;
&lt;br /&gt;
S[0] = “A” (position 0 only). &lt;br /&gt;
&lt;br /&gt;
String concatenation is accomplished using the + symbol&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The questions in this topic will cover any of the above constructs in the Intermediate and Senior Division.  In the Junior Division, Contest 1 will focus on branching. Contest 2 will focus on loops, arrays in Contest 3 and strings in Contest 4.&lt;br /&gt;
&lt;br /&gt;
= Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
After this program is executed, what is the value of B that is printed if the input values are 50 and 10?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
input H, R&lt;br /&gt;
B = 0&lt;br /&gt;
if H&amp;gt;48 then&lt;br /&gt;
    B = B + (H - 48) * 2 * R&lt;br /&gt;
    H = 48&lt;br /&gt;
end if&lt;br /&gt;
if H&amp;gt;40 then&lt;br /&gt;
   B = B + (H - 40) * (3/2) * R&lt;br /&gt;
   H = 40&lt;br /&gt;
end if&lt;br /&gt;
B = B + H * R&lt;br /&gt;
output B&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This program computes an employee’s weekly salary, given the hourly rate (R) and the number of hours worked in the week (H).  The employee is paid an hourly rate for the number of hours worked, up to 40, time and a half for the overtime hours, up to 48 hours, and double for all hours over 48.  The table monitors variables B and H:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! | B || H&lt;br /&gt;
|-&lt;br /&gt;
| | 0 || 50&lt;br /&gt;
|-&lt;br /&gt;
| | 40 || 48&lt;br /&gt;
|-&lt;br /&gt;
| | 160 || 40&lt;br /&gt;
|-&lt;br /&gt;
| | 560 || 40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the final value of B is 2*2*10 + 8*3/2*10 + 40*10 = 40 + 120 + 400 = 560.&lt;br /&gt;
&lt;br /&gt;
== Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of NUM?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A = “BANANAS”&lt;br /&gt;
NUM = 0: T = “”&lt;br /&gt;
for J = len(A) - 1 to 0 step –1&lt;br /&gt;
     T = T + A[j]&lt;br /&gt;
next &lt;br /&gt;
for J = 0 to len(A) - 1&lt;br /&gt;
    if A[J] == T[J] then NUM = NUM + 1&lt;br /&gt;
next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The program first stores the reverse of variable A into variable T and then counts the number of letters that are in the same position in both strings.&lt;br /&gt;
Variable NUM is incremented each time a character at position x of A is the same as the character in position x of string T. There are 5 such positions: 1, 2, 3, 4, and 5.&lt;br /&gt;
&lt;br /&gt;
== Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of C[4]?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A(0) = 12: A(1) = 41: A(2) = 52&lt;br /&gt;
A(3) = 57: A(4) = 77: A(5) = -100&lt;br /&gt;
B(0) = 17: B(1) = 34: B(20 = 81&lt;br /&gt;
J = 0: K = 0: N = 0&lt;br /&gt;
while A(J) &amp;gt; 0&lt;br /&gt;
  while B(K) &amp;lt;= A(J)&lt;br /&gt;
    C(N) = B(K)&lt;br /&gt;
    N = N + 1&lt;br /&gt;
    k = k + 1&lt;br /&gt;
  end while&lt;br /&gt;
  C(N) = A(J): N = N + 1: J = J + 1&lt;br /&gt;
end while&lt;br /&gt;
C(N) = B(K)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following table traces the variables through the execution of the program. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!J&lt;br /&gt;
!K&lt;br /&gt;
!N&lt;br /&gt;
!A(J)&lt;br /&gt;
!B(K)&lt;br /&gt;
!C(N)&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0  || 0  || 12 || 17 || 12&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 41 || 17 || 17&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 2 || 41 || 34 || 34&lt;br /&gt;
|-&lt;br /&gt;
|1 || 2 || 3 || 41 || 81 || 41&lt;br /&gt;
|-&lt;br /&gt;
|2 || 2 || 4 || 52 || 81 || 52&lt;br /&gt;
|-&lt;br /&gt;
|3 || 2 || 5 || 57 || 81 || 57&lt;br /&gt;
|-&lt;br /&gt;
|4 || 2 || 6 || 77 || 81 || 77&lt;br /&gt;
|-&lt;br /&gt;
|5 || 2 || 7 || -100 || 81 || 81&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thus, the value of C(4) is 52.  Note that this program merges two arrays in increasing order into one array until a negative number is input.&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IBlXLEWeHjc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IBlXLEWeHjc &amp;#039;&amp;#039;ACSL Math: What Does This Program Do?&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=885</id>
		<title>What Does This Program Do?</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=885"/>
		<updated>2024-09-12T18:36:16Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Description of the ACSL Pseudo-code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Frequently, one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, and documentation is, unfortunately,&lt;br /&gt;
not always available or sufficient, it is essential to be able to read and understand an arbitrary program.  &lt;br /&gt;
&lt;br /&gt;
This category presents a program and asks the student to determine that the program does. The programs are written using a pseudocode that&lt;br /&gt;
should be readily understandable by all programmers familiar with a high-level programming language, such as Python, Java, or C.&lt;br /&gt;
&lt;br /&gt;
= Description of the ACSL Pseudo-code =&lt;br /&gt;
&lt;br /&gt;
We will use the following constructs in writing this code for this topic in ACSL:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Construct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Code Segment&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|Operators&lt;br /&gt;
|! (not) , ^ or ↑(exponent), *, / (real division), % (modulus), +, -, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, !=, ==, &amp;amp;&amp;amp; (and), &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt; (or) in that order of precedence&lt;br /&gt;
|-&lt;br /&gt;
|Functions&lt;br /&gt;
|abs(x) - absolute value, sqrt(x) - square root, int(x) - greatest integer &amp;lt;= x&lt;br /&gt;
|-&lt;br /&gt;
|Variables&lt;br /&gt;
|Start with a letter, only letters and digits&lt;br /&gt;
|-&lt;br /&gt;
|Sequential statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|INPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|variable = expression (assignment)&lt;br /&gt;
|-&lt;br /&gt;
|OUTPUT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Decision statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|IF boolean expression THEN&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|ELSE   (optional)&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END IF&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Indefinite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|WHILE Boolean expression&lt;br /&gt;
|-&lt;br /&gt;
|     Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END WHILE&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Definite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|FOR variable = start TO end STEP increment&lt;br /&gt;
|-&lt;br /&gt;
|    Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|NEXT&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Arrays:&lt;br /&gt;
|1 dimensional  arrays use a single subscript such as A(5).  2 dimensional arrays use (row, col) order such as A(2,3).  Arrays can start at location 0 for 1 dimensional arrays and location (0,0) for 2 dimensional arrays.  Most ACSL past problems start with either A(1) or A(1,1).  The size of the array will usually be specified in the problem statement.&lt;br /&gt;
|-&lt;br /&gt;
|Strings:&lt;br /&gt;
|Strings can contain 0 or more characters and the indexed position starts with 0 at the first character.  An empty string has a length of 0.  Errors occur if accessing a character that is in a negative position or equal to the length of the string or larger.  The len(A) function will find the length of the string which is the total number of characters.  Strings are identified with surrounding double quotes. Use [ ] for identifying the characters in a substring of a given string as follows:  &lt;br /&gt;
S = “ACSL WDTPD” (S has a length of 10 and D is at location 9)&lt;br /&gt;
&lt;br /&gt;
S[:3] = “ACS” (take the first 3 characters starting on the left) &lt;br /&gt;
&lt;br /&gt;
S[4:] = “DTPD” (take the last 4 characters starting on the right) &lt;br /&gt;
&lt;br /&gt;
S[2:6] = “SL WD” (take the characters starting at location 2 and ending at location 6)&lt;br /&gt;
&lt;br /&gt;
S[0] = “A” (position 0 only). &lt;br /&gt;
&lt;br /&gt;
String concatenation is accomplished using the + symbol&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The questions in this topic will cover any of the above constructs in the Intermediate and Senior Division.  In the Junior Division, loops will not be included in Contest 1; loops will be used in Contest 2; arrays in Contest 3; and strings in Contest 4.&lt;br /&gt;
&lt;br /&gt;
= Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
After this program is executed, what is the value of B that is printed if the input values are 50 and 10?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
input H, R&lt;br /&gt;
B = 0&lt;br /&gt;
if H&amp;gt;48 then&lt;br /&gt;
    B = B + (H - 48) * 2 * R&lt;br /&gt;
    H = 48&lt;br /&gt;
end if&lt;br /&gt;
if H&amp;gt;40 then&lt;br /&gt;
   B = B + (H - 40) * (3/2) * R&lt;br /&gt;
   H = 40&lt;br /&gt;
end if&lt;br /&gt;
B = B + H * R&lt;br /&gt;
output B&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This program computes an employee’s weekly salary, given the hourly rate (R) and the number of hours worked in the week (H).  The employee is paid an hourly rate for the number of hours worked, up to 40, time and a half for the overtime hours, up to 48 hours, and double for all hours over 48.  The table monitors variables B and H:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! | B || H&lt;br /&gt;
|-&lt;br /&gt;
| | 0 || 50&lt;br /&gt;
|-&lt;br /&gt;
| | 40 || 48&lt;br /&gt;
|-&lt;br /&gt;
| | 160 || 40&lt;br /&gt;
|-&lt;br /&gt;
| | 560 || 40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the final value of B is 2*2*10 + 8*3/2*10 + 40*10 = 40 + 120 + 400 = 560.&lt;br /&gt;
&lt;br /&gt;
== Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of NUM?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A = “BANANAS”&lt;br /&gt;
NUM = 0: T = “”&lt;br /&gt;
for J = len(A) - 1 to 0 step –1&lt;br /&gt;
     T = T + A[j]&lt;br /&gt;
next &lt;br /&gt;
for J = 0 to len(A) - 1&lt;br /&gt;
    if A[J] == T[J] then NUM = NUM + 1&lt;br /&gt;
next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The program first stores the reverse of variable A into variable T and then counts the number of letters that are in the same position in both strings.&lt;br /&gt;
Variable NUM is incremented each time a character at position x of A is the same as the character in position x of string T. There are 5 such positions: 1, 2, 3, 4, and 5.&lt;br /&gt;
&lt;br /&gt;
== Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of C[4]?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A(0) = 12: A(1) = 41: A(2) = 52&lt;br /&gt;
A(3) = 57: A(4) = 77: A(5) = -100&lt;br /&gt;
B(0) = 17: B(1) = 34: B(20 = 81&lt;br /&gt;
J = 0: K = 0: N = 0&lt;br /&gt;
while A(J) &amp;gt; 0&lt;br /&gt;
  while B(K) &amp;lt;= A(J)&lt;br /&gt;
    C(N) = B(K)&lt;br /&gt;
    N = N + 1&lt;br /&gt;
    k = k + 1&lt;br /&gt;
  end while&lt;br /&gt;
  C(N) = A(J): N = N + 1: J = J + 1&lt;br /&gt;
end while&lt;br /&gt;
C(N) = B(K)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following table traces the variables through the execution of the program. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!J&lt;br /&gt;
!K&lt;br /&gt;
!N&lt;br /&gt;
!A(J)&lt;br /&gt;
!B(K)&lt;br /&gt;
!C(N)&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0  || 0  || 12 || 17 || 12&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 41 || 17 || 17&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 2 || 41 || 34 || 34&lt;br /&gt;
|-&lt;br /&gt;
|1 || 2 || 3 || 41 || 81 || 41&lt;br /&gt;
|-&lt;br /&gt;
|2 || 2 || 4 || 52 || 81 || 52&lt;br /&gt;
|-&lt;br /&gt;
|3 || 2 || 5 || 57 || 81 || 57&lt;br /&gt;
|-&lt;br /&gt;
|4 || 2 || 6 || 77 || 81 || 77&lt;br /&gt;
|-&lt;br /&gt;
|5 || 2 || 7 || -100 || 81 || 81&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thus, the value of C(4) is 52.  Note that this program merges two arrays in increasing order into one array until a negative number is input.&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IBlXLEWeHjc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IBlXLEWeHjc &amp;#039;&amp;#039;ACSL Math: What Does This Program Do?&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=884</id>
		<title>What Does This Program Do?</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=884"/>
		<updated>2024-09-12T18:34:05Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Description of the ACSL Pseudo-code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Frequently, one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, and documentation is, unfortunately,&lt;br /&gt;
not always available or sufficient, it is essential to be able to read and understand an arbitrary program.  &lt;br /&gt;
&lt;br /&gt;
This category presents a program and asks the student to determine that the program does. The programs are written using a pseudocode that&lt;br /&gt;
should be readily understandable by all programmers familiar with a high-level programming language, such as Python, Java, or C.&lt;br /&gt;
&lt;br /&gt;
= Description of the ACSL Pseudo-code =&lt;br /&gt;
&lt;br /&gt;
We will use the following constructs in writing this code for this topic in ACSL:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Construct&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;Code Segment&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
|Operators&lt;br /&gt;
|! (not) , ^ or ↑(exponent), *, / (real division), % (modulus), +, -, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, !=, ==, &amp;amp;&amp;amp; (and), &amp;lt;math&amp;gt;||&amp;lt;/math&amp;gt; (or) in that order of precedence&lt;br /&gt;
|-&lt;br /&gt;
|Functions&lt;br /&gt;
|abs(x) - absolute value, sqrt(x) - square root, int(x) - greatest integer &amp;lt;= x&lt;br /&gt;
|-&lt;br /&gt;
|Variables&lt;br /&gt;
|Start with a letter, only letters and digits&lt;br /&gt;
|-&lt;br /&gt;
|Sequential statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|INPUT variable&lt;br /&gt;
|-&lt;br /&gt;
|variable = expression (assignment)&lt;br /&gt;
|-&lt;br /&gt;
|OUTPUT variable&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Decision statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|IF boolean expression THEN&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|ELSE   (optional)&lt;br /&gt;
|-&lt;br /&gt;
|Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END IF&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Indefinite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|WHILE Boolean expression&lt;br /&gt;
|-&lt;br /&gt;
|     Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|END WHILE&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Definite Loop statements&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|FOR variable = start TO end STEP increment&lt;br /&gt;
|-&lt;br /&gt;
|    Statement(s)&lt;br /&gt;
|-&lt;br /&gt;
|NEXT&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
|Arrays:&lt;br /&gt;
|1 dimensional  arrays use a single subscript such as A(5).  2 dimensional arrays use (row, col) order such as A(2,3).  Arrays can start at location 0 for 1 dimensional arrays and location (0,0) for 2 dimensional arrays.  Most ACSL past problems start with either A(1) or A(1,1).  The size of the array will usually be specified in the problem statement.&lt;br /&gt;
|-&lt;br /&gt;
|Strings:&lt;br /&gt;
|Strings can contain 0 or more characters and the indexed position starts with 0 at the first character.  An empty string has a length of 0.  Errors occur if accessing a character that is in a negative position or equal to the length of the string or larger.  The len(A) function will find the length of the string which is the total number of characters.  Strings are identified with surrounding double quotes. Use [ ] for identifying the characters in a substring of a given string as follows:  &lt;br /&gt;
S = “ACSL WDTPD” (S has a length of 10 and D is at location 9)&lt;br /&gt;
&lt;br /&gt;
S[:3] = “ACS” (take the first 3 characters starting on the left) &lt;br /&gt;
&lt;br /&gt;
S[4:] = “DTPD” (take the last 4 characters starting on the right) &lt;br /&gt;
&lt;br /&gt;
S[2:6] = “SL WD” (take the characters starting at location 2 and ending at location 6)&lt;br /&gt;
&lt;br /&gt;
S[0] = “A” (position 0 only). &lt;br /&gt;
&lt;br /&gt;
String concatenation is accomplished using the + symbol&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The questions in this topic will cover any of the above constructs in the Intermediate and Senior Division.  In the Junior Division, loops will not be included in Contest 1; loops will be used in Contest 2; arrays will be used in Contest 3; and strings will be included in Contest 4.&lt;br /&gt;
&lt;br /&gt;
= Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
After this program is executed, what is the value of B that is printed if the input values are 50 and 10?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
input H, R&lt;br /&gt;
B = 0&lt;br /&gt;
if H&amp;gt;48 then&lt;br /&gt;
    B = B + (H - 48) * 2 * R&lt;br /&gt;
    H = 48&lt;br /&gt;
end if&lt;br /&gt;
if H&amp;gt;40 then&lt;br /&gt;
   B = B + (H - 40) * (3/2) * R&lt;br /&gt;
   H = 40&lt;br /&gt;
end if&lt;br /&gt;
B = B + H * R&lt;br /&gt;
output B&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This program computes an employee’s weekly salary, given the hourly rate (R) and the number of hours worked in the week (H).  The employee is paid an hourly rate for the number of hours worked, up to 40, time and a half for the overtime hours, up to 48 hours, and double for all hours over 48.  The table monitors variables B and H:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! | B || H&lt;br /&gt;
|-&lt;br /&gt;
| | 0 || 50&lt;br /&gt;
|-&lt;br /&gt;
| | 40 || 48&lt;br /&gt;
|-&lt;br /&gt;
| | 160 || 40&lt;br /&gt;
|-&lt;br /&gt;
| | 560 || 40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the final value of B is 2*2*10 + 8*3/2*10 + 40*10 = 40 + 120 + 400 = 560.&lt;br /&gt;
&lt;br /&gt;
== Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of NUM?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A = “BANANAS”&lt;br /&gt;
NUM = 0: T = “”&lt;br /&gt;
for J = len(A) - 1 to 0 step –1&lt;br /&gt;
     T = T + A[j]&lt;br /&gt;
next &lt;br /&gt;
for J = 0 to len(A) - 1&lt;br /&gt;
    if A[J] == T[J] then NUM = NUM + 1&lt;br /&gt;
next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The program first stores the reverse of variable A into variable T and then counts the number of letters that are in the same position in both strings.&lt;br /&gt;
Variable NUM is incremented each time a character at position x of A is the same as the character in position x of string T. There are 5 such positions: 1, 2, 3, 4, and 5.&lt;br /&gt;
&lt;br /&gt;
== Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, what is the final value of C[4]?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
A(0) = 12: A(1) = 41: A(2) = 52&lt;br /&gt;
A(3) = 57: A(4) = 77: A(5) = -100&lt;br /&gt;
B(0) = 17: B(1) = 34: B(20 = 81&lt;br /&gt;
J = 0: K = 0: N = 0&lt;br /&gt;
while A(J) &amp;gt; 0&lt;br /&gt;
  while B(K) &amp;lt;= A(J)&lt;br /&gt;
    C(N) = B(K)&lt;br /&gt;
    N = N + 1&lt;br /&gt;
    k = k + 1&lt;br /&gt;
  end while&lt;br /&gt;
  C(N) = A(J): N = N + 1: J = J + 1&lt;br /&gt;
end while&lt;br /&gt;
C(N) = B(K)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The following table traces the variables through the execution of the program. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!J&lt;br /&gt;
!K&lt;br /&gt;
!N&lt;br /&gt;
!A(J)&lt;br /&gt;
!B(K)&lt;br /&gt;
!C(N)&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0  || 0  || 12 || 17 || 12&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 41 || 17 || 17&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 2 || 41 || 34 || 34&lt;br /&gt;
|-&lt;br /&gt;
|1 || 2 || 3 || 41 || 81 || 41&lt;br /&gt;
|-&lt;br /&gt;
|2 || 2 || 4 || 52 || 81 || 52&lt;br /&gt;
|-&lt;br /&gt;
|3 || 2 || 5 || 57 || 81 || 57&lt;br /&gt;
|-&lt;br /&gt;
|4 || 2 || 6 || 77 || 81 || 77&lt;br /&gt;
|-&lt;br /&gt;
|5 || 2 || 7 || -100 || 81 || 81&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Thus, the value of C(4) is 52.  Note that this program merges two arrays in increasing order into one array until a negative number is input.&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IBlXLEWeHjc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IBlXLEWeHjc &amp;#039;&amp;#039;ACSL Math: What Does This Program Do?&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Boolean_Algebra&amp;diff=883</id>
		<title>Boolean Algebra</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Boolean_Algebra&amp;diff=883"/>
		<updated>2024-05-24T23:22:33Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Operators */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;Boolean algebra&amp;#039;&amp;#039; is the branch of algebra in which the values of the variables and constants have exactly two values: &amp;#039;&amp;#039;true&amp;#039;&amp;#039; and &amp;#039;&amp;#039;false&amp;#039;&amp;#039;, usually denoted 1 and 0 respectively. &lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
&lt;br /&gt;
The basic operators in Boolean algebra are &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039;. The secondary operators are &amp;#039;&amp;#039;eXclusive OR&amp;#039;&amp;#039; (often called &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039;) and &amp;#039;&amp;#039;eXclusive NOR&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;XNOR&amp;#039;&amp;#039;&amp;#039;, sometimes called &amp;#039;&amp;#039;&amp;#039;equivalence&amp;#039;&amp;#039;&amp;#039;). They are secondary in the sense that they &lt;br /&gt;
can be composed from the basic operators.&lt;br /&gt;
&lt;br /&gt;
*The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of two values is true only whenever both values are true. It is written as $xy$ or $x \cdot y$. The values of  &amp;#039;&amp;#039;and&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x  y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of two values is true whenever either or both values are true. It is written as $x+y$. The values of  &amp;#039;&amp;#039;or&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x + y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; of  a value is its opposite; that is, the &amp;#039;&amp;#039;not&amp;#039;&amp;#039; of a true value is false whereas the &amp;#039;&amp;#039;not&amp;#039;&amp;#039; of a false value is true. It is written as $\overline{x}$ or $\neg{x}$. The values of  &amp;#039;&amp;#039;not&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ \overline{x}\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of two values is true whenever the values are different.  It uses the $\oplus$ operator, and can be built from the basic operators: $x \oplus y = x\ \overline{y}\ \ +\ \overline{x}\ \ y$ The values of  &amp;#039;&amp;#039;xor&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x \oplus y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 0&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
*The &amp;#039;&amp;#039;&amp;#039;XNOR&amp;#039;&amp;#039;&amp;#039; of two values is true whenever the values are the same. It is the &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; of the &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; function. It uses the $\odot$ operator: $x \odot y = \overline{x \oplus y}$. The &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039; can be built from basic operators: $x \odot y = x  y + \overline{x}  \overline{y}$ The values of  &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x \odot y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 0&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 1&lt;br /&gt;
|} &lt;br /&gt;
 &lt;br /&gt;
Just as algebra has basic rules for simplifying and evaluating expressions, so does Boolean algebra.&lt;br /&gt;
&lt;br /&gt;
== Why is Boolean Algebra Important for ACSL Students? ==&lt;br /&gt;
&lt;br /&gt;
Boolean algebra is important to programmers, computer scientists, and the general population. &lt;br /&gt;
&lt;br /&gt;
*For programmers, Boolean expressions are used for conditionals and loops. For example, the following snippet of code sums the even numbers that are not also multiples of 3, stopping when the sum hits 100:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
s = 0&lt;br /&gt;
x = 1&lt;br /&gt;
while (s &amp;lt; 100):&lt;br /&gt;
    if (x % 2 == 0) and (x % 3 != 0)&lt;br /&gt;
        then s = s + x&lt;br /&gt;
    x = x + 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Both the conditional statement &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;s &amp;lt; 100&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
and the Boolean expression with 2 conditional statements  &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(x % 2 == 0) and (x % 3 != 0)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
evaluate to &amp;#039;&amp;#039;true&amp;#039;&amp;#039; or &amp;#039;&amp;#039;false&amp;#039;&amp;#039;. &lt;br /&gt;
&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*For computer scientists, Boolean algebra is the basis for digital circuits that make up a computer&amp;#039;s hardware. The [[Digital Electronics]] category concerns a graphical representation of a circuit. That circuit is typically easiest to understand and evaluate by converting it to its Boolean algebra representation. &lt;br /&gt;
 &lt;br /&gt;
* The general population uses Boolean algebra, probably without knowing that they are doing so, when they enter search terms in Internet search engines. For example, the search expression &amp;#039;&amp;#039;jaguar speed -car&amp;#039;&amp;#039; is parsed by the search engine as the Boolean expression &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;&amp;quot;jaguar&amp;quot; and &amp;quot;car&amp;quot; and not &amp;quot;speed&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;; it returns pages about the speed of the jaguar animal, not the Jaguar car.&lt;br /&gt;
&lt;br /&gt;
==Laws==&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;law&amp;#039;&amp;#039;&amp;#039; of Boolean algebra is an identity such as &amp;lt;math&amp;gt;x + (y + z) = (x + y) + z&amp;lt;/math&amp;gt;&lt;br /&gt;
between two Boolean terms, where a &amp;#039;&amp;#039;&amp;#039;Boolean term&amp;#039;&amp;#039;&amp;#039; is defined as an expression built up from variables,  the constants 0 and 1, and operations &amp;#039;&amp;#039;and&amp;#039;&amp;#039;, &amp;#039;&amp;#039;or&amp;#039;&amp;#039;, &amp;#039;&amp;#039;not&amp;#039;&amp;#039;, &amp;#039;&amp;#039;xor&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
Like ordinary algebra, parentheses are used to group terms. When a &amp;#039;&amp;#039;not&amp;#039;&amp;#039; is represented with an overhead horizontal line, there is an implicit grouping of the terms under the line. That is, $x \cdot \overline{y + z}$ is evaluated as if it were written $x \cdot \overline{(y + z)}.$&lt;br /&gt;
&lt;br /&gt;
=== Order of Precedence ===&lt;br /&gt;
&lt;br /&gt;
The order of operator precedence is &amp;#039;&amp;#039;not&amp;#039;&amp;#039;; then &amp;#039;&amp;#039;and&amp;#039;&amp;#039;; then &amp;#039;&amp;#039;xor&amp;#039;&amp;#039; and &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039;; and finally &amp;#039;&amp;#039;or&amp;#039;&amp;#039;. Operators with the same level of precedence are evaluated from left-to-right. &lt;br /&gt;
 &lt;br /&gt;
=== Fundamental Identities ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Commutative Law – The order of application of two separate terms is not important. || $x+y = y+x$ || $x \cdot y = y \cdot x$ &lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Associative Law – Regrouping of the terms in an expression doesn&amp;#039;t change the value of the expression. ||$(x + y) + z$ = $x + (y + z)$ || $x \cdot (y \cdot z) = (x \cdot y) \cdot z$ &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Idempotent Law – A term that is &amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039;´ed or &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with itself is equal to that term. || $ x +x = x $ || $x \cdot x = x$&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Annihilator Law – A term that is &amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039;´ed with 1 is 1; a term &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with 0 is 0. || $x + 1 = 1$ || $ x \cdot 0 = 0 $ &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Identity Law – A term &amp;#039;&amp;#039;or&amp;#039;&amp;#039;´ed 0 or  &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with a 1 will always equal that term. || $x + 0 = x$  || $x \cdot 1 = x$&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Complement Law – A term &amp;#039;&amp;#039;or&amp;#039;&amp;#039;´ed with its complement equals 1 and a term &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with its complement equals 0. || $x + \overline{x} = 1 $ || $x \cdot \overline{x} = 0$&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Absorptive Law – Complex expressions can be reduced to a simpler ones by absorbing like terms. ||colspan=2|&lt;br /&gt;
$x+x  y = x$&lt;br /&gt;
&lt;br /&gt;
$ x +\overline{x}y = x + y $&lt;br /&gt;
&lt;br /&gt;
$x  (x+y) = x$&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Distributive Law – It&amp;#039;s OK to multiply or factor-out an expression.||colspan=2|&lt;br /&gt;
&lt;br /&gt;
$x \cdot (y + z) = xy + xz$&lt;br /&gt;
&lt;br /&gt;
$(x+y) \cdot (p + q) = xp + xq +yp + yq$&lt;br /&gt;
&lt;br /&gt;
$(x+y)(x+z)=x + yz $&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | DeMorgan&amp;#039;s Law – An &amp;#039;&amp;#039;or&amp;#039;&amp;#039; (&amp;#039;&amp;#039;and&amp;#039;&amp;#039;) expression that is negated is equal to the &amp;#039;&amp;#039;and&amp;#039;&amp;#039; (&amp;#039;&amp;#039;or&amp;#039;&amp;#039;) of the negation of each term.|| $\overline{x+y} = \overline{x} \cdot \overline{y}$||$\overline{x \cdot y} = \overline{x} + \overline{y}$&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Double Negation – A term that is inverted twice is equal to the original term.||colspan=2| $\overline{\overline{x}} = x $ &lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Relationship between XOR and XNOR|| colspan=2 | $ x\odot y = \overline{x\oplus y} = x \oplus \overline{y} =\overline{x} \oplus {y}$ &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
Problems in this category are typically of the form &amp;quot;Given a Boolean expression, simplify it as much as possible&amp;quot; or &amp;quot;Given a Boolean expression,&lt;br /&gt;
find the values of all possible inputs that make the expression &amp;#039;&amp;#039;true&amp;#039;&amp;#039;.&amp;quot;  Simplify means writing an equivalent expression using the fewest number of operators.&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: Simplify the Expression ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Simplify the following expression as much as possible:&lt;br /&gt;
$ \overline{ \overline{A(A+B)} + B\overline{A}}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The simplification proceeds as follows:&lt;br /&gt;
&lt;br /&gt;
:$\overline{ \overline{A(A+B)} + B\overline{A}}$&lt;br /&gt;
::{| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  &amp;lt;math&amp;gt;= \left(\overline{ \overline{A(A+B)}}\right) \cdot \left(\overline{ B\overline{A}}\right)&amp;lt;/math&amp;gt; ||&lt;br /&gt;
|  (DeMorgan&amp;#039;s Law)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;= \left(A(A+B)\right) \cdot \left( \overline{B}+\overline{\overline{A}}\right)&amp;lt;/math&amp;gt; ||&lt;br /&gt;
|  (Double Negation; DeMorgan&amp;#039;s Law)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;= A \cdot \left( \overline{B}+A\right)&amp;lt;/math&amp;gt; ||&lt;br /&gt;
|  (Absorption; Double Negation)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;=A&amp;lt;/math&amp;gt;  || &lt;br /&gt;
| (Absorption)&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Find Solutions ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Find all orderd pairs $(A,B)$ that make the following expression &amp;#039;&amp;#039;true&amp;#039;&amp;#039;:&lt;br /&gt;
$ \overline{ \overline{(A+B)} + \overline{A}B }$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
There are typically two approaches to solving this type of problem. One approach is to simplify the expression as much as possible, until&lt;br /&gt;
it&amp;#039;s obvious what the solutions are. The other approach is to create a truth table of all possible inputs, with columns for each subexpression.&lt;br /&gt;
&lt;br /&gt;
The simplification approach is as following:&lt;br /&gt;
:$ \overline{\overline{(A+B)} + \overline{A}B}$&lt;br /&gt;
::$= \overline{\overline{A+B}} \cdot \overline{\overline{A}B}$ &lt;br /&gt;
::$= (A+B) \cdot (\overline{\overline{A}}+\overline{B} ) $ &lt;br /&gt;
::$= (A+B) \cdot (A+\overline{B}) $ &lt;br /&gt;
::$= AA + A\overline{B} + BA + B\overline{B} $ &lt;br /&gt;
::$= A + A(\overline{B} + B) + 0 $ &lt;br /&gt;
::$= A + A(1)$ &lt;br /&gt;
::$= A + A$ &lt;br /&gt;
::$=A$&lt;br /&gt;
This means that all inputs are valid whenever $A$ is &amp;#039;&amp;#039;true&amp;#039;&amp;#039;: $(1,0)$ and $(1,1)$&lt;br /&gt;
&lt;br /&gt;
The truth table approach is as following. Each column is the result of a basic operation on two other columns. &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#1&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#2&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#3 &lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#4&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#5&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#6&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#7&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#8&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff&amp;quot;|&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff&amp;quot;|&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |OR of Col#1, Col#2&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |NOT of Col#3&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |NOT of Col#1&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |ADD of Col#1, Col#2&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |OR of Col#4, Col#6&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |NOT of Col#7 &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;A+B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A+B}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A}B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A+B} + \overline{A}B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{\overline{A+B} + \overline{A}B}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
!0&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
!0&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
!1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
!1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The rightmost column is the expression we are solving; it is &amp;#039;&amp;#039;true&amp;#039;&amp;#039; for the 3rd and 4th rows, where the inputs are $(1,0)$ and $(1,1)$.&lt;br /&gt;
&lt;br /&gt;
== Online Resources ==&lt;br /&gt;
&lt;br /&gt;
===Websites===&lt;br /&gt;
A great online tutorial on Boolean Algebra is part of [https://ryanstutorials.net/boolean-algebra-tutorial/ Ryan&amp;#039;s Tutorials]. There are many online Boolean Calculators.  This one gives Truth Tables [https://sheabunge.github.io/boolcalc/ calculator ]. This link that has ads also simplifies and uses ! for NOT [https://www.boolean-algebra.com/ calculator].&lt;br /&gt;
&lt;br /&gt;
===Videos===&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some previous problems. To access the YouTube page with the video, click on the title of the video in the icon. (You can also play the video directly by clicking on the arrow in the center of the image; however, you&amp;#039;ll &lt;br /&gt;
probably want to have a larger viewing of the video since it contains writing on a whiteboard.) Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/HJdhEjpVYsY&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/HJdhEjpVYsY &amp;#039;&amp;#039;ACSL Boolean Algebra Contest 2 Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Mr. Minich is an ACSL advisor. This video was one of two he created to help prepare his students for the ACSL Boolean algebra category. It shows solutions to 5 different problems that have&lt;br /&gt;
appeared in recent years. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/4io6xgz8Zwk&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/4io6xgz8Zwk &amp;#039;&amp;#039;ACSL Boolean Algebra Contest 2 Worksheet 2&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;) ]&lt;br /&gt;
&lt;br /&gt;
Mr. Minich is an ACSL advisor. This video was one of two he created to help prepare his students for the ACSL Boolean algebra category. It shows solutions to 5 different problems that have&lt;br /&gt;
appeared in recent years. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/6vI1mO1XOjQ&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/6vI1mO1XOjQ &amp;#039;&amp;#039;ACSL 3 13-14 #1 - AM&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Gordon Campbell&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video walks through the solution to finding all ordered triples that make the following&lt;br /&gt;
Boolean expression &amp;#039;&amp;#039;true&amp;#039;&amp;#039;:&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
(AB+\overline{C})(\overline{A}+BC)(A+\overline{B}+C)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
This problem appeared in 2013-2014 in the Senior Division, Contest #3.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/KRKTbAZYlLM&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/KRKTbAZYlLM &amp;#039;&amp;#039;ACSL 3 #1 14-15 - AM&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Gordon Campbell&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video walks through the simplification of the expression:&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
\overline{(\overline{A}+B)}(B+C)\overline{(A+\overline{C})}(A\overline{B}+BC)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
This problem appeared in 2014-2015 in the Senior Division, Contest #3.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jDnni-zm2g8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jDnni-zm2g8 &amp;#039;&amp;#039;A general tutorial on boolean algebra that can be used for American Computer Science League.&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Walks through the simplification of the following Boolean expression:&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
\overline{ (\overline{A + \overline{B}})(AB)} +&lt;br /&gt;
\overline{ (A+B)(\overline{\overline{A}B})}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=878</id>
		<title>Computer Number Systems</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=878"/>
		<updated>2022-07-04T21:23:50Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Video Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All digital computers, from supercomputers to your smartphone, are electronic devices and ultimately can do one thing: detect whether an electrical signal is on or off. That basic information, called a &amp;#039;&amp;#039;bit&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;bi&amp;#039;&amp;#039;&amp;#039;nary digi&amp;#039;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;#039;), has two values: a 1 (or &amp;#039;&amp;#039;true&amp;#039;&amp;#039;) when the signal is on, and a 0 (of &amp;#039;&amp;#039;false&amp;#039;&amp;#039;) when the signal is off. &lt;br /&gt;
&lt;br /&gt;
Larger values can be stored by a group of bits. For example, there are 4 different values stored by 2 bits (00, 01, 10, and 11), 8 values for 3 bits (000, 001, 010, 011, 100, 101, 110, and 111), 16 values for 4 bits (0000, 0001, ..., 1111), and so on. However, large numbers, using 0s and 1s only, are quite unwieldy for humans. For example, a computer would need 19 bits to store the numbers up to 500,000! We use of different number systems to work with large binary strings that represent numbers within computers.&lt;br /&gt;
&lt;br /&gt;
== Different Number Systems ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;number system&amp;#039;&amp;#039; is the way we name and represent numbers. The number system we use in our daily life is known as &amp;#039;&amp;#039;&amp;#039;decimal number system&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;base 10&amp;#039;&amp;#039;&amp;#039; because it is based on 10 different digits: 0, 1, 2, ..., 8, and 9. The base of number is written as subscript to a number. For example, the decimal number &amp;quot;twelve thousand three hundred and forty-five&amp;quot; is written as $12345_{10}$. Without a base or explicit context, it&amp;#039;s assumed that a number is in base 10. &lt;br /&gt;
&lt;br /&gt;
In computer science, apart from the decimal system, three additional number systems are commonly used: &amp;#039;&amp;#039;&amp;#039;binary&amp;#039;&amp;#039;&amp;#039; (base-2), &amp;#039;&amp;#039;&amp;#039;octal&amp;#039;&amp;#039;&amp;#039; (base-8), and &amp;#039;&amp;#039;&amp;#039;hexadecimal&amp;#039;&amp;#039;&amp;#039; or just &amp;#039;&amp;#039;&amp;#039;hex&amp;#039;&amp;#039;&amp;#039; (base-16). Binary numbers are important because that is how numbers are stored in the computer. Octal and hexadecimal are used to represent binary numbers in a user-friendly way. Each octal symbol represents 3 binary bits and each hex digit represents 4 binary bits. For example, the decimal number 53201, stored as in the computer as the binary number 10000001111000101100, is represented by the octal number 2017054, and the hex number 81E2C. The table below compares the number systems: &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Number System&lt;br /&gt;
!Base&lt;br /&gt;
!Digits Used&lt;br /&gt;
!Examples&lt;br /&gt;
|-&lt;br /&gt;
|Binary&lt;br /&gt;
|2&lt;br /&gt;
|0,1&lt;br /&gt;
|$10110_{2}$, $10110011_{2}$&lt;br /&gt;
|-&lt;br /&gt;
|Octal&lt;br /&gt;
|8&lt;br /&gt;
|0,1,2,3,4,5,6,7&lt;br /&gt;
|$75021_{8}$, $231_{8}$, $60012_{8}$&lt;br /&gt;
|-&lt;br /&gt;
|Decimal&lt;br /&gt;
|10&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9&lt;br /&gt;
|$97425_{10}$ or simply 97425&lt;br /&gt;
|-&lt;br /&gt;
|Hexadecimal&lt;br /&gt;
|16&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F&lt;br /&gt;
|$54A2DD0F_{16}$&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In general, $N$ bits have $2^N$ different values. The computers aboard the Apollo spacecraft had 8-bit words of memory. Each word of memory could store 256 different values, and the contents were displayed using 2 hex characters.&lt;br /&gt;
&lt;br /&gt;
The following table shows the first 20 numbers in decimal, binary, octal, and hexadecimal:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
!Decimal&lt;br /&gt;
!Binary&lt;br /&gt;
!Octal&lt;br /&gt;
!Hexadecimal&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0 &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1 &lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|10&lt;br /&gt;
|2&lt;br /&gt;
|2 &lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|11&lt;br /&gt;
|3&lt;br /&gt;
|3 &lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|100&lt;br /&gt;
|4&lt;br /&gt;
|4 &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|101&lt;br /&gt;
|5&lt;br /&gt;
|5 &lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|110&lt;br /&gt;
|6&lt;br /&gt;
|6 &lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|111&lt;br /&gt;
|7&lt;br /&gt;
|7 &lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|1000&lt;br /&gt;
|10&lt;br /&gt;
|8&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|1001&lt;br /&gt;
|11&lt;br /&gt;
|9&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|1010&lt;br /&gt;
|12&lt;br /&gt;
|A&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|1011&lt;br /&gt;
|13&lt;br /&gt;
|B&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|1100&lt;br /&gt;
|14&lt;br /&gt;
|C &lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|1101&lt;br /&gt;
|15&lt;br /&gt;
|D &lt;br /&gt;
|-&lt;br /&gt;
|14&lt;br /&gt;
|1110&lt;br /&gt;
|16&lt;br /&gt;
|E &lt;br /&gt;
|-&lt;br /&gt;
|15&lt;br /&gt;
|1111&lt;br /&gt;
|17&lt;br /&gt;
|F &lt;br /&gt;
|-&lt;br /&gt;
|16&lt;br /&gt;
|10000&lt;br /&gt;
|20&lt;br /&gt;
|10 &lt;br /&gt;
|-&lt;br /&gt;
|17&lt;br /&gt;
|10001&lt;br /&gt;
|21&lt;br /&gt;
|11&lt;br /&gt;
|-&lt;br /&gt;
|18&lt;br /&gt;
|10010&lt;br /&gt;
|22&lt;br /&gt;
|12&lt;br /&gt;
|-&lt;br /&gt;
|19&lt;br /&gt;
|10011&lt;br /&gt;
|23&lt;br /&gt;
|13&lt;br /&gt;
|-&lt;br /&gt;
|20&lt;br /&gt;
|10100&lt;br /&gt;
|24&lt;br /&gt;
|14&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Converting to Decimal ==&lt;br /&gt;
&lt;br /&gt;
As we learned in the first or second grade, the decimal value of a decimal number is simply sum of each digit multiplied by its place value:&lt;br /&gt;
&lt;br /&gt;
:$12345 = 1×10^{4}+ 2×10^{3}+ 3×10^{2}+ 4×10^{1}+ 5×10^{0} =   10000 + 2000+ 300 +40+5 = 12345$&lt;br /&gt;
&lt;br /&gt;
:$3079 = 3×10^{3}+ 0×10^{2}+ 7×10^{1}+ 9×10^{0} = 3000 + 70 + 9 = 3079$&lt;br /&gt;
&lt;br /&gt;
Analogously, the decimal value of a number in an arbitrary base is the sum of each digit multiplied by its place value.  Here are some examples of converting from one base into base 10:&lt;br /&gt;
&lt;br /&gt;
:$1101_{2}  = 1 × 2^3  + 1 × 2^2  + 0 × 2^1  + 1 × 2^0 = 8 + 4  + 0  + 1  = 13_{10}$ &lt;br /&gt;
&lt;br /&gt;
:$175_{8}   = 1 × 8^2  + 7 × 8^1  + 5 × 8^0 = 1 × 64 + 7 × 8 + 5 × 1 = 64 + 56 + 5 = 125_{10}$&lt;br /&gt;
&lt;br /&gt;
:$A5E_{16}  = 10 × 16^2 + 5 × 16^1 + 14 × 16^0 = 10 × 256 + 5 × 16 + 14 × 1 = 2560 + 80 + 14 = 2654_{10}$&lt;br /&gt;
&lt;br /&gt;
== Converting from Decimal ==&lt;br /&gt;
&lt;br /&gt;
The algorithm to convert a number from an arbitrary base requires finding how many times successive powers of the base go into the number, starting with the largest power of the base less than the starting number. For example, converting 3306 from base 10 to octal proceeds as follows:&lt;br /&gt;
&lt;br /&gt;
1) The largest power of 8 that is less than or equal to 3306 is 512 ($8^3$). Divide 3306 by 512:&lt;br /&gt;
:$3306 = 6*8^3 + 234$  &lt;br /&gt;
&lt;br /&gt;
2) The next power of 8 is 64 ($8^2$). Divide 234 by 64:&lt;br /&gt;
:$234 = 3 *8^2 + 42$&lt;br /&gt;
&lt;br /&gt;
3) The next smaller power of 8 is 8 ($8^1$). Divide 42 by 8:&lt;br /&gt;
:$42 = 5*8^1 + 2$&lt;br /&gt;
&lt;br /&gt;
4) Finally, the next smaller power of 8 is 1 ($8^0$). Divide 2 by 1:&lt;br /&gt;
:$2 = 2 * 8^0$&lt;br /&gt;
&lt;br /&gt;
The answer is $6352_8$.&lt;br /&gt;
&lt;br /&gt;
== Converting between Binary, Octal, and Hexadecimal == &lt;br /&gt;
&lt;br /&gt;
Converting from octal to binary is simple: replace each octal digit by its corresponding 3 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$375_{8} = \ \ 011\ \ \ 111\ \ \ 101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from hex to binary is also simple: replace each hex digit by its corresponding 4 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$FD_{16} = \ \ 1111\ \ \ 1101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from binary to either octal or hex is pretty simple as well: group the bits by 3s or 4s (starting at the right), and convert each group:&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 10\ 000\ 001\ 111\ 000\ 101 \ 100 = 2017054_8$&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 1000\ 0001\ 1110\ 0010\ 1100 = 81E2C_{16}$&lt;br /&gt;
&lt;br /&gt;
Converting between base 8 and 16 is easy by expressing the number in base 2 (easy to do!) and then converting that number from base 2 (another easy operation)! This is shown below in Sample Problem #1.&lt;br /&gt;
&lt;br /&gt;
== Using Hexadecimal Numbers to Represent Colors ==&lt;br /&gt;
&lt;br /&gt;
Computers use hexadecimal numbers to represent various colors in computer graphics because all computer screens use combinations of red, green, and blue light or RGB to represent thousands of different colors. Two digits are used for each so the hexadecimal number “#FF0000” represents the color red, “#00FF00” represents green, and “#0000FF” represents blue.  The color black is “#000000” and white is “#FFFFFF”. &lt;br /&gt;
 &lt;br /&gt;
The hash tag or number sign is used to denote a hexadecimal number.  $FF_{16} = F (15) × 16 + F (15) × 1 = 240 + 15 = 255_{10}$ so there are 0 to 255 or 256 different shades of each color or $256^{3} = 16,777,216$ different colors. &lt;br /&gt;
 &lt;br /&gt;
The following web site has nearly every color name, along with its hex code and decimal values:  &lt;br /&gt;
 &lt;br /&gt;
:https://www.rapidtables.com/web/color/RGB_Color.html &lt;br /&gt;
 &lt;br /&gt;
For example “salmon” is “#FA8072” which represents the decimal numbers 250 (hex FA), 128 (hex 80), and 114 (hex 72).&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
[https://ryanstutorials.net/ Ryan&amp;#039;s Tutorials] covers this topic beautifully. Rather than trying to duplicate that work, we&amp;#039;ll point you to the different sections:&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/ 1. Number Systems] - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-conversions.php 2. Binary Conversions] - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the [https://ryanstutorials.net/binary-tutorial/binary-conversions.php#activities &amp;#039;&amp;#039;Activities&amp;#039;&amp;#039;] section, you can practice converting numbers. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-arithmetic.php 3. Binary Arithmetic] - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-negative-numbers.php 4. Negative Numbers] - ACSL problems will not cover how negative numbers are represented in binary. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-floating-point.php 5. Binary Fractions and Floating Point] - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section [https://ryanstutorials.net/binary-tutorial/binary-floating-point.php#convertfraction Converting to a Binary Fraction], but keep in mind that ACSL problems may also cover octal and hexadecimal fractions.&lt;br /&gt;
&lt;br /&gt;
The  [https://coolconversion.com/math/binary-octal-hexa-decimal/ CoolConversion.com online calculator] is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion. &lt;br /&gt;
&lt;br /&gt;
The AskNumbers.com site has a nice description of the conversions between [https://www.asknumbers.com/hex-to-octal.aspx binary, octal, decimal and hexadecimal] numbers. &lt;br /&gt;
&lt;br /&gt;
== Format of ACSL Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.&lt;br /&gt;
&lt;br /&gt;
To be successful in this category, you must know the following facts cold:&lt;br /&gt;
&lt;br /&gt;
# The binary value of each octal digit 0, 1, ..., 7&lt;br /&gt;
# The binary value of each hex digit 0, 1, ..., 9, A, B, C, D, E, F&lt;br /&gt;
# The decimal value of each hex digit 0, 1, ..., F  &lt;br /&gt;
# Powers  of  2,  up  to 4096&lt;br /&gt;
# Powers  of  8,  up  to 4096&lt;br /&gt;
# Powers  of  16,  up  to  65,536&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ where $x_{16}=3676_8$.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.&lt;br /&gt;
&lt;br /&gt;
An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:&lt;br /&gt;
 &lt;br /&gt;
$$\begin{align}&lt;br /&gt;
3676_8 &amp;amp;= 011 ~  110 ~ 111 ~ 110_2  &amp;amp; \text{convert each octal digit into base 2}\hfill\cr &lt;br /&gt;
&amp;amp;= 0111 ~ 1011 ~ 1110_2  &amp;amp; \text{group by 4 bits, from right-to-left}\hfill\cr&lt;br /&gt;
&amp;amp;= 7 ~ \text{B} ~ \text{E}_{16}  &amp;amp; \text{convert each group of 4 bits into a hex digit}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ in the following hexadecimal equation: $ x= \text{F5AD}_{16} - \text{69EB}_{16}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, &lt;br /&gt;
working directly in base 16 isn&amp;#039;t too hard. &lt;br /&gt;
As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.  &lt;br /&gt;
&lt;br /&gt;
:The rightmost digit becomes 2, because D-B=2.  &lt;br /&gt;
:The next column is A-E. We need to &amp;#039;&amp;#039;borrow&amp;#039;&amp;#039; a one from the 5 column, and 1A-E=C &lt;br /&gt;
:In the next column, 4-9=B, again, borrowing a 1 from the next column.&lt;br /&gt;
:Finally, the leftmost column,  E-6=8&lt;br /&gt;
&lt;br /&gt;
Combining these results of each column, we get a final answer of $8BC2_{16}$.&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
How many numbers from 100 to 200 in base 10 consist of distinct&lt;br /&gt;
ascending digits and also have distinct ascending hex digits when&lt;br /&gt;
converted to base 16? &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; There are 13 numbers that have ascending digits in both bases from 100&lt;br /&gt;
to 200.  They are (in base 10):&lt;br /&gt;
123 (7B), 124, 125, 126, 127 (7F), 137 (89), 138, 139 (8B), 156 (9C), 157, 158, 159 (9F), 189 (BD)&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
===ACSL Videos===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/2v5hDcKCfbo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/2v5hDcKCfbo &amp;#039;&amp;#039;Computer Number Systems - ACSL Short Problems Topic&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Next Generation Academy&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A great tutorial covering this ACSL category, and shows how&lt;br /&gt;
to solve many ACSL problems that have appeared in previous contests.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Other Videos ===&lt;br /&gt;
&lt;br /&gt;
There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aW3qCcH6Dao&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aW3qCcH6Dao &amp;#039;&amp;#039;Number Systems - Converting Decimal, Binary and Hexadecimal&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Joe James&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
An introduction to number systems, and how to convert between decimal, binary and hexadecimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m1JtWKuTLR0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m1JtWKuTLR0 &amp;#039;&amp;#039;Lesson 2.3 : Hexadecimal Tutorial&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carl Herold&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video focuses on hexadecimal numbers: their relationship to binary numbers and how to convert to decimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/WR67syBDzew&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/WR67syBDzew &amp;#039;&amp;#039;Hexes and the Magic of Base 16 - Vaidehi Joshi - May 2017&amp;#039; (&amp;#039;&amp;#039;&amp;#039;DonutJS&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A fun introduction to hexadecimal numbers, focusing a bit &lt;br /&gt;
on using hex numbers for specifying RGB colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jvx-NrILgpE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jvx-NrILgpE &amp;#039;&amp;#039;Collins Lab: Binary &amp;amp; Hex&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Adafruit Industries&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A professionally produced video that explains the number systems, how and why binary numbers are fundamental to computer science, and why hexadecimal is important to computer programmers.  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Prefix/Infix/Postfix_Notation&amp;diff=877</id>
		<title>Prefix/Infix/Postfix Notation</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Prefix/Infix/Postfix_Notation&amp;diff=877"/>
		<updated>2021-12-20T19:04:40Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Converting Expressions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The expression $5+\large{8\over{3-1}}$ clearly has a value of 9. It is written in &amp;#039;&amp;#039;infix&amp;#039;&amp;#039; notation as $5+8/(3-1)$. The value of an &amp;#039;&amp;#039;infix&amp;#039;&amp;#039; version is well-defined because there is a well-established order of precedence in mathematics: We first evaluate the parentheses (3-1=2); then, because division has higher precedence that subtraction, we next do 8/2=4. And finally, 5+4=9.  The order of precedence is often given the mnemonic of &amp;#039;&amp;#039;&amp;#039;Please excuse my dear Aunt Sue&amp;#039;&amp;#039;&amp;#039;, or &amp;#039;&amp;#039;&amp;#039;PEMDAS&amp;#039;&amp;#039;&amp;#039;: &amp;#039;&amp;#039;&amp;#039;p&amp;#039;&amp;#039;&amp;#039;arentheses, &amp;#039;&amp;#039;&amp;#039;e&amp;#039;&amp;#039;&amp;#039;xponentiation, &amp;#039;&amp;#039;&amp;#039;m&amp;#039;&amp;#039;&amp;#039;ultiplication/&amp;#039;&amp;#039;&amp;#039;d&amp;#039;&amp;#039;&amp;#039;ivision, and &amp;#039;&amp;#039;&amp;#039;a&amp;#039;&amp;#039;&amp;#039;ddition/&amp;#039;&amp;#039;&amp;#039;&amp;#039;s&amp;#039;&amp;#039;&amp;#039;ubtraction. Multiplication and division have the same level of precedence; addition and subtraction also have the same level of precedence. Terms with equals precedence are evaluated from left-to-right [https://en.wikipedia.org/wiki/Order_of_operations wikipedia].&lt;br /&gt;
&lt;br /&gt;
The algorithm to evaluate an &amp;#039;&amp;#039;infix&amp;#039;&amp;#039; expression is complex, as it must address the order of precedence. Two alternative notations have been developed which lend themselves to simple computer algorithms for evaluating expressions. In &amp;#039;&amp;#039;prefix&amp;#039;&amp;#039; notation, each operator is placed before its operands . The expression above would be &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;+ 5 / 8 - 3 1&amp;lt;/syntaxhighlight&amp;gt;. In &amp;#039;&amp;#039;postfix&amp;#039;&amp;#039; notation, each operator is placed after its operand. The expression above is &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;5 8 3 1 - / +&amp;lt;/syntaxhighlight&amp;gt;.  In &amp;#039;&amp;#039;prefix&amp;#039;&amp;#039; and &amp;#039;&amp;#039;postfix&amp;#039;&amp;#039; notations, there is no notion of order of precedence, nor are there any parentheses. The evaluation is the same regardless of the operators. &lt;br /&gt;
&lt;br /&gt;
Problems in this category ask to convert between prefix, infix, and postfix, or to evaluate an expression in prefix or postfix.&lt;br /&gt;
&lt;br /&gt;
== Converting Expressions ==&lt;br /&gt;
&lt;br /&gt;
An algorithm for converting from infix to prefix (postfix) is as follows:&lt;br /&gt;
* Fully parenthesize the infix expression.  It should now consist solely of “terms”:  a binary operator sandwiched between two operands.&lt;br /&gt;
* Write down the operands in the same order that they appear in the infix expression.&lt;br /&gt;
* Look at each term in the infix expression in the order that one would evaluate them, i.e., inner-most parenthesis to outer-most and left to right among terms of the same depth.&lt;br /&gt;
* For each term, write down the operator before (after) the operands.  &lt;br /&gt;
&lt;br /&gt;
One way to convert from prefix (postfix) to infix is to make repeated scans through the expression. &lt;br /&gt;
Each scan, find an operator with two adjacent operands and replace it with a parenthesized infix expression. &lt;br /&gt;
This is not the most efficient algorithm, but works well for a human.&lt;br /&gt;
&lt;br /&gt;
A quick check for determining whether a conversion is correct is to convert the result back into the original format.&lt;br /&gt;
&lt;br /&gt;
== Context ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Prefix&amp;#039;&amp;#039; and &amp;#039;&amp;#039;postfix&amp;#039;&amp;#039; notation is also known as [https://en.wikipedia.org/wiki/Polish_notation &amp;#039;&amp;#039;Polish&amp;#039;&amp;#039; and &amp;#039;&amp;#039;Reverse Polish&amp;#039;&amp;#039; notation], respectively.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Infix to Prefix ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sequence of steps illustrates converting $X=\left(AB-{C\over{D}}\right)^E$ from infix to prefix:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!(X = (((A * B) - (C / D)) ↑ E)) &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot;  |X A B C D E	&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;* A B&amp;lt;/syntaxhighlight&amp;gt; C D E&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;* A B&amp;lt;/syntaxhighlight&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;/ C D&amp;lt;/syntaxhighlight&amp;gt; E&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;- * A B / C D&amp;lt;/syntaxhighlight&amp;gt; E&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; |  X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;↑-  * A B / C D E&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;= X ↑ - * A B / C D E&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Infix to Postfix ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sequence of steps illustrates converting $X=\left(AB-{C\over{D}}\right)^E$ from infix to postfix:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!(X = (((A * B) - (C / D)) ↑ E))&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot;  |X A B C D E	&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;A B *&amp;lt;/syntaxhighlight&amp;gt; C D E&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;A B *&amp;lt;/syntaxhighlight&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;C D /&amp;lt;/syntaxhighlight&amp;gt; E&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;A B * C D / -&amp;lt;/syntaxhighlight&amp;gt; E&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; |  X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;A B * C D / - E ↑&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt; X A B * C D / - E ↑ =&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Prefix to Infix ===&lt;br /&gt;
&lt;br /&gt;
The following sequence of steps illustrates converting  $(3*4+{8\over{2}})^{(7-5)}$  from its prefix representation to infix:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! ↑ + * 3 4 / 8 2 – 7 5 &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; | ↑ + &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(3*4)&amp;lt;/syntaxhighlight&amp;gt; / 8 2 – 7 5&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; |↑ + &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(3*4)&amp;lt;/syntaxhighlight&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(8/2)&amp;lt;/syntaxhighlight&amp;gt; – 7 5&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; |↑ &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(3*4)+(8/2)&amp;lt;/syntaxhighlight&amp;gt; - 7 5&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; |↑ &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;((3*4)+(8/2))&amp;lt;/syntaxhighlight&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(7-5)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; |&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(((3*4)+(8/2))↑(7-5))&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Postfix to Infix ===&lt;br /&gt;
&lt;br /&gt;
The following sequence of steps illustrates converting  $(3*4+{8\over{2}})^{(7-5)}$  from its postfix representation to infix:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!3 4 * 8 2 / + 7 5 -↑&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; | &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(3*4)&amp;lt;/syntaxhighlight&amp;gt; 8 2 / + 7 5 - ↑&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; | &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(3*4)&amp;lt;/syntaxhighlight&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(8/2)&amp;lt;/syntaxhighlight&amp;gt; + 7 5 - ↑&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; | &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;((3*4)+(8/2))&amp;lt;/syntaxhighlight&amp;gt; 7 5 -↑ &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; | &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;((3*4)+(8/2))&amp;lt;/syntaxhighlight&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(7-5)&amp;lt;/syntaxhighlight&amp;gt; ↑ &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; |&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(((3*4)+(8/2))↑(7-5))&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some previous problems.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/lDm08rP_lms&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/lDm08rP_lms &amp;#039;&amp;#039;ACSL Prefix Postfix Infix Contest 2 Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Mr. Minich is an ACSL advisor. This video was created to help prepare his students for the ACSL Prefix/Infix/Postfix category. It shows solutions to 5 different problems that have&lt;br /&gt;
appeared in recent years. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/4YZdsw2UOpo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/4YZdsw2UOpo &amp;#039;&amp;#039;Prefix Notation&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
To quote the video description: &amp;#039;&amp;#039;A general tutorial on prefix notation that can be used for American Computer Science League.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/R-t9-rbJDw8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/R-t9-rbJDw8 &amp;#039;&amp;#039;Postfix Notation&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
To quote the video description: &amp;#039;&amp;#039;A general tutorial on postfix notation that can be used for American Computer Science League.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/dcc-nXY2L6c&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/dcc-nXY2L6c &amp;#039;&amp;#039;2015 16 Contest 2 Prefix Infix Postfix Problem#1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Ravi Yeluru&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Ravi Yeluru walks through the solution to an ACSL Prefix/Infix/Postfix program that appeared in the 2015-16 year, Contest #2.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/lEIPvUqstEY&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/lEIPvUqstEY &amp;#039;&amp;#039;2015 16 Contest 2 Prefix Infix Postfix Problem#2&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Ravi Yeluru&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Ravi Yeluru walks through the solution to an ACSL Prefix/Infix/Postfix program that appeared in the 2015-16 year, Contest #2.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Other Videos ===&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos cover various aspects of this topic; they were created by authors who are not involved (or aware) of ACSL, to the best of our knowledge. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/t7YWDiz8LMY&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/t7YWDiz8LMY &amp;#039;&amp;#039;Infix Postfix and Prefix Notation&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carleton Moore&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A very gentle overview of infix, prefix, and postfix.&lt;br /&gt;
 &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/z3VsmufB_QI&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/z3VsmufB_Q I&amp;#039;&amp;#039;Infix Prefix and Postfix&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;University Academy&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Another very gentle overview of infix, prefix, and postfix.&lt;br /&gt;
 &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jos1Flt21is&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jos1Flt21is &amp;#039;&amp;#039;Infix Postfix and Prefix Notation&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;mycodeschool&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Another overview of infix, prefix, and postfix notations.&lt;br /&gt;
 &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/MeRb_1bddWg&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/MeRb_1bddWg &amp;#039;&amp;#039;Evaluation of Prefix and Postfix expressions using stack&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;mycodeschool&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Describes the standard algorithm to evaluate prefix and postfix expressions.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/vq-nUF0G4fI&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/vq-nUF0G4fI &amp;#039;&amp;#039;Infix to Postfix using stack&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;mycodeschool&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Describes the standard algorithm to convert from infix to postfix. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;URL&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [URL &amp;#039;&amp;#039;TITLE&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;AUTHOR&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Digital_Electronics&amp;diff=876</id>
		<title>Digital Electronics</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Digital_Electronics&amp;diff=876"/>
		<updated>2021-12-18T19:14:36Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Other Videos */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A digital circuit is constructed from logic gates. Each logic gate performs a function of boolean logic based on its inputs, such as AND or OR. &lt;br /&gt;
Each circuit can be represented as a Boolean Algebra expression; &lt;br /&gt;
this topic is an extension of the topic of [[Boolean Algebra]], which includes &lt;br /&gt;
a thorough description of truth tables and simplifying expressions. &lt;br /&gt;
&lt;br /&gt;
= Definitions =&lt;br /&gt;
&lt;br /&gt;
The following table illustrates all logic gates. For each logic gate, the&lt;br /&gt;
table shows the equivalent Boolean algebra expression and truth table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;NAME&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;GRAPHICAL SYMBOL&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;ALGEBRAIC EXPRESSION&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;TRUTH TABLE&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;BUFFER&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Buffer-gate-en.svg|128px]]&lt;br /&gt;
| X = A&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Not-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;\overline{A}&amp;lt;/math&amp;gt; or  &amp;lt;math&amp;gt;\neg A&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| |[[File:And-gate.png|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;AB&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;A \cdot B&amp;lt;/math&amp;gt; &lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|colspan=&amp;quot;1&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B ||  X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;NAND&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Nand-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;\overline{AB}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\overline{A\cdot B}&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Or-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;A+B&amp;lt;/math&amp;gt; &lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;NOR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Nor-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;\overline{A+B}&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|[[File:Xor-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;A \oplus B&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;XNOR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Xnor-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;\overline{A \oplus B} \text{ or } A \odot B&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that there is some ambiguity in the conversion from a diagram to a circuit. For example, is &amp;lt;math&amp;gt;\overline{A+B}&amp;lt;/math&amp;gt; an OR gate followed by a NOT gate, or smply&lt;br /&gt;
a NOT gate.&lt;br /&gt;
&lt;br /&gt;
=Online Tools=&lt;br /&gt;
&lt;br /&gt;
The [http://www.cburch.com/logisim/index.html Logisim] application is a wonderful tool&lt;br /&gt;
for exploring this topic.&lt;br /&gt;
Logisim is free to download and use; among its many features is support to automatically draw&lt;br /&gt;
a circuit from a Boolean Algebra expression; to simulate the circuit with arbitrary inputs;&lt;br /&gt;
and to complete a truth table for the circuit. From the application, you can import the circuit corresponding to the [[#Sample_Problem_1|Sample Problem 1]] &lt;br /&gt;
from the file located at [http://www.acsl.org/misc/wiki-digital-electronics-sample1.circ http://www.acsl.org/misc/wiki-digital-electronics-sample1.circ].&lt;br /&gt;
There are many YouTube videos that show how to use the Logisim application; including a very nice [https://www.youtube.com/watch?v=cMz7wyY_PxE 4 minute tutorial].&lt;br /&gt;
&lt;br /&gt;
Logisim contains many &lt;br /&gt;
additional advanced features that are beyond&lt;br /&gt;
the scope of ACSL problems.&lt;br /&gt;
&lt;br /&gt;
=Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Sample Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
Find all ordered triplets (A, B, C) which make the following circuit FALSE:&lt;br /&gt;
&lt;br /&gt;
::[[File:NotABorC.svg|200px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
One approach to solving this problem is to reason about that inputs and outputs are necessary at each gate. For the circuit to be FALSE, both inputs to the file OR gate must be false. Thus, input C must be FALSE, and the output of the NAND gate must also be false. The NAND gate is false only when both of its inputs are TRUE; thus, inputs A and B must both be TRUE. The final answer is (TRUE, TRUE, FALSE), or (1, 1, 0).&lt;br /&gt;
&lt;br /&gt;
Another approach to solving this problem is to translate the circuit into a Boolean Algebra expression and simplify &lt;br /&gt;
the expression using the laws of Boolean Algebra. This circuit translates to the Boolean expression &amp;lt;math&amp;gt;\overline{AB}+C&amp;lt;/math&amp;gt;.  &lt;br /&gt;
To find when this is FALSE we can equivalently find when the &amp;lt;math&amp;gt;\overline{\overline{AB}+C}&amp;lt;/math&amp;gt; is TRUE.  &lt;br /&gt;
The expression becomes &amp;lt;math&amp;gt;\overline{\overline{AB}}\cdot \overline{C}&amp;lt;/math&amp;gt; after applying DeMorgan’s Law.  The double NOT over the AB expression&lt;br /&gt;
cancels out, to become &amp;lt;math&amp;gt;AB\overline{C}&amp;lt;/math&amp;gt;.  The AND of 3 terms is TRUE when each term is TRUE, or A=1, B=1 and C=0.&lt;br /&gt;
&lt;br /&gt;
== Sample Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
How many ordered 4-tuples (A, B, C, D) make the following circuit TRUE?&lt;br /&gt;
&lt;br /&gt;
::[[File:circuit-sample2.svg |400px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
We&amp;#039;ll use a truth table to solve this problem. The rows in the truth table will correspond to all possible inputs - 16 in this case, since there are 4 inputs. The output columns will be the output of each gate, other than the NOT gates. The diagram below labels each of the gates; it&amp;#039;s useful to keep the column straight when working the truth table.&lt;br /&gt;
&lt;br /&gt;
::[[File:circuit-sample2-labels.svg |300px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|colspan=&amp;quot;5&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot; | A&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot; | B&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot; | C&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot; | D&lt;br /&gt;
!  p&lt;br /&gt;
!  q&lt;br /&gt;
!  r&lt;br /&gt;
!  s&lt;br /&gt;
!  t&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{C+D}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;p+\overline{B}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A}B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;r \oplus q&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;s \oplus p&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0 || 0 || 0 || 1 || 1 || 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0 || 0 || 1 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0 || 1 || 0 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0 || 1 || 1 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 1 || 0 || 0 || 1 || 1 || 1 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 1 || 0 || 1 || 0 || 0 || 1 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 1 || 1 || 0 || 0 || 1 || 1 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 1 || 1 || 1 || 0 || 0 || 1 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 0 || 0 || 1 || 1 || 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 0 || 1 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 0 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 1 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 0 || 0 || 1 || 1 || 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 0 || 1 || 0 || 0 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 1 || 0 || 0 || 0 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 1 || 1 || 0 || 0 || 0 || 0 || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
From the truth table, there are 10 rows where the final output is TRUE.&lt;br /&gt;
&lt;br /&gt;
== Sample Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
Simplify the Boolean expression that this circuit represents.&lt;br /&gt;
&lt;br /&gt;
::[[File:Circuit-PB.png|200px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The circuit translates as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;(\overline{A}(A+B))\overline{B+C}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;=(\overline{A}A+\overline{A}B)\overline{B}\overline{C}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;=(0+\overline{A}B)\overline{B}\overline{C}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;=\overline{A}B\overline{B}\overline{C}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
==ACSL Advisors==&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;URL&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [URL &amp;#039;&amp;#039;TITLE&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;AUTHOR&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/gxil9VyGTtE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/gxil9VyGTtE &amp;#039;&amp;#039;Digital Electronics -1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Ravi Yeluru (hemsra)&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Introduces the AND, OR, and NOT gates, and works through a couple of simple circuits.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m7-wa5ca_G8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m7-wa5ca_G8 Digital Electronics -2&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Ravi Yeluru (hemsra)&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Solves a 3-gate circuit (the AND of an OR and a NOR) given by the Boolean expression &amp;lt;math&amp;gt;(\overline{A}+B)(\overline{B+C})&amp;lt;/math&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/Eckd5UlJmB4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/Eckd5UlJmB4 &amp;#039;&amp;#039;Digital Electronics Boolean Algebra&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Solves a 3-gate circuit (the AND of an OR and a NOR) given by the Boolean expression&lt;br /&gt;
&amp;lt;math&amp;gt;\overline{(A+B)}(B+C)&amp;lt;/math&amp;gt;. &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/JJL6DsVCpHo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/JJL6DsVCpHo &amp;#039;&amp;#039;ACSL Digital Electronics Worksheet Sample&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Solves a handful of ACSL problems.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Other Videos==&lt;br /&gt;
&lt;br /&gt;
The topic of Digital Electronics is fundamental in Computer Science and there are many videos on YouTube that teach this subject. We found the following videos to be&lt;br /&gt;
nice introductions to digital logic gates. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/s2MI_NgKD98&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/s2MI_NgKD98 &amp;#039;&amp;#039;Digital Electronics Basics&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Beginning Electronics&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/z9s8A8oBe7g&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/z9s8A8oBe7g &amp;#039;&amp;#039;Logic Gate Expressions&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Kevin Drumm&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/eroqZpbKrhc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/eroqZpbKrhc &amp;#039;&amp;#039;Determining the truth table and logic statement&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Anna does some physics&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
Uses a truth table to find the inputs that make the circuit &amp;lt;math&amp;gt;\not(A+B)+(AB)&amp;lt;/math&amp;gt; true using a truth table.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Digital_Electronics&amp;diff=873</id>
		<title>Digital Electronics</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Digital_Electronics&amp;diff=873"/>
		<updated>2021-12-08T04:31:14Z</updated>

		<summary type="html">&lt;p&gt;Marc: Reverted edits by Marc (talk) to last revision by Partha&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A digital circuit is constructed from logic gates. Each logic gate performs a function of boolean logic based on its inputs, such as AND or OR. &lt;br /&gt;
Each circuit can be represented as a Boolean Algebra expression; &lt;br /&gt;
this topic is an extension of the topic of [[Boolean Algebra]], which includes &lt;br /&gt;
a thorough description of truth tables and simplifying expressions. &lt;br /&gt;
&lt;br /&gt;
= Definitions =&lt;br /&gt;
&lt;br /&gt;
The following table illustrates all logic gates. For each logic gate, the&lt;br /&gt;
table shows the equivalent Boolean algebra expression and truth table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;NAME&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;GRAPHICAL SYMBOL&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;ALGEBRAIC EXPRESSION&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;TRUTH TABLE&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;BUFFER&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Buffer-gate-en.svg|128px]]&lt;br /&gt;
| X = A&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Not-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;\overline{A}&amp;lt;/math&amp;gt; or  &amp;lt;math&amp;gt;\neg A&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| |[[File:And-gate.png|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;AB&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;A \cdot B&amp;lt;/math&amp;gt; &lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|colspan=&amp;quot;1&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B ||  X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;NAND&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Nand-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;\overline{AB}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\overline{A\cdot B}&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Or-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;A+B&amp;lt;/math&amp;gt; &lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;NOR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Nor-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;\overline{A+B}&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|[[File:Xor-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;A \oplus B&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;XNOR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Xnor-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;\overline{A \oplus B} \text{ or } A \odot B&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that there is some ambiguity in the conversion from a diagram to a circuit. For example, is &amp;lt;math&amp;gt;\overline{A+B}&amp;lt;/math&amp;gt; an OR gate followed by a NOT gate, or smply&lt;br /&gt;
a NOT gate.&lt;br /&gt;
&lt;br /&gt;
=Online Tools=&lt;br /&gt;
&lt;br /&gt;
The [http://www.cburch.com/logisim/index.html Logisim] application is a wonderful tool&lt;br /&gt;
for exploring this topic.&lt;br /&gt;
Logisim is free to download and use; among its many features is support to automatically draw&lt;br /&gt;
a circuit from a Boolean Algebra expression; to simulate the circuit with arbitrary inputs;&lt;br /&gt;
and to complete a truth table for the circuit. From the application, you can import the circuit corresponding to the [[#Sample_Problem_1|Sample Problem 1]] &lt;br /&gt;
from the file located at [http://www.acsl.org/misc/wiki-digital-electronics-sample1.circ http://www.acsl.org/misc/wiki-digital-electronics-sample1.circ].&lt;br /&gt;
There are many YouTube videos that show how to use the Logisim application; including a very nice [https://www.youtube.com/watch?v=cMz7wyY_PxE 4 minute tutorial].&lt;br /&gt;
&lt;br /&gt;
Logisim contains many &lt;br /&gt;
additional advanced features that are beyond&lt;br /&gt;
the scope of ACSL problems.&lt;br /&gt;
&lt;br /&gt;
=Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Sample Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
Find all ordered triplets (A, B, C) which make the following circuit FALSE:&lt;br /&gt;
&lt;br /&gt;
::[[File:NotABorC.svg|200px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
One approach to solving this problem is to reason about that inputs and outputs are necessary at each gate. For the circuit to be FALSE, both inputs to the file OR gate must be false. Thus, input C must be FALSE, and the output of the NAND gate must also be false. The NAND gate is false only when both of its inputs are TRUE; thus, inputs A and B must both be TRUE. The final answer is (TRUE, TRUE, FALSE), or (1, 1, 0).&lt;br /&gt;
&lt;br /&gt;
Another approach to solving this problem is to translate the circuit into a Boolean Algebra expression and simplify &lt;br /&gt;
the expression using the laws of Boolean Algebra. This circuit translates to the Boolean expression &amp;lt;math&amp;gt;\overline{AB}+C&amp;lt;/math&amp;gt;.  &lt;br /&gt;
To find when this is FALSE we can equivalently find when the &amp;lt;math&amp;gt;\overline{\overline{AB}+C}&amp;lt;/math&amp;gt; is TRUE.  &lt;br /&gt;
The expression becomes &amp;lt;math&amp;gt;\overline{\overline{AB}}\cdot \overline{C}&amp;lt;/math&amp;gt; after applying DeMorgan’s Law.  The double NOT over the AB expression&lt;br /&gt;
cancels out, to become &amp;lt;math&amp;gt;AB\overline{C}&amp;lt;/math&amp;gt;.  The AND of 3 terms is TRUE when each term is TRUE, or A=1, B=1 and C=0.&lt;br /&gt;
&lt;br /&gt;
== Sample Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
How many ordered 4-tuples (A, B, C, D) make the following circuit TRUE?&lt;br /&gt;
&lt;br /&gt;
::[[File:circuit-sample2.svg |400px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
We&amp;#039;ll use a truth table to solve this problem. The rows in the truth table will correspond to all possible inputs - 16 in this case, since there are 4 inputs. The output columns will be the output of each gate, other than the NOT gates. The diagram below labels each of the gates; it&amp;#039;s useful to keep the column straight when working the truth table.&lt;br /&gt;
&lt;br /&gt;
::[[File:circuit-sample2-labels.svg |300px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|colspan=&amp;quot;5&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot; | A&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot; | B&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot; | C&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot; | D&lt;br /&gt;
!  p&lt;br /&gt;
!  q&lt;br /&gt;
!  r&lt;br /&gt;
!  s&lt;br /&gt;
!  t&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{C+D}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;p+\overline{B}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A}B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;r \oplus q&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;s \oplus p&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0 || 0 || 0 || 1 || 1 || 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0 || 0 || 1 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0 || 1 || 0 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0 || 1 || 1 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 1 || 0 || 0 || 1 || 1 || 1 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 1 || 0 || 1 || 0 || 0 || 1 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 1 || 1 || 0 || 0 || 1 || 1 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 1 || 1 || 1 || 0 || 0 || 1 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 0 || 0 || 1 || 1 || 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 0 || 1 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 0 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 1 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 0 || 0 || 1 || 1 || 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 0 || 1 || 0 || 0 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 1 || 0 || 0 || 0 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 1 || 1 || 0 || 0 || 0 || 0 || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
From the truth table, there are 10 rows where the final output is TRUE.&lt;br /&gt;
&lt;br /&gt;
== Sample Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
Simplify the Boolean expression that this circuit represents.&lt;br /&gt;
&lt;br /&gt;
::[[File:Circuit-PB.png|200px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The circuit translates as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;(\overline{A}(A+B))\overline{B+C}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;=(\overline{A}A+\overline{A}B)\overline{B}\overline{C}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;=(0+\overline{A}B)\overline{B}\overline{C}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;=\overline{A}B\overline{B}\overline{C}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
==ACSL Advisors==&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;URL&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [URL &amp;#039;&amp;#039;TITLE&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;AUTHOR&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/gxil9VyGTtE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/gxil9VyGTtE &amp;#039;&amp;#039;Digital Electronics -1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Ravi Yeluru (hemsra)&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Introduces the AND, OR, and NOT gates, and works through a couple of simple circuits.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m7-wa5ca_G8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m7-wa5ca_G8 Digital Electronics -2&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Ravi Yeluru (hemsra)&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Solves a 3-gate circuit (the AND of an OR and a NOR) given by the Boolean expression &amp;lt;math&amp;gt;(\overline{A}+B)(\overline{B+C})&amp;lt;/math&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/Eckd5UlJmB4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/Eckd5UlJmB4 &amp;#039;&amp;#039;Digital Electronics Boolean Algebra&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Solves a 3-gate circuit (the AND of an OR and a NOR) given by the Boolean expression&lt;br /&gt;
&amp;lt;math&amp;gt;\overline{(A+B)}(B+C)&amp;lt;/math&amp;gt;. &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/JJL6DsVCpHo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/JJL6DsVCpHo &amp;#039;&amp;#039;ACSL Digital Electronics Worksheet Sample&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Solves a handful of ACSL problems.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Other Videos==&lt;br /&gt;
&lt;br /&gt;
The topic of Digital Electronics is fundamental in Computer Science and there are many videos on YouTube that teach this subject. We found the following videos to be&lt;br /&gt;
nice introductions to digital logic gates. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/s2MI_NgKD98&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/s2MI_NgKD98 &amp;#039;&amp;#039;Digital Electronics Basics&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Beginning Electronics&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/z9s8A8oBe7g&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/z9s8A8oBe7g &amp;#039;&amp;#039;Logic Gate Expressions&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Kevin Drumm&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/TLl4E3IV6Z0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/TLl4E3IV6Z0 &amp;#039;&amp;#039;Logic Gate Combinations&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Kevin Drumm&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/eroqZpbKrhc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/eroqZpbKrhc &amp;#039;&amp;#039;Determining the truth table and logic statement&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Anna does some physics&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
Uses a truth table to find the inputs that make the circuit &amp;lt;math&amp;gt;\not(A+B)+(AB)&amp;lt;/math&amp;gt; true using a truth table.&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Digital_Electronics&amp;diff=872</id>
		<title>Digital Electronics</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Digital_Electronics&amp;diff=872"/>
		<updated>2021-12-08T04:27:54Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Video Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A digital circuit is constructed from logic gates. Each logic gate performs a function of boolean logic based on its inputs, such as AND or OR. &lt;br /&gt;
Each circuit can be represented as a Boolean Algebra expression; &lt;br /&gt;
this topic is an extension of the topic of [[Boolean Algebra]], which includes &lt;br /&gt;
a thorough description of truth tables and simplifying expressions. &lt;br /&gt;
&lt;br /&gt;
= Definitions =&lt;br /&gt;
&lt;br /&gt;
The following table illustrates all logic gates. For each logic gate, the&lt;br /&gt;
table shows the equivalent Boolean algebra expression and truth table.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;NAME&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;GRAPHICAL SYMBOL&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;ALGEBRAIC EXPRESSION&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;TRUTH TABLE&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;BUFFER&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Buffer-gate-en.svg|128px]]&lt;br /&gt;
| X = A&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Not-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;\overline{A}&amp;lt;/math&amp;gt; or  &amp;lt;math&amp;gt;\neg A&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| |[[File:And-gate.png|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;AB&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;A \cdot B&amp;lt;/math&amp;gt; &lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|colspan=&amp;quot;1&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B ||  X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;NAND&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Nand-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;\overline{AB}&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;\overline{A\cdot B}&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Or-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;A+B&amp;lt;/math&amp;gt; &lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;NOR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Nor-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;\overline{A+B}&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|[[File:Xor-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;A \oplus B&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 0&lt;br /&gt;
|}&lt;br /&gt;
|-&lt;br /&gt;
!&amp;#039;&amp;#039;&amp;#039;XNOR&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| [[File:Xnor-gate-en.svg|128px]]&lt;br /&gt;
| X = &amp;lt;math&amp;gt;\overline{A \oplus B} \text{ or } A \odot B&amp;lt;/math&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
! A || B || X&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || 1&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that there is some ambiguity in the conversion from a diagram to a circuit. For example, is &amp;lt;math&amp;gt;\overline{A+B}&amp;lt;/math&amp;gt; an OR gate followed by a NOT gate, or smply&lt;br /&gt;
a NOT gate.&lt;br /&gt;
&lt;br /&gt;
=Online Tools=&lt;br /&gt;
&lt;br /&gt;
The [http://www.cburch.com/logisim/index.html Logisim] application is a wonderful tool&lt;br /&gt;
for exploring this topic.&lt;br /&gt;
Logisim is free to download and use; among its many features is support to automatically draw&lt;br /&gt;
a circuit from a Boolean Algebra expression; to simulate the circuit with arbitrary inputs;&lt;br /&gt;
and to complete a truth table for the circuit. From the application, you can import the circuit corresponding to the [[#Sample_Problem_1|Sample Problem 1]] &lt;br /&gt;
from the file located at [http://www.acsl.org/misc/wiki-digital-electronics-sample1.circ http://www.acsl.org/misc/wiki-digital-electronics-sample1.circ].&lt;br /&gt;
There are many YouTube videos that show how to use the Logisim application; including a very nice [https://www.youtube.com/watch?v=cMz7wyY_PxE 4 minute tutorial].&lt;br /&gt;
&lt;br /&gt;
Logisim contains many &lt;br /&gt;
additional advanced features that are beyond&lt;br /&gt;
the scope of ACSL problems.&lt;br /&gt;
&lt;br /&gt;
=Sample Problems =&lt;br /&gt;
&lt;br /&gt;
== Sample Problem 1 ==&lt;br /&gt;
&lt;br /&gt;
Find all ordered triplets (A, B, C) which make the following circuit FALSE:&lt;br /&gt;
&lt;br /&gt;
::[[File:NotABorC.svg|200px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
One approach to solving this problem is to reason about that inputs and outputs are necessary at each gate. For the circuit to be FALSE, both inputs to the file OR gate must be false. Thus, input C must be FALSE, and the output of the NAND gate must also be false. The NAND gate is false only when both of its inputs are TRUE; thus, inputs A and B must both be TRUE. The final answer is (TRUE, TRUE, FALSE), or (1, 1, 0).&lt;br /&gt;
&lt;br /&gt;
Another approach to solving this problem is to translate the circuit into a Boolean Algebra expression and simplify &lt;br /&gt;
the expression using the laws of Boolean Algebra. This circuit translates to the Boolean expression &amp;lt;math&amp;gt;\overline{AB}+C&amp;lt;/math&amp;gt;.  &lt;br /&gt;
To find when this is FALSE we can equivalently find when the &amp;lt;math&amp;gt;\overline{\overline{AB}+C}&amp;lt;/math&amp;gt; is TRUE.  &lt;br /&gt;
The expression becomes &amp;lt;math&amp;gt;\overline{\overline{AB}}\cdot \overline{C}&amp;lt;/math&amp;gt; after applying DeMorgan’s Law.  The double NOT over the AB expression&lt;br /&gt;
cancels out, to become &amp;lt;math&amp;gt;AB\overline{C}&amp;lt;/math&amp;gt;.  The AND of 3 terms is TRUE when each term is TRUE, or A=1, B=1 and C=0.&lt;br /&gt;
&lt;br /&gt;
== Sample Problem 2 ==&lt;br /&gt;
&lt;br /&gt;
How many ordered 4-tuples (A, B, C, D) make the following circuit TRUE?&lt;br /&gt;
&lt;br /&gt;
::[[File:circuit-sample2.svg |400px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
We&amp;#039;ll use a truth table to solve this problem. The rows in the truth table will correspond to all possible inputs - 16 in this case, since there are 4 inputs. The output columns will be the output of each gate, other than the NOT gates. The diagram below labels each of the gates; it&amp;#039;s useful to keep the column straight when working the truth table.&lt;br /&gt;
&lt;br /&gt;
::[[File:circuit-sample2-labels.svg |300px]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|INPUT&lt;br /&gt;
|colspan=&amp;quot;5&amp;quot; style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; &amp;quot;|OUTPUT&lt;br /&gt;
|-&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot; | A&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot; | B&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot; | C&lt;br /&gt;
!rowspan=&amp;quot;2&amp;quot; | D&lt;br /&gt;
!  p&lt;br /&gt;
!  q&lt;br /&gt;
!  r&lt;br /&gt;
!  s&lt;br /&gt;
!  t&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{C+D}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;p+\overline{B}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A}B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;r \oplus q&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;s \oplus p&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0 || 0 || 0 || 1 || 1 || 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0 || 0 || 1 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0 || 1 || 0 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 0 || 1 || 1 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 1 || 0 || 0 || 1 || 1 || 1 || 0 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 1 || 0 || 1 || 0 || 0 || 1 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 1 || 1 || 0 || 0 || 1 || 1 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|0 || 1 || 1 || 1 || 0 || 0 || 1 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 0 || 0 || 1 || 1 || 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 0 || 1 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 0 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|1 || 0 || 1 || 1 || 0 || 1 || 0 || 1 || 1&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 0 || 0 || 1 || 1 || 0 || 1 || 0&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 0 || 1 || 0 || 0 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 1 || 0 || 0 || 0 || 0 || 0 || 0&lt;br /&gt;
|-&lt;br /&gt;
|1 || 1 || 1 || 1 || 0 || 0 || 0 || 0 || 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
From the truth table, there are 10 rows where the final output is TRUE.&lt;br /&gt;
&lt;br /&gt;
== Sample Problem 3 ==&lt;br /&gt;
&lt;br /&gt;
Simplify the Boolean expression that this circuit represents.&lt;br /&gt;
&lt;br /&gt;
::[[File:Circuit-PB.png|300px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The circuit translates as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;(\overline{A}(A+B))\overline{B+C}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;=(\overline{A}A+\overline{A}B)\overline{B}\overline{C}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;=(0+\overline{A}B)\overline{B}\overline{C}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;=\overline{A}B\overline{B}\overline{C}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Video Resources =&lt;br /&gt;
&lt;br /&gt;
==ACSL Advisors==&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;URL&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [URL &amp;#039;&amp;#039;TITLE&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;AUTHOR&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Recursive_Functions&amp;diff=871</id>
		<title>Recursive Functions</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Recursive_Functions&amp;diff=871"/>
		<updated>2021-12-08T04:18:17Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Other Videos */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A definition that defines an object in terms of itself is said to be &amp;#039;&amp;#039;recursive&amp;#039;&amp;#039;.  In computer science, recursion refers to a function or subroutine that calls itself, and it is&lt;br /&gt;
a fundamental paradigm in programming. A recursive program is used for solving problems that can be broken down into sub-problems of the same type, doing so until&lt;br /&gt;
the problem is easy enough to solve directly.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Fibonacci Numbers ===&lt;br /&gt;
 &lt;br /&gt;
A common recursive function that you’ve probably encountered is the Fibonacci numbers: 0, 1, 1, 2, 3, 5, 8, 13, and so on. That is, you get the next Fibonacci number by adding together the previous two. Mathematically, this is written as &lt;br /&gt;
&lt;br /&gt;
$$f(N)=f(N-1)+f(N-2)$$&lt;br /&gt;
&lt;br /&gt;
Try finding f(10). No doubt, you have the correct answer, because you intuitively stopped when you reach $f(1)$ and $f(0)$. &lt;br /&gt;
To be formal about this, we need to define when the recursion stops, called the &amp;#039;&amp;#039;base cases&amp;#039;&amp;#039;. &lt;br /&gt;
The base cases for the Fibonacci function is $f(0)=0$, and $f(1)=1$. The typical way to write this function is as follows:&lt;br /&gt;
$$f(N)=\cases{N &amp;amp; if $N \le 1$\cr&lt;br /&gt;
f(N-1)+f(N-2) &amp;amp; if $N &amp;gt; 1$}$$&lt;br /&gt;
&lt;br /&gt;
Here is a Python implementation of the Fibonacci function:&lt;br /&gt;
&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def Fibonacci(x):&lt;br /&gt;
  if (x &amp;lt;= 1) return x&lt;br /&gt;
  return Fibonacci(x-1) + Fibonacci(x-2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(As a challenge to the reader: How could you implement the Fibonacci function without using recursion?)&lt;br /&gt;
&lt;br /&gt;
=== Factorial Function ===&lt;br /&gt;
&lt;br /&gt;
Consider the factorial function, $n! = n * (n-1) * ... * 1$, with 0! defined as having a value of 1. We can define this recursively as follows: &lt;br /&gt;
&lt;br /&gt;
$$f(x)=\cases&lt;br /&gt;
{1 &amp;amp; if $x=0$\cr&lt;br /&gt;
x*f(x-1) &amp;amp; if $x\gt 0$\cr&lt;br /&gt;
}$$&lt;br /&gt;
&lt;br /&gt;
With this definition, the factorial of every non-negative integer can be found. &lt;br /&gt;
&lt;br /&gt;
Here is a Python implementation of the factorial function:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;def Factorial(x):&lt;br /&gt;
  if (x == 0) return 1&lt;br /&gt;
  return x * Factorial(x-1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some Definitions ===&lt;br /&gt;
&lt;br /&gt;
A few definitions: &amp;#039;&amp;#039;Indirection recursion&amp;#039;&amp;#039; is when a function calls another function which eventually calls the original function. For example, A calls B, and then, before function B exits, function A is called (either by B or by a function that B calls). &amp;#039;&amp;#039;Single recursion&amp;#039;&amp;#039; is recursion with a single reference to itself, such as the factorial example above. &amp;#039;&amp;#039;Multiple recursion&amp;#039;&amp;#039;, illustrated by the Fibonacci number function, is when a function has multiple self references. &amp;#039;&amp;#039;Infinite recursion&amp;#039;&amp;#039; is a recursive function that never returns because it keeps calling itself. The program will eventually crash with an &amp;#039;&amp;#039;out of memory&amp;#039;&amp;#039; error message of some sort. &lt;br /&gt;
&lt;br /&gt;
This ACSL category focuses on mathematical recursive functions rather than programming algorithms.  While many mathematical functions can be done iteratively more efficiently than they can be done recursively, many algorithms in computer science must be written recursively.  The Tower of Hanoi which is referred to in one of the videos is a good example of this.  Another example is given in the sample problems below.&lt;br /&gt;
&lt;br /&gt;
== Sample Problems==&lt;br /&gt;
&lt;br /&gt;
This ACSL category focuses on mathematical recursive functions rather than programming procedures; but you’ll see some of the latter.&lt;br /&gt;
You will  typically  be asked to evaluate a recursive function for some specific value.   &lt;br /&gt;
It&amp;#039;s important that you are careful and neat.  Work  your  way  down  the  recursive  calls  until  there  are  no  more  calls,  and  then  work  your  way  back  up.  &lt;br /&gt;
 &lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Find $g(11)$ given the following &lt;br /&gt;
$$g(x)=\cases&lt;br /&gt;
{g(x-3)+1 &amp;amp; if $x&amp;gt;0$\cr&lt;br /&gt;
3x &amp;amp; otherwise\cr&lt;br /&gt;
}$$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The evaluation proceeds top-down as follows:&lt;br /&gt;
&lt;br /&gt;
$$\begin{align}&lt;br /&gt;
g(11)&amp;amp;=g(8)+1\cr&lt;br /&gt;
g(8)&amp;amp;=g(5)+1\cr&lt;br /&gt;
g(5)&amp;amp;=g(2)+1\cr&lt;br /&gt;
g(2)&amp;amp;=g(-1)+1\cr&lt;br /&gt;
g(-1)&amp;amp;=-3\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
We now use what we know about $g(-1)$ to learn more values, working our way back &amp;quot;up&amp;quot; the recursion:&lt;br /&gt;
:We now know the value of $g(2): g(2)=-3+1=-2$&lt;br /&gt;
:We now know the value of $g(5): g(5)= -2+1=-1$&lt;br /&gt;
:We now know the value of $g(8): g(8) = -1+1=0$&lt;br /&gt;
:And finally, we now have the value of $g(11): g(11)=0+1=1$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Find the value of $h(13)$ given the following definition of $h$:&lt;br /&gt;
&lt;br /&gt;
$$h(x)=\cases&lt;br /&gt;
{h(x-7)+1 &amp;amp; when $x&amp;gt;5$\cr&lt;br /&gt;
x &amp;amp; when $0 \le x \le 5$\cr&lt;br /&gt;
h(x+3) &amp;amp; when $x \lt 0$}$$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
$$\begin{align}&lt;br /&gt;
h(13) &amp;amp;= h(6)+1 &amp;amp; \text{top rule, since $x&amp;gt;5$}\cr&lt;br /&gt;
h(6) &amp;amp;= h(-1)+1 &amp;amp; \text{top rule, since $x&amp;gt;5$}\cr&lt;br /&gt;
h(-1)&amp;amp;= h(-1+3) =h(2)&amp;amp; \text{bottom rule, since $x&amp;lt;0$}\cr&lt;br /&gt;
h(2)&amp;amp;=2&amp;amp;\text{middle rule, since $0 \le x \le 5$}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
We now work our way back up the recursion, filling in values that have been computed.&lt;br /&gt;
&lt;br /&gt;
:$h(-1) = h(2) = 2$&lt;br /&gt;
:$h(6)=h(-1)+1 = 2+1=3$&lt;br /&gt;
:$h(13)=h(6)+1= 3+1=4$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Find the value of $f(12,6)$ given the following definition of $f$:&lt;br /&gt;
&lt;br /&gt;
$$f(x,y)=\cases&lt;br /&gt;
{f(x-y,y-1)+2 &amp;amp; when $x&amp;gt;y$\cr&lt;br /&gt;
x+y &amp;amp; otherwise}$$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
$$\begin{align}&lt;br /&gt;
f(12,6) &amp;amp;= f(6,5)+2 &amp;amp; \text{top rule, since $x&amp;gt;y$}\cr&lt;br /&gt;
f(6,5) &amp;amp;= f(1,4)+2 &amp;amp; \text{top rule, since $x&amp;gt;y$}\cr&lt;br /&gt;
f(1,4) &amp;amp;= 1+4 = 5&amp;amp; \text{bottom rule, since $x \le y$}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
We now work our way back up the recursion, filling in values that have been computed.&lt;br /&gt;
&lt;br /&gt;
:$f(12,6) = f(6,5) + 2 = f(1,4) + 2 + 2 = 5 + 2 + 2 = 9$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 4 ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Consider the following recursive algorithm for painting a square:&lt;br /&gt;
&lt;br /&gt;
1. Given a square.&lt;br /&gt;
2. If the length of a side is less than 2 feet, then stop.&lt;br /&gt;
3. Divide the square into 4 equal size squares (i.e., draw a “plus” sign inside the square).&lt;br /&gt;
4. Paint one of these 4 small squares.&lt;br /&gt;
5. Repeat this procedure (start at step 1) for each of the 3 unpainted squares.&lt;br /&gt;
&lt;br /&gt;
If this algorithm is applied to a square with a side of 16 feet (having a total area of 256 sq. feet), how many square feet will be painted?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
In the first pass, we get four squares of side 8.&lt;br /&gt;
One is painted, three are unpainted.&lt;br /&gt;
Next, we have 3*4 squares of side 4.&lt;br /&gt;
Three are painted (area=3*4&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;), nine are not.&lt;br /&gt;
Next, we have 9*4 squares of side 2.&lt;br /&gt;
Nine are painted (area = 9*2&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;), 27 are not.&lt;br /&gt;
Finally, we have 27*4 squares of side 1.&lt;br /&gt;
Twenty-seven are painted.&lt;br /&gt;
Therefore, the total painted is 1*8&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; + 3*4&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; + 9*2&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; + 27*1&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; = 175.&lt;br /&gt;
&lt;br /&gt;
== Online Resources ==&lt;br /&gt;
&lt;br /&gt;
===ACSL===&lt;br /&gt;
&lt;br /&gt;
The following videos show the solution to problems that have appeared in previous ACSL contests. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/YinptBVZNFM&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/YinptBVZNFM &amp;quot;ACSL Math: Recursive Functions&amp;quot; (Quick Coding Bytes)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/OjZSIXStSr8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/OjZSIXStSr8 &amp;#039;&amp;#039;Recursion Example 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video walks through the solution to a straight-forward single-variable recursive function, that is, $f(x)=\cases{....}$ &lt;br /&gt;
The problem&lt;br /&gt;
appeared in ACSL Senior Division Contest #1, 2014-2015.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/MWdGTVCLI8g&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/MWdGTVCLI8g &amp;#039;&amp;#039;Recursion Example 2&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video walks through the solution to a 2-variable recursive function, that is, $f(x,y)=\cases{....}$ . The problem&lt;br /&gt;
appeared in ACSL Senior Division Contest #1, 2014-2015.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/5P5iK-5heEc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/5P5iK-5heEc &amp;#039;&amp;#039;Recursive Functions ACSL Example Problem&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video walks through the solution to a 2-variable recursive function, that is, $f(x,y)=\cases{....}$ . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Videos===&lt;br /&gt;
&lt;br /&gt;
Because recursion is such a fundamental concept in computer science, there is no end to the number of YouTube videos that cover the topic. There are dozens of walk-throughs of the factorial and Fibonacci functions, and of other classic algorithms such as Towers of Hanoi and Binary Trees.&lt;br /&gt;
Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/LdNdfPhwCP4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/LdNdfPhwCP4 &amp;#039;&amp;#039;Recursion lecture 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;anim aland&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Prof. Alan Dorin from Monash University presents an wonderful introduction to recursion. The last part of the video uses factorial as an example. Taken note how his base case guards against infinite recursion.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/dxyYP3BSdcQ&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/dxyYP3BSdcQ &amp;#039;&amp;#039;Fibonacci Sequence - Anatomy of recursion and space complexity analysis&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;mycodeschool&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video is hand-simulation on the whiteboard of the recursive code for computing a Fibonnaci number. The code uses a base case of &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;if n&amp;lt;=1 return n&amp;lt;/syntaxhighlight&amp;gt; to prevent infinite recursion where the function called with a negative parameter.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Recursive_Functions&amp;diff=870</id>
		<title>Recursive Functions</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Recursive_Functions&amp;diff=870"/>
		<updated>2021-12-08T04:17:53Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* ACSL */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A definition that defines an object in terms of itself is said to be &amp;#039;&amp;#039;recursive&amp;#039;&amp;#039;.  In computer science, recursion refers to a function or subroutine that calls itself, and it is&lt;br /&gt;
a fundamental paradigm in programming. A recursive program is used for solving problems that can be broken down into sub-problems of the same type, doing so until&lt;br /&gt;
the problem is easy enough to solve directly.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Fibonacci Numbers ===&lt;br /&gt;
 &lt;br /&gt;
A common recursive function that you’ve probably encountered is the Fibonacci numbers: 0, 1, 1, 2, 3, 5, 8, 13, and so on. That is, you get the next Fibonacci number by adding together the previous two. Mathematically, this is written as &lt;br /&gt;
&lt;br /&gt;
$$f(N)=f(N-1)+f(N-2)$$&lt;br /&gt;
&lt;br /&gt;
Try finding f(10). No doubt, you have the correct answer, because you intuitively stopped when you reach $f(1)$ and $f(0)$. &lt;br /&gt;
To be formal about this, we need to define when the recursion stops, called the &amp;#039;&amp;#039;base cases&amp;#039;&amp;#039;. &lt;br /&gt;
The base cases for the Fibonacci function is $f(0)=0$, and $f(1)=1$. The typical way to write this function is as follows:&lt;br /&gt;
$$f(N)=\cases{N &amp;amp; if $N \le 1$\cr&lt;br /&gt;
f(N-1)+f(N-2) &amp;amp; if $N &amp;gt; 1$}$$&lt;br /&gt;
&lt;br /&gt;
Here is a Python implementation of the Fibonacci function:&lt;br /&gt;
&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def Fibonacci(x):&lt;br /&gt;
  if (x &amp;lt;= 1) return x&lt;br /&gt;
  return Fibonacci(x-1) + Fibonacci(x-2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(As a challenge to the reader: How could you implement the Fibonacci function without using recursion?)&lt;br /&gt;
&lt;br /&gt;
=== Factorial Function ===&lt;br /&gt;
&lt;br /&gt;
Consider the factorial function, $n! = n * (n-1) * ... * 1$, with 0! defined as having a value of 1. We can define this recursively as follows: &lt;br /&gt;
&lt;br /&gt;
$$f(x)=\cases&lt;br /&gt;
{1 &amp;amp; if $x=0$\cr&lt;br /&gt;
x*f(x-1) &amp;amp; if $x\gt 0$\cr&lt;br /&gt;
}$$&lt;br /&gt;
&lt;br /&gt;
With this definition, the factorial of every non-negative integer can be found. &lt;br /&gt;
&lt;br /&gt;
Here is a Python implementation of the factorial function:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;def Factorial(x):&lt;br /&gt;
  if (x == 0) return 1&lt;br /&gt;
  return x * Factorial(x-1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Some Definitions ===&lt;br /&gt;
&lt;br /&gt;
A few definitions: &amp;#039;&amp;#039;Indirection recursion&amp;#039;&amp;#039; is when a function calls another function which eventually calls the original function. For example, A calls B, and then, before function B exits, function A is called (either by B or by a function that B calls). &amp;#039;&amp;#039;Single recursion&amp;#039;&amp;#039; is recursion with a single reference to itself, such as the factorial example above. &amp;#039;&amp;#039;Multiple recursion&amp;#039;&amp;#039;, illustrated by the Fibonacci number function, is when a function has multiple self references. &amp;#039;&amp;#039;Infinite recursion&amp;#039;&amp;#039; is a recursive function that never returns because it keeps calling itself. The program will eventually crash with an &amp;#039;&amp;#039;out of memory&amp;#039;&amp;#039; error message of some sort. &lt;br /&gt;
&lt;br /&gt;
This ACSL category focuses on mathematical recursive functions rather than programming algorithms.  While many mathematical functions can be done iteratively more efficiently than they can be done recursively, many algorithms in computer science must be written recursively.  The Tower of Hanoi which is referred to in one of the videos is a good example of this.  Another example is given in the sample problems below.&lt;br /&gt;
&lt;br /&gt;
== Sample Problems==&lt;br /&gt;
&lt;br /&gt;
This ACSL category focuses on mathematical recursive functions rather than programming procedures; but you’ll see some of the latter.&lt;br /&gt;
You will  typically  be asked to evaluate a recursive function for some specific value.   &lt;br /&gt;
It&amp;#039;s important that you are careful and neat.  Work  your  way  down  the  recursive  calls  until  there  are  no  more  calls,  and  then  work  your  way  back  up.  &lt;br /&gt;
 &lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Find $g(11)$ given the following &lt;br /&gt;
$$g(x)=\cases&lt;br /&gt;
{g(x-3)+1 &amp;amp; if $x&amp;gt;0$\cr&lt;br /&gt;
3x &amp;amp; otherwise\cr&lt;br /&gt;
}$$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The evaluation proceeds top-down as follows:&lt;br /&gt;
&lt;br /&gt;
$$\begin{align}&lt;br /&gt;
g(11)&amp;amp;=g(8)+1\cr&lt;br /&gt;
g(8)&amp;amp;=g(5)+1\cr&lt;br /&gt;
g(5)&amp;amp;=g(2)+1\cr&lt;br /&gt;
g(2)&amp;amp;=g(-1)+1\cr&lt;br /&gt;
g(-1)&amp;amp;=-3\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
We now use what we know about $g(-1)$ to learn more values, working our way back &amp;quot;up&amp;quot; the recursion:&lt;br /&gt;
:We now know the value of $g(2): g(2)=-3+1=-2$&lt;br /&gt;
:We now know the value of $g(5): g(5)= -2+1=-1$&lt;br /&gt;
:We now know the value of $g(8): g(8) = -1+1=0$&lt;br /&gt;
:And finally, we now have the value of $g(11): g(11)=0+1=1$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Find the value of $h(13)$ given the following definition of $h$:&lt;br /&gt;
&lt;br /&gt;
$$h(x)=\cases&lt;br /&gt;
{h(x-7)+1 &amp;amp; when $x&amp;gt;5$\cr&lt;br /&gt;
x &amp;amp; when $0 \le x \le 5$\cr&lt;br /&gt;
h(x+3) &amp;amp; when $x \lt 0$}$$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
$$\begin{align}&lt;br /&gt;
h(13) &amp;amp;= h(6)+1 &amp;amp; \text{top rule, since $x&amp;gt;5$}\cr&lt;br /&gt;
h(6) &amp;amp;= h(-1)+1 &amp;amp; \text{top rule, since $x&amp;gt;5$}\cr&lt;br /&gt;
h(-1)&amp;amp;= h(-1+3) =h(2)&amp;amp; \text{bottom rule, since $x&amp;lt;0$}\cr&lt;br /&gt;
h(2)&amp;amp;=2&amp;amp;\text{middle rule, since $0 \le x \le 5$}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
We now work our way back up the recursion, filling in values that have been computed.&lt;br /&gt;
&lt;br /&gt;
:$h(-1) = h(2) = 2$&lt;br /&gt;
:$h(6)=h(-1)+1 = 2+1=3$&lt;br /&gt;
:$h(13)=h(6)+1= 3+1=4$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Find the value of $f(12,6)$ given the following definition of $f$:&lt;br /&gt;
&lt;br /&gt;
$$f(x,y)=\cases&lt;br /&gt;
{f(x-y,y-1)+2 &amp;amp; when $x&amp;gt;y$\cr&lt;br /&gt;
x+y &amp;amp; otherwise}$$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
$$\begin{align}&lt;br /&gt;
f(12,6) &amp;amp;= f(6,5)+2 &amp;amp; \text{top rule, since $x&amp;gt;y$}\cr&lt;br /&gt;
f(6,5) &amp;amp;= f(1,4)+2 &amp;amp; \text{top rule, since $x&amp;gt;y$}\cr&lt;br /&gt;
f(1,4) &amp;amp;= 1+4 = 5&amp;amp; \text{bottom rule, since $x \le y$}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
We now work our way back up the recursion, filling in values that have been computed.&lt;br /&gt;
&lt;br /&gt;
:$f(12,6) = f(6,5) + 2 = f(1,4) + 2 + 2 = 5 + 2 + 2 = 9$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 4 ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Consider the following recursive algorithm for painting a square:&lt;br /&gt;
&lt;br /&gt;
1. Given a square.&lt;br /&gt;
2. If the length of a side is less than 2 feet, then stop.&lt;br /&gt;
3. Divide the square into 4 equal size squares (i.e., draw a “plus” sign inside the square).&lt;br /&gt;
4. Paint one of these 4 small squares.&lt;br /&gt;
5. Repeat this procedure (start at step 1) for each of the 3 unpainted squares.&lt;br /&gt;
&lt;br /&gt;
If this algorithm is applied to a square with a side of 16 feet (having a total area of 256 sq. feet), how many square feet will be painted?&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
In the first pass, we get four squares of side 8.&lt;br /&gt;
One is painted, three are unpainted.&lt;br /&gt;
Next, we have 3*4 squares of side 4.&lt;br /&gt;
Three are painted (area=3*4&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;), nine are not.&lt;br /&gt;
Next, we have 9*4 squares of side 2.&lt;br /&gt;
Nine are painted (area = 9*2&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;), 27 are not.&lt;br /&gt;
Finally, we have 27*4 squares of side 1.&lt;br /&gt;
Twenty-seven are painted.&lt;br /&gt;
Therefore, the total painted is 1*8&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; + 3*4&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; + 9*2&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; + 27*1&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; = 175.&lt;br /&gt;
&lt;br /&gt;
== Online Resources ==&lt;br /&gt;
&lt;br /&gt;
===ACSL===&lt;br /&gt;
&lt;br /&gt;
The following videos show the solution to problems that have appeared in previous ACSL contests. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/YinptBVZNFM&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/YinptBVZNFM &amp;quot;ACSL Math: Recursive Functions&amp;quot; (Quick Coding Bytes)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/OjZSIXStSr8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/OjZSIXStSr8 &amp;#039;&amp;#039;Recursion Example 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video walks through the solution to a straight-forward single-variable recursive function, that is, $f(x)=\cases{....}$ &lt;br /&gt;
The problem&lt;br /&gt;
appeared in ACSL Senior Division Contest #1, 2014-2015.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/MWdGTVCLI8g&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/MWdGTVCLI8g &amp;#039;&amp;#039;Recursion Example 2&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video walks through the solution to a 2-variable recursive function, that is, $f(x,y)=\cases{....}$ . The problem&lt;br /&gt;
appeared in ACSL Senior Division Contest #1, 2014-2015.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/5P5iK-5heEc&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/5P5iK-5heEc &amp;#039;&amp;#039;Recursive Functions ACSL Example Problem&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video walks through the solution to a 2-variable recursive function, that is, $f(x,y)=\cases{....}$ . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Videos===&lt;br /&gt;
&lt;br /&gt;
Because recursion is such a fundamental concept in computer science, there is no end to the number of YouTube videos that cover the topic. There are dozens of walk-throughs of the factorial and Fibonacci functions, and of other classic algorithms such as Towers of Hanoi and Binary Trees.&lt;br /&gt;
Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/LdNdfPhwCP4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/LdNdfPhwCP4 &amp;#039;&amp;#039;Recursion lecture 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;anim aland&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Prof. Alan Dorin from Monash University presents an wonderful introduction to recursion. The last part of the video uses factorial as an example. Taken note how his base case guards against infinite recursion.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/dxyYP3BSdcQ&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/dxyYP3BSdcQ &amp;#039;&amp;#039;Fibonacci Sequence - Anatomy of recursion and space complexity analysis&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;mycodeschool&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video is hand-simulation on the whiteboard of the recursive code for computing a Fibonnaci number. The code uses a base case of &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;if n&amp;lt;=1 return n&amp;lt;/syntaxhighlight&amp;gt; to prevent infinite recursion where the function called with a negative parameter.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/rVPuzFYlfYE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/rVPuzFYlfYE &amp;#039;&amp;#039;Towers of Hanoi&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Arnaldo Pedro Figueira Figueira&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A nice explanation of the Towers of Hanoi from MIT edX Course: [https://www.edx.org/course/subject/computer-science MITx: 6.00x Introduction to Computer Science and Programming].  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Prefix/Infix/Postfix_Notation&amp;diff=869</id>
		<title>Prefix/Infix/Postfix Notation</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Prefix/Infix/Postfix_Notation&amp;diff=869"/>
		<updated>2021-12-08T04:17:24Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Video Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The expression $5+\large{8\over{3-1}}$ clearly has a value of 9. It is written in &amp;#039;&amp;#039;infix&amp;#039;&amp;#039; notation as $5+8/(3-1)$. The value of an &amp;#039;&amp;#039;infix&amp;#039;&amp;#039; version is well-defined because there is a well-established order of precedence in mathematics: We first evaluate the parentheses (3-1=2); then, because division has higher precedence that subtraction, we next do 8/2=4. And finally, 5+4=9.  The order of precedence is often given the mnemonic of &amp;#039;&amp;#039;&amp;#039;Please excuse my dear Aunt Sue&amp;#039;&amp;#039;&amp;#039;, or &amp;#039;&amp;#039;&amp;#039;PEMDAS&amp;#039;&amp;#039;&amp;#039;: &amp;#039;&amp;#039;&amp;#039;p&amp;#039;&amp;#039;&amp;#039;arentheses, &amp;#039;&amp;#039;&amp;#039;e&amp;#039;&amp;#039;&amp;#039;xponentiation, &amp;#039;&amp;#039;&amp;#039;m&amp;#039;&amp;#039;&amp;#039;ultiplication/&amp;#039;&amp;#039;&amp;#039;d&amp;#039;&amp;#039;&amp;#039;ivision, and &amp;#039;&amp;#039;&amp;#039;a&amp;#039;&amp;#039;&amp;#039;ddition/&amp;#039;&amp;#039;&amp;#039;&amp;#039;s&amp;#039;&amp;#039;&amp;#039;ubtraction. Multiplication and division have the same level of precedence; addition and subtraction also have the same level of precedence. Terms with equals precedence are evaluated from left-to-right [https://en.wikipedia.org/wiki/Order_of_operations wikipedia].&lt;br /&gt;
&lt;br /&gt;
The algorithm to evaluate an &amp;#039;&amp;#039;infix&amp;#039;&amp;#039; expression is complex, as it must address the order of precedence. Two alternative notations have been developed which lend themselves to simple computer algorithms for evaluating expressions. In &amp;#039;&amp;#039;prefix&amp;#039;&amp;#039; notation, each operator is placed before its operands . The expression above would be &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;+ 5 / 8 - 3 1&amp;lt;/syntaxhighlight&amp;gt;. In &amp;#039;&amp;#039;postfix&amp;#039;&amp;#039; notation, each operator is placed after its operand. The expression above is &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;5 8 3 1 - / +&amp;lt;/syntaxhighlight&amp;gt;.  In &amp;#039;&amp;#039;prefix&amp;#039;&amp;#039; and &amp;#039;&amp;#039;postfix&amp;#039;&amp;#039; notations, there is no notion of order of precedence, nor are there any parentheses. The evaluation is the same regardless of the operators. &lt;br /&gt;
&lt;br /&gt;
Problems in this category ask to convert between prefix, infix, and postfix, or to evaluate an expression in prefix or postfix.&lt;br /&gt;
&lt;br /&gt;
== Converting Expressions ==&lt;br /&gt;
&lt;br /&gt;
An algorithm for converting from infix to prefix (postfix) is as follows:&lt;br /&gt;
* Fully parenthesize the infix expression.  It should now consist solely of “terms”:  a binary operator sandwiched between two operands.&lt;br /&gt;
* Write down the operands in the same order that they appear in the infix expression.&lt;br /&gt;
* Look at each term in the infix expression in the order that one would evaluate them, i.e., inner-most parenthesis to outer-most and left to right among terms of the same depth.&lt;br /&gt;
* For each term, write down the operand before (after) the operators.  &lt;br /&gt;
&lt;br /&gt;
One way to convert from prefix (postfix) to infix is to make repeated scans through the expression. &lt;br /&gt;
Each scan, find an operator with two adjacent operators and replace it with a parenthesized infix expression. &lt;br /&gt;
This is not the most efficient algorithm, but works well for a human.&lt;br /&gt;
&lt;br /&gt;
A quick check for determining whether a conversion is correct is to convert the result back into the original format.  &lt;br /&gt;
&lt;br /&gt;
== Context ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Prefix&amp;#039;&amp;#039; and &amp;#039;&amp;#039;postfix&amp;#039;&amp;#039; notation is also known as [https://en.wikipedia.org/wiki/Polish_notation &amp;#039;&amp;#039;Polish&amp;#039;&amp;#039; and &amp;#039;&amp;#039;Reverse Polish&amp;#039;&amp;#039; notation], respectively.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Infix to Prefix ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sequence of steps illustrates converting $X=\left(AB-{C\over{D}}\right)^E$ from infix to prefix:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!(X = (((A * B) - (C / D)) ↑ E)) &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot;  |X A B C D E	&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;* A B&amp;lt;/syntaxhighlight&amp;gt; C D E&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;* A B&amp;lt;/syntaxhighlight&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;/ C D&amp;lt;/syntaxhighlight&amp;gt; E&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;- * A B / C D&amp;lt;/syntaxhighlight&amp;gt; E&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; |  X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;↑-  * A B / C D E&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;= X ↑ - * A B / C D E&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Infix to Postfix ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sequence of steps illustrates converting $X=\left(AB-{C\over{D}}\right)^E$ from infix to postfix:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!(X = (((A * B) - (C / D)) ↑ E))&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot;  |X A B C D E	&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;A B *&amp;lt;/syntaxhighlight&amp;gt; C D E&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;A B *&amp;lt;/syntaxhighlight&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;C D /&amp;lt;/syntaxhighlight&amp;gt; E&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;A B * C D / -&amp;lt;/syntaxhighlight&amp;gt; E&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; |  X &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;A B * C D / - E ↑&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff; text-align: left; padding-left: 2em&amp;quot; | &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt; X A B * C D / - E ↑ =&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Prefix to Infix ===&lt;br /&gt;
&lt;br /&gt;
The following sequence of steps illustrates converting  $(3*4+{8\over{2}})^{(7-5)}$  from its prefix representation to infix:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! ↑ + * 3 4 / 8 2 – 7 5 &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; | ↑ + &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(3*4)&amp;lt;/syntaxhighlight&amp;gt; / 8 2 – 7 5&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; |↑ + &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(3*4)&amp;lt;/syntaxhighlight&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(8/2)&amp;lt;/syntaxhighlight&amp;gt; – 7 5&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; |↑ &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(3*4)+(8/2)&amp;lt;/syntaxhighlight&amp;gt; - 7 5&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; |↑ &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;((3*4)+(8/2))&amp;lt;/syntaxhighlight&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(7-5)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; |&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(((3*4)+(8/2))↑(7-5))&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Postfix to Infix ===&lt;br /&gt;
&lt;br /&gt;
The following sequence of steps illustrates converting  $(3*4+{8\over{2}})^{(7-5)}$  from its postfix representation to infix:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!3 4 * 8 2 / + 7 5 -↑&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; | &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(3*4)&amp;lt;/syntaxhighlight&amp;gt; 8 2 / + 7 5 - ↑&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; | &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(3*4)&amp;lt;/syntaxhighlight&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(8/2)&amp;lt;/syntaxhighlight&amp;gt; + 7 5 - ↑&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; | &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;((3*4)+(8/2))&amp;lt;/syntaxhighlight&amp;gt; 7 5 -↑ &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; | &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;((3*4)+(8/2))&amp;lt;/syntaxhighlight&amp;gt; &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(7-5)&amp;lt;/syntaxhighlight&amp;gt; ↑ &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #ffffff&amp;quot; |&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(((3*4)+(8/2))↑(7-5))&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some previous problems.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/lDm08rP_lms&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/lDm08rP_lms &amp;#039;&amp;#039;ACSL Prefix Postfix Infix Contest 2 Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Mr. Minich is an ACSL advisor. This video was created to help prepare his students for the ACSL Prefix/Infix/Postfix category. It shows solutions to 5 different problems that have&lt;br /&gt;
appeared in recent years. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/4YZdsw2UOpo&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/4YZdsw2UOpo &amp;#039;&amp;#039;Prefix Notation&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
To quote the video description: &amp;#039;&amp;#039;A general tutorial on prefix notation that can be used for American Computer Science League.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/R-t9-rbJDw8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/R-t9-rbJDw8 &amp;#039;&amp;#039;Postfix Notation&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
To quote the video description: &amp;#039;&amp;#039;A general tutorial on postfix notation that can be used for American Computer Science League.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/dcc-nXY2L6c&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/dcc-nXY2L6c &amp;#039;&amp;#039;2015 16 Contest 2 Prefix Infix Postfix Problem#1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Ravi Yeluru&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Ravi Yeluru walks through the solution to an ACSL Prefix/Infix/Postfix program that appeared in the 2015-16 year, Contest #2.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/lEIPvUqstEY&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/lEIPvUqstEY &amp;#039;&amp;#039;2015 16 Contest 2 Prefix Infix Postfix Problem#2&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Ravi Yeluru&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Ravi Yeluru walks through the solution to an ACSL Prefix/Infix/Postfix program that appeared in the 2015-16 year, Contest #2.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Other Videos ===&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos cover various aspects of this topic; they were created by authors who are not involved (or aware) of ACSL, to the best of our knowledge. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/t7YWDiz8LMY&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/t7YWDiz8LMY &amp;#039;&amp;#039;Infix Postfix and Prefix Notation&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carleton Moore&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A very gentle overview of infix, prefix, and postfix.&lt;br /&gt;
 &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/z3VsmufB_QI&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/z3VsmufB_Q I&amp;#039;&amp;#039;Infix Prefix and Postfix&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;University Academy&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Another very gentle overview of infix, prefix, and postfix.&lt;br /&gt;
 &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jos1Flt21is&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jos1Flt21is &amp;#039;&amp;#039;Infix Postfix and Prefix Notation&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;mycodeschool&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Another overview of infix, prefix, and postfix notations.&lt;br /&gt;
 &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/MeRb_1bddWg&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/MeRb_1bddWg &amp;#039;&amp;#039;Evaluation of Prefix and Postfix expressions using stack&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;mycodeschool&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Describes the standard algorithm to evaluate prefix and postfix expressions.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/vq-nUF0G4fI&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/vq-nUF0G4fI &amp;#039;&amp;#039;Infix to Postfix using stack&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;mycodeschool&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Describes the standard algorithm to convert from infix to postfix. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;URL&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [URL &amp;#039;&amp;#039;TITLE&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;AUTHOR&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Graph_Theory&amp;diff=868</id>
		<title>Graph Theory</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Graph_Theory&amp;diff=868"/>
		<updated>2021-12-08T04:16:32Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Other Videos */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Many problems are naturally formulated in terms of points and connections between them.  For example, a computer network has PCs connected by cables, an airline map has cities connected by routes, and a school has rooms connected by hallways.  A graph is a mathematical object which models such situations.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;graph&amp;#039;&amp;#039; is a collection of vertices and edges.  An &amp;#039;&amp;#039;edge&amp;#039;&amp;#039; is a connection between two &amp;#039;&amp;#039;vertices&amp;#039;&amp;#039; (sometimes referred to as &amp;#039;&amp;#039;nodes&amp;#039;&amp;#039;).  One can draw a graph by marking points for the vertices and drawing lines connecting them for the edges, but the graph is defined independently of the visual representation.  For example, the following two drawings represent the same graph:&lt;br /&gt;
&lt;br /&gt;
::[[File:Graph fig1a.svg|150px]] &amp;lt;span style=&amp;quot;display:inline-block; width: 5em;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[File:Graph fig1b.svg|150px]]&lt;br /&gt;
&lt;br /&gt;
The precise way to represent this graph is to identify its set of vertices {A, B, C, D, E, F, G}, and its set of edges between these vertices {AB, AD, BD, CF, FG, GH, GE, HE}.&lt;br /&gt;
&lt;br /&gt;
== Terminology ==&lt;br /&gt;
&lt;br /&gt;
The edges of the above graph have no directions meaning that the edge from one vertex A to another vertex B is the same as from vertex B to vertex A. Such a graph is called an &amp;#039;&amp;#039;undirected graph&amp;#039;&amp;#039;. Similarly, a graph having a direction associated with each edge is known as a &amp;#039;&amp;#039;directed graph&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;path&amp;#039;&amp;#039; from vertex x to y in a graph is a list of vertices, in which successive vertices are connected by edges in the graph.  For example, FGHE is path from F to E in the graph above.  A &amp;#039;&amp;#039;simple path&amp;#039;&amp;#039; is a path with no vertex repeated.  For example, FGHEG is not a simple path.  &lt;br /&gt;
&lt;br /&gt;
A graph is &amp;#039;&amp;#039;connected&amp;#039;&amp;#039; if there is a path from every vertex to every other vertex in the graph.  Intuitively, if the vertices were physical objects and the edges were strings connecting them, a connected graph would stay in one piece if picked up by any vertex.  A graph which is not connected is made up of &amp;#039;&amp;#039;connected components&amp;#039;&amp;#039;.  For example, the graph above has two connected components: {A, B, D} and {C, E, F, G, H}.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;cycle&amp;#039;&amp;#039; is a path, which is simple except that the first and last vertex are the same (a path from a point back to itself).  For example, the path HEGH is a cycle in our example.  Vertices must be listed in the order that they are traveled to make the path; any of the vertices may be listed first.  Thus, HEGH and EHGE are different ways to identify the same cycle.  For clarity, we list the start / end vertex twice: once at the start of the cycle and once at the end.&lt;br /&gt;
&lt;br /&gt;
We’ll denote the number of vertices in a given graph by V and the number of edges by E.  Note that E can range anywhere from $V$ to $V^2$ (or $V(V-1)/2$ in an undirected graph).  Graphs with all edges present are called &amp;#039;&amp;#039;complete graphs&amp;#039;&amp;#039;; graphs with relatively few edges present (say less than $V log(V)$) are called &amp;#039;&amp;#039;sparse&amp;#039;&amp;#039;; graphs with relatively few edges missing are called &amp;#039;&amp;#039;dense.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== Directed Graphs ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Directed graphs&amp;#039;&amp;#039; are graphs which have a direction associated with each edge.  An edge xy in a directed graph can be used in a path that goes from x to y but not necessarily from y to x.  For example, a directed graph similar to our example graph is drawn below:&lt;br /&gt;
&lt;br /&gt;
[[File:Graph fig1a directed.svg|150px]]&lt;br /&gt;
&lt;br /&gt;
This graph is defined as the set of vertices V = {A,B,C,D,E,F,G,H} and the set of edges {AB,AD,DA,DB,EG,GE,HG,HE,GF,CF,FC}.  There is one directed path from G to C (namely, GFC); however, there are no directed paths from C to G.  Note that a few of the edges have arrows on both ends, such as the edge between A and D.  These dual arrows indicate that there is an edge in each direction, which essentially makes an undirected edge.  An &amp;#039;&amp;#039;undirected graph&amp;#039;&amp;#039; can be thought of as a directed graph with all edges occurring in pairs in this way.  A directed graph with no cycles is called a &amp;#039;&amp;#039;dag&amp;#039;&amp;#039; (directed acyclic graph).&lt;br /&gt;
&lt;br /&gt;
== Trees &amp;amp; Forests ==&lt;br /&gt;
&lt;br /&gt;
A graph with no cycles is called a &amp;#039;&amp;#039;tree&amp;#039;&amp;#039;.  There is only one path between any two nodes in a tree.  A tree with $N$ vertices contains exactly $N-1$ edges.&lt;br /&gt;
&lt;br /&gt;
[[File:forest.png|500px]]&lt;br /&gt;
&lt;br /&gt;
The two graphs shown above are trees because neither has any cycles and all vertices are connected. The graph &lt;br /&gt;
on the left has 4 vertices and 3 edges; the graph on the right has 8 vertices and 7 edges. Note that in both cases, because they &lt;br /&gt;
are trees,  &lt;br /&gt;
the number of edges is one less than the number of vertices. &lt;br /&gt;
&lt;br /&gt;
A group of disconnected trees is called a &amp;#039;&amp;#039;forest&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;weighted graph&amp;#039;&amp;#039; is a graph that has a weight (also referred to as a cost) associated with each edge. &lt;br /&gt;
For example, in a graph &lt;br /&gt;
used by airlines where cities are vertices and edges are cities with direct flights connecting them,&lt;br /&gt;
the weight for each edge might be the distance between the cities. &lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;spanning tree&amp;#039;&amp;#039; of a graph is a subgraph that contains all the vertices and forms a tree.  &lt;br /&gt;
A &amp;#039;&amp;#039;minimal spanning tree&amp;#039;&amp;#039;&lt;br /&gt;
can be found for weighted graphs&lt;br /&gt;
in order to minimize the cost across an entire network.&lt;br /&gt;
&lt;br /&gt;
== Adjacency Matrices ==&lt;br /&gt;
&lt;br /&gt;
It is frequently convenient to represent a graph by a matrix known as an &amp;#039;&amp;#039;adjacency matrix.&amp;#039;&amp;#039;  Consider&lt;br /&gt;
the following directed graph:&lt;br /&gt;
&lt;br /&gt;
[[File:DirectedGraph.png|200px]]&lt;br /&gt;
&lt;br /&gt;
To draw the adjacency matrix, we create an $N$ by $N$ grid and label the rows and columns for each vertex (diagram at the left). Then, place a 1 for each edge in the cell whose row and column correspond to the&lt;br /&gt;
starting and ending vertices of the edge (diagram in the middle). Finally, place  &lt;br /&gt;
a 0 in all other cells (diagram at the right).  &lt;br /&gt;
&lt;br /&gt;
[[File:AdjMatrix.png|600px]]&lt;br /&gt;
&lt;br /&gt;
By construction, cell $(i,j)$ in the matrix with a value of 1 indicates a direct path from vertex $i$ to vertex $j$. &lt;br /&gt;
If we square the &lt;br /&gt;
matrix, the value in cell $(i,j)$ indicates the number of paths of length 2 from vertex $i$ to vertex $j$.&lt;br /&gt;
&lt;br /&gt;
[[File:AdjMatrix2.png|250px]]&lt;br /&gt;
&lt;br /&gt;
For example, the $M^2$ says that there 2 paths of length 2 from A to C (A → B → C and A → D → C).  This also says that there is exactly 1 path of length 2 from A to D (A → B → D), exactly 1 path of length 2 from B to B (B → C → B), and so on.&lt;br /&gt;
&lt;br /&gt;
In general, if we raise $M$ to the &amp;#039;&amp;#039;pth&amp;#039;&amp;#039; power, the resulting matrix indicates which paths of length $p$ exist in the graph. &lt;br /&gt;
The value in $M^p(i,j)$ is the number of paths from vertex $i$ to vertex $j$.&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Find the number of different cycles contained in the directed graph with vertices {A, B, C, D, E} and edges {AB, BA, BC, CD, DC, DB, DE}.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The graph is as follows:&lt;br /&gt;
&lt;br /&gt;
::[[File:graph sample1.svg|196px]]&lt;br /&gt;
&lt;br /&gt;
By inspection, the cycles are: ABA, BCDB, and CDC.  Thus, there are 3 cycles in the graph.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Given the directed graph below, how many more paths of length 3 would exist if edges AE and EA were added?&lt;br /&gt;
&lt;br /&gt;
[[File:graph_s1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
By using adjacency matrices, the current one is&lt;br /&gt;
&lt;br /&gt;
[[File:matrix1_s2.png]]&lt;br /&gt;
&lt;br /&gt;
After adding edges AE and EA, the matrices are:&lt;br /&gt;
&lt;br /&gt;
[[File:matrix2_s2.png]]&lt;br /&gt;
&lt;br /&gt;
There are 6 more paths of length 2 since 16 – 10 = 6.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2===&lt;br /&gt;
&lt;br /&gt;
In the following directed graph, find the total number of different paths from vertex A to vertex C of length 2 or 4.&lt;br /&gt;
&lt;br /&gt;
::[[File:graph sample3.svg|128px]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Let matrix $M$ represent the graph.  Recall that the number of paths from vertex $i$ to vertex $j$ of length $p$ equals $M^p[i,j]$.  The values of $M$, $M^2$ and $M^4$ are:&lt;br /&gt;
&lt;br /&gt;
[[File:matrix_s3.png]]&lt;br /&gt;
&lt;br /&gt;
There is 1 path of length 2 from A to C (cell [1,3] in $M^2$).  By inspection, the only path of length 2 is A → A → C.&lt;br /&gt;
&lt;br /&gt;
There are 3 paths of length 4 (cell [1,3] in $M^4$) and they are A → A → A → A → C, A → A → C → A → C, A → C → A → A → C.&lt;br /&gt;
&lt;br /&gt;
=== Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
Given the adjacency matrix, draw the directed graph.&lt;br /&gt;
&lt;br /&gt;
[[File:matrix_s4.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
There must be exactly 4 vertices:  V = {A, B, C, D}. There must be be exactly 7 edges: E = {AB, AD, BA, BD, CA, DB, DC}.  Here are two valid drawings of the graph:&lt;br /&gt;
&lt;br /&gt;
: [[File:Graph sample4soln-a.svg|128px]] &amp;lt;span style=&amp;quot;display:inline-block; width: 5em;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[File:Graph sample4soln-d.svg|128px]]&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
===ACSL Videos===&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/pWCuRRqBGvw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/pWCuRRqBGvw &amp;#039;&amp;#039;ACSL Math: Graph Theory&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Raj Joshi&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/H96Lo2q_FSk&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/H96Lo2q_FSk &amp;#039;&amp;#039;ACSL - Graph Theory Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Shows the solution to the ACSL problem: &amp;#039;&amp;#039;&amp;#039;Draw the directed graph with vertices A, B, C, D, E and the directed edges AB, BC, AD, BC, DC, ED, and EA.&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/y1fdIb_oNG0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/y1fdIb_oNG0 &amp;#039;&amp;#039;ACSL Graph Theory Worksheet 3&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Shows the solution to an ACSL problem asking to find how many paths of a specific length there are in a specific directed graph.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/vtTCRMGB0K8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/vtTCRMGB0K8 &amp;#039;&amp;#039;Graph Theory ACSL Example Problem&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Shows the solution to an ACSL problem asking to find how many different cycles there are from a specific vertex in a specific directed graph.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/ivhOH6crQ1w&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/ivhOH6crQ1w &amp;#039;&amp;#039;ACSL Test Prep - Graph Theory&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Mrs. Goopta&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A talked-over presentation discussing graph theory as needed for the American Computer Science League and its tests.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Other Videos===&lt;br /&gt;
&lt;br /&gt;
There are dozens of YouTube videos that provide an introduction to graph theory. The following are a couple that we found particularly well done.  Be aware that the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt; https://youtu.be/gXgEDyodOJU&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/gXgEDyodOJU &amp;#039;&amp;#039;Data structures: Introduction to Graphs&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;(mycodeschool)&amp;#039;&amp;#039;&amp;#039;]&lt;br /&gt;
&lt;br /&gt;
A nice introduction to the fundamental concepts of graphs. &lt;br /&gt;
 &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Boolean_Algebra&amp;diff=867</id>
		<title>Boolean Algebra</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Boolean_Algebra&amp;diff=867"/>
		<updated>2021-12-08T04:15:01Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Videos */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;Boolean algebra&amp;#039;&amp;#039; is the branch of algebra in which the values of the variables and constants have exactly two values: &amp;#039;&amp;#039;true&amp;#039;&amp;#039; and &amp;#039;&amp;#039;false&amp;#039;&amp;#039;, usually denoted 1 and 0 respectively. &lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
&lt;br /&gt;
The basic operators in Boolean algebra are &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039;. The secondary operators are &amp;#039;&amp;#039;eXclusive OR&amp;#039;&amp;#039; (often called &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039;) and &amp;#039;&amp;#039;eXclusive NOR&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;XNOR&amp;#039;&amp;#039;&amp;#039;, sometimes called &amp;#039;&amp;#039;&amp;#039;equivalence&amp;#039;&amp;#039;&amp;#039;). They are secondary in the sense that they &lt;br /&gt;
can be composed from the basic operators.&lt;br /&gt;
&lt;br /&gt;
*The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of two values is true only whenever both values are true. It is written as $xy$ or $x \cdot y$. The values of  &amp;#039;&amp;#039;and&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x  y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of two values is true whenever either or both values are true. It is written as $x+y$. The values of  &amp;#039;&amp;#039;or&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x + y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; of  a value is its opposite; that is, the &amp;#039;&amp;#039;not&amp;#039;&amp;#039; of a true value is false whereas the &amp;#039;&amp;#039;not&amp;#039;&amp;#039; of a false value is true. It is written as $\overline{x}$ or $\neg{x}$. The values of  &amp;#039;&amp;#039;not&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ \overline{x}\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of two values is true whenever the values are different.  It uses the $\oplus$ operator, and can be built from the basic operators: $x \oplus y = x \overline{y} + \overline{x} y$ The values of  &amp;#039;&amp;#039;xor&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x \oplus y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 0&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
*The &amp;#039;&amp;#039;&amp;#039;XNOR&amp;#039;&amp;#039;&amp;#039; of two values is true whenever the values are the same. It is the &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; of the &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; function. It uses the $\odot$ operator: $x \odot y = \overline{x \oplus y}$. The &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039; can be built from basic operators: $x \odot y = x  y + \overline{x}  \overline{y}$ The values of  &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x \odot y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 0&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 1&lt;br /&gt;
|} &lt;br /&gt;
 &lt;br /&gt;
Just as algebra has basic rules for simplifying and evaluating expressions, so does Boolean algebra.&lt;br /&gt;
&lt;br /&gt;
== Why is Boolean Algebra Important for ACSL Students? ==&lt;br /&gt;
&lt;br /&gt;
Boolean algebra is important to programmers, computer scientists, and the general population. &lt;br /&gt;
&lt;br /&gt;
*For programmers, Boolean expressions are used for conditionals and loops. For example, the following snippet of code sums the even numbers that are not also multiples of 3, stopping when the sum hits 100:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
s = 0&lt;br /&gt;
x = 1&lt;br /&gt;
while (s &amp;lt; 100):&lt;br /&gt;
    if (x % 2 == 0) and (x % 3 != 0)&lt;br /&gt;
        then s = s + x&lt;br /&gt;
    x = x + 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Both the conditional statement &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;s &amp;lt; 100&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
and the Boolean expression with 2 conditional statements  &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(x % 2 == 0) and (x % 3 != 0)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
evaluate to &amp;#039;&amp;#039;true&amp;#039;&amp;#039; or &amp;#039;&amp;#039;false&amp;#039;&amp;#039;. &lt;br /&gt;
&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*For computer scientists, Boolean algebra is the basis for digital circuits that make up a computer&amp;#039;s hardware. The [[Digital Electronics]] category concerns a graphical representation of a circuit. That circuit is typically easiest to understand and evaluate by converting it to its Boolean algebra representation. &lt;br /&gt;
 &lt;br /&gt;
* The general population uses Boolean algebra, probably without knowing that they are doing so, when they enter search terms in Internet search engines. For example, the search expression &amp;#039;&amp;#039;jaguar speed -car&amp;#039;&amp;#039; is parsed by the search engine as the Boolean expression &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;&amp;quot;jaguar&amp;quot; and &amp;quot;car&amp;quot; and not &amp;quot;speed&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;; it returns pages about the speed of the jaguar animal, not the Jaguar car.&lt;br /&gt;
&lt;br /&gt;
==Laws==&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;law&amp;#039;&amp;#039;&amp;#039; of Boolean algebra is an identity such as &amp;lt;math&amp;gt;x + (y + z) = (x + y) + z&amp;lt;/math&amp;gt;&lt;br /&gt;
between two Boolean terms, where a &amp;#039;&amp;#039;&amp;#039;Boolean term&amp;#039;&amp;#039;&amp;#039; is defined as an expression built up from variables,  the constants 0 and 1, and operations &amp;#039;&amp;#039;and&amp;#039;&amp;#039;, &amp;#039;&amp;#039;or&amp;#039;&amp;#039;, &amp;#039;&amp;#039;not&amp;#039;&amp;#039;, &amp;#039;&amp;#039;xor&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
Like ordinary algebra, parentheses are used to group terms. When a &amp;#039;&amp;#039;not&amp;#039;&amp;#039; is represented with an overhead horizontal line, there is an implicit grouping of the terms under the line. That is, $x \cdot \overline{y + z}$ is evaluated as if it were written $x \cdot \overline{(y + z)}.$&lt;br /&gt;
&lt;br /&gt;
=== Order of Precedence ===&lt;br /&gt;
&lt;br /&gt;
The order of operator precedence is &amp;#039;&amp;#039;not&amp;#039;&amp;#039;; then &amp;#039;&amp;#039;and&amp;#039;&amp;#039;; then &amp;#039;&amp;#039;xor&amp;#039;&amp;#039; and &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039;; and finally &amp;#039;&amp;#039;or&amp;#039;&amp;#039;. Operators with the same level of precedence are evaluated from left-to-right. &lt;br /&gt;
 &lt;br /&gt;
=== Fundamental Identities ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Commutative Law – The order of application of two separate terms is not important. || $x+y = y+x$ || $x \cdot y = y \cdot x$ &lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Associative Law – Regrouping of the terms in an expression doesn&amp;#039;t change the value of the expression. ||$(x + y) + z$ = $x + (y + z)$ || $x \cdot (y \cdot z) = (x \cdot y) \cdot z$ &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Idempotent Law – A term that is &amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039;´ed or &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with itself is equal to that term. || $ x +x = x $ || $x \cdot x = x$&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Annihilator Law – A term that is &amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039;´ed with 1 is 1; a term &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with 0 is 0. || $x + 1 = 1$ || $ x \cdot 0 = 0 $ &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Identity Law – A term &amp;#039;&amp;#039;or&amp;#039;&amp;#039;´ed 0 or  &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with a 1 will always equal that term. || $x + 0 = x$  || $x \cdot 1 = x$&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Complement Law – A term &amp;#039;&amp;#039;or&amp;#039;&amp;#039;´ed with its complement equals 1 and a term &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with its complement equals 0. || $x + \overline{x} = 1 $ || $x \cdot \overline{x} = 0$&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Absorptive Law – Complex expressions can be reduced to a simpler ones by absorbing like terms. ||colspan=2|&lt;br /&gt;
$x+x  y = x$&lt;br /&gt;
&lt;br /&gt;
$ x +\overline{x}y = x + y $&lt;br /&gt;
&lt;br /&gt;
$x  (x+y) = x$&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Distributive Law – It&amp;#039;s OK to multiply or factor-out an expression.||colspan=2|&lt;br /&gt;
&lt;br /&gt;
$x \cdot (y + z) = xy + xz$&lt;br /&gt;
&lt;br /&gt;
$(x+y) \cdot (p + q) = xp + xq +yp + yq$&lt;br /&gt;
&lt;br /&gt;
$(x+y)(x+z)=x + yz $&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | DeMorgan&amp;#039;s Law – An &amp;#039;&amp;#039;or&amp;#039;&amp;#039; (&amp;#039;&amp;#039;and&amp;#039;&amp;#039;) expression that is negated is equal to the &amp;#039;&amp;#039;and&amp;#039;&amp;#039; (&amp;#039;&amp;#039;or&amp;#039;&amp;#039;) of the negation of each term.|| $\overline{x+y} = \overline{x} \cdot \overline{y}$||$\overline{x \cdot y} = \overline{x} + \overline{y}$&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Double Negation – A term that is inverted twice is equal to the original term.||colspan=2| $\overline{\overline{x}} = x $ &lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Relationship between XOR and XNOR|| colspan=2 | $ x\odot y = \overline{x\oplus y} = x \oplus \overline{y} =\overline{x} \oplus {y}$ &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
Problems in this category are typically of the form &amp;quot;Given a Boolean expression, simplify it as much as possible&amp;quot; or &amp;quot;Given a Boolean expression,&lt;br /&gt;
find the values of all possible inputs that make the expression &amp;#039;&amp;#039;true&amp;#039;&amp;#039;.&amp;quot;  Simplify means writing an equivalent expression using the fewest number of operators.&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: Simplify the Expression ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Simplify the following expression as much as possible:&lt;br /&gt;
$ \overline{ \overline{A(A+B)} + B\overline{A}}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The simplification proceeds as follows:&lt;br /&gt;
&lt;br /&gt;
:$\overline{ \overline{A(A+B)} + B\overline{A}}$&lt;br /&gt;
::{| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  &amp;lt;math&amp;gt;= \left(\overline{ \overline{A(A+B)}}\right) \cdot \left(\overline{ B\overline{A}}\right)&amp;lt;/math&amp;gt; ||&lt;br /&gt;
|  (DeMorgan&amp;#039;s Law)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;= \left(A(A+B)\right) \cdot \left( \overline{B}+\overline{\overline{A}}\right)&amp;lt;/math&amp;gt; ||&lt;br /&gt;
|  (Double Negation; DeMorgan&amp;#039;s Law)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;= A \cdot \left( \overline{B}+A\right)&amp;lt;/math&amp;gt; ||&lt;br /&gt;
|  (Absorption; Double Negation)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;=A&amp;lt;/math&amp;gt;  || &lt;br /&gt;
| (Absorption)&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Find Solutions ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Find all orderd pairs $(A,B)$ that make the following expression &amp;#039;&amp;#039;true&amp;#039;&amp;#039;:&lt;br /&gt;
$ \overline{ \overline{(A+B)} + \overline{A}B }$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
There are typically two approaches to solving this type of problem. One approach is to simplify the expression as much as possible, until&lt;br /&gt;
it&amp;#039;s obvious what the solutions are. The other approach is to create a truth table of all possible inputs, with columns for each subexpression.&lt;br /&gt;
&lt;br /&gt;
The simplification approach is as following:&lt;br /&gt;
:$ \overline{\overline{(A+B)} + \overline{A}B}$&lt;br /&gt;
::$= \overline{\overline{A+B}} \cdot \overline{\overline{A}B}$ &lt;br /&gt;
::$= (A+B) \cdot (\overline{\overline{A}}+\overline{B} ) $ &lt;br /&gt;
::$= (A+B) \cdot (A+\overline{B}) $ &lt;br /&gt;
::$= AA + A\overline{B} + BA + B\overline{B} $ &lt;br /&gt;
::$= A + A(\overline{B} + B) + 0 $ &lt;br /&gt;
::$= A + A(1)$ &lt;br /&gt;
::$= A + A$ &lt;br /&gt;
::$=A$&lt;br /&gt;
This means that all inputs are valid whenever $A$ is &amp;#039;&amp;#039;true&amp;#039;&amp;#039;: $(1,0)$ and $(1,1)$&lt;br /&gt;
&lt;br /&gt;
The truth table approach is as following. Each column is the result of a basic operation on two other columns. &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#1&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#2&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#3 &lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#4&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#5&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#6&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#7&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#8&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff&amp;quot;|&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff&amp;quot;|&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |OR of Col#1, Col#2&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |NOT of Col#3&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |NOT of Col#1&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |ADD of Col#1, Col#2&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |OR of Col#4, Col#6&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |NOT of Col#7 &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;A+B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A+B}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A}B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A+B} + \overline{A}B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{\overline{A+B} + \overline{A}B}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
!0&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
!0&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
!1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
!1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The rightmost column is the expression we are solving; it is &amp;#039;&amp;#039;true&amp;#039;&amp;#039; for the 3rd and 4th rows, where the inputs are $(1,0)$ and $(1,1)$.&lt;br /&gt;
&lt;br /&gt;
== Online Resources ==&lt;br /&gt;
&lt;br /&gt;
===Websites===&lt;br /&gt;
A great online tutorial on Boolean Algebra is part of [https://ryanstutorials.net/boolean-algebra-tutorial/ Ryan&amp;#039;s Tutorials]. There are many online Boolean Calculators.  This one gives Truth Tables [https://sheabunge.github.io/boolcalc/ calculator ]. This link that has ads also simplifies and uses ! for NOT [https://www.boolean-algebra.com/ calculator].&lt;br /&gt;
&lt;br /&gt;
===Videos===&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some previous problems. To access the YouTube page with the video, click on the title of the video in the icon. (You can also play the video directly by clicking on the arrow in the center of the image; however, you&amp;#039;ll &lt;br /&gt;
probably want to have a larger viewing of the video since it contains writing on a whiteboard.) Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/HJdhEjpVYsY&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/HJdhEjpVYsY &amp;#039;&amp;#039;ACSL Boolean Algebra Contest 2 Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Mr. Minich is an ACSL advisor. This video was one of two he created to help prepare his students for the ACSL Boolean algebra category. It shows solutions to 5 different problems that have&lt;br /&gt;
appeared in recent years. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/4io6xgz8Zwk&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/4io6xgz8Zwk &amp;#039;&amp;#039;ACSL Boolean Algebra Contest 2 Worksheet 2&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;) ]&lt;br /&gt;
&lt;br /&gt;
Mr. Minich is an ACSL advisor. This video was one of two he created to help prepare his students for the ACSL Boolean algebra category. It shows solutions to 5 different problems that have&lt;br /&gt;
appeared in recent years. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/6vI1mO1XOjQ&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/6vI1mO1XOjQ &amp;#039;&amp;#039;ACSL 3 13-14 #1 - AM&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Gordon Campbell&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video walks through the solution to finding all ordered triples that make the following&lt;br /&gt;
Boolean expression &amp;#039;&amp;#039;true&amp;#039;&amp;#039;:&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
(AB+\overline{C})(\overline{A}+BC)(A+\overline{B}+C)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
This problem appeared in 2013-2014 in the Senior Division, Contest #3.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/KRKTbAZYlLM&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/KRKTbAZYlLM &amp;#039;&amp;#039;ACSL 3 #1 14-15 - AM&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Gordon Campbell&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video walks through the simplification of the expression:&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
\overline{(\overline{A}+B)}(B+C)\overline{(A+\overline{C})}(A\overline{B}+BC)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
This problem appeared in 2014-2015 in the Senior Division, Contest #3.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jDnni-zm2g8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jDnni-zm2g8 &amp;#039;&amp;#039;A general tutorial on boolean algebra that can be used for American Computer Science League.&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Walks through the simplification of the following Boolean expression:&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
\overline{ (\overline{A + \overline{B}})(AB)} +&lt;br /&gt;
\overline{ (A+B)(\overline{\overline{A}B})}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Bit-String_Flicking&amp;diff=866</id>
		<title>Bit-String Flicking</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Bit-String_Flicking&amp;diff=866"/>
		<updated>2021-12-08T04:13:54Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Video Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Bit strings (strings of binary digits) are frequently manipulated bit-by-bit using the logical operators  &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039;. Bits strings are manipulated as a unit using &amp;#039;&amp;#039;&amp;#039;SHIFT&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;CIRCULATE&amp;#039;&amp;#039;&amp;#039; operators. The bits on the left are called the &amp;#039;&amp;#039;most significant bits&amp;#039;&amp;#039; and those on the right are the &amp;#039;&amp;#039;least significant bits&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Most high-level languages (e.g., Python, Java, C++), support bit-string operations. Programmers typically use bit strings to maintain a set of flags.  Suppose that a program supports 8 options, each of which can be either “on” or “off”.  One could maintain this information using an array of size 8, or one could use a single variable (if it is internally stored using at least 8 bits or 1 byte, which is usually the case) and represent each option with a single bit.  In addition to saving space, the program is often cleaner if a single variable is involved rather than an array.  Bits strings are often used to maintain a set where values are either in the set or not. Shifting of bits is also used to multiply or divide by powers of 2.&lt;br /&gt;
&lt;br /&gt;
Mastering this topic is essential for systems programming, programming in assembly language, optimizing code, and hardware design.&lt;br /&gt;
&lt;br /&gt;
== Operators==&lt;br /&gt;
&lt;br /&gt;
=== Bitwise Operators ===&lt;br /&gt;
&lt;br /&gt;
The logical operators are  &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; (~ or $\neg$), &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; (&amp;amp;), &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; (|), and &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; ($\oplus$). These operators should be familiar to ACSL students from the [[Boolean Algebra]] and [[Digital Electronics]] categories.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; is a unary operator that performs logical negation on each bit. Bits that are 0 become 1, and those that are 1 become 0. For example: ~101110 has a value of 010001.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands.  The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of two values is 1 only if both values are 1. For example, &amp;#039;&amp;#039;&amp;#039;1011011 and 011001&amp;#039;&amp;#039;&amp;#039; has a value of &amp;#039;&amp;#039;&amp;#039;001001&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; function is often used to isolate the value of a bit in a bit-string or to clear the value of a bit in a bit-string.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands. The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of two values is 1 only if one or both values are 1. For example, &amp;#039;&amp;#039;&amp;#039;1011011 or 0011001&amp;#039;&amp;#039;&amp;#039; has a value of &amp;#039;&amp;#039;&amp;#039;1011011&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; function is often use to force the value of a bit in a bit-string to be 1, if it isn&amp;#039;t already.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands. The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of two values is 1 if the values are different and 0 if they are the same. For example, &amp;#039;&amp;#039;&amp;#039;1011011 xor 011001 = 110010&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; function is often used to change the value of a particular bit.&lt;br /&gt;
&lt;br /&gt;
All binary operators (AND, OR, or XOR) must operate on bit-strings that are of the same length. If the operands are not the same length, the shorter one is padded with 0&amp;#039;s on the left as needed. For example, &amp;#039;&amp;#039;&amp;#039;11010 and 1110&amp;#039;&amp;#039;&amp;#039; would have value of &amp;#039;&amp;#039;&amp;#039;11010 and 01110 = 01010&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The following table summarizes the operators:&lt;br /&gt;
&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
! &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;and&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;xor&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Shift Operators ===&lt;br /&gt;
&lt;br /&gt;
Logical shifts (LSHIFT-x and RSHIFT-x) “ripple” the bit-string x positions in the indicated direction, either to the left or to the right.  Bits shifted out are lost; zeros are shifted in at the other end.   &lt;br /&gt;
&lt;br /&gt;
Circulates (RCIRC-x and LCIRC-x) “ripple” the bit string x positions in the indicated direction.  As each bit is shifted out one end, it is shifted in at the other end. The effect of this is that the bits remain in the same order on the other side of the string.&lt;br /&gt;
&lt;br /&gt;
The size of a bit-string  does not change with shifts, or circulates.  If any bit strings are initially of different lengths, all shorter ones are padded with zeros in the left bits until all strings are of the same length.  &lt;br /&gt;
&lt;br /&gt;
The following table gives some examples of these operations:&lt;br /&gt;
&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: right&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!x&lt;br /&gt;
!(LSHIFT-2 x)&lt;br /&gt;
!(RSHIFT-3 x)&lt;br /&gt;
!(LCIRC-3 x)&lt;br /&gt;
!(RCIRC-1 x)&lt;br /&gt;
|-&lt;br /&gt;
!01101&lt;br /&gt;
| 10100&lt;br /&gt;
| 00001&lt;br /&gt;
| 01011&lt;br /&gt;
| 10110&lt;br /&gt;
|-&lt;br /&gt;
!10&lt;br /&gt;
| 00&lt;br /&gt;
| 00&lt;br /&gt;
| 01&lt;br /&gt;
| 01&lt;br /&gt;
|-&lt;br /&gt;
!1110&lt;br /&gt;
| 1000&lt;br /&gt;
| 0001&lt;br /&gt;
| 0111&lt;br /&gt;
| 0111&lt;br /&gt;
|-&lt;br /&gt;
!1011011&lt;br /&gt;
| 1101100&lt;br /&gt;
| 0001011&lt;br /&gt;
| 1011101&lt;br /&gt;
| 1101101&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Order of Precedence ===&lt;br /&gt;
&lt;br /&gt;
The order of precedence (from highest to lowest) is: NOT; SHIFT and CIRC; AND; XOR; and finally, OR.  In other words, all unary operators are performed on a single operator first.  Operators with equal precedence are evaluated left to right; all unary  operators bind from right to left.&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression: &lt;br /&gt;
:(101110 AND NOT 110110 OR (LSHIFT-3 101010))&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The expression evaluates as follows:&lt;br /&gt;
:(101110 AND &amp;#039;&amp;#039;&amp;#039;001001&amp;#039;&amp;#039;&amp;#039; OR (LSHIFT-3 101010))&lt;br /&gt;
:(&amp;#039;&amp;#039;&amp;#039;001000&amp;#039;&amp;#039;&amp;#039; OR (LSHIFT-3 101010))&lt;br /&gt;
:(001000 OR &amp;#039;&amp;#039;&amp;#039;010000&amp;#039;&amp;#039;&amp;#039;)&lt;br /&gt;
:&amp;#039;&amp;#039;&amp;#039;011000&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression: &lt;br /&gt;
:(RSHIFT-1 (LCIRC-4 (RCIRC-2 01101))) &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The expression evaluates as follows, starting at the innermost parentheses:&lt;br /&gt;
:(RCIRC-2 01101) =&amp;gt; 01011&lt;br /&gt;
:(LCIRC-4 01011) =&amp;gt; 10101&lt;br /&gt;
:(RSHIFT-1 10101) = 01010&lt;br /&gt;
&lt;br /&gt;
=== Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
List all possible values of x (5 bits long) that solve the following equation.&lt;br /&gt;
:(LSHIFT-1 (10110 XOR (RCIRC-3 x) AND 11011)) = 01100&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Since x is a string 5 bits long, represent it by abcde.&lt;br /&gt;
:(RCIRC-3 abcde) =&amp;gt; cdeab&lt;br /&gt;
:(cdeab AND 11011) =&amp;gt; cd0ab&lt;br /&gt;
:(10110 XOR cd0ab) =&amp;gt; Cd1Ab (the capital letter is the NOT of its lower case)&lt;br /&gt;
:(LSHIFT-1 Cd1Ab) =&amp;gt; d1Ab0&lt;br /&gt;
&lt;br /&gt;
So, d1Ab0 = 01100.&lt;br /&gt;
&lt;br /&gt;
Meaning, we must have d=0, A=1 (hence a=0), b=0.  Thus, the solution must be in the form 00*0*, where * is an “I-don’t-care”.  &lt;br /&gt;
&lt;br /&gt;
The four possible values of x are: 00000, 00001, 00100 and 00101.&lt;br /&gt;
&lt;br /&gt;
=== Problem 4 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression:&lt;br /&gt;
: ((RCIRC-14 (LCIRC-23 01101)) | (LSHIFT-1 10011) &amp;amp; (RSHIFT-2 10111))&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The problem can be rewritten as &lt;br /&gt;
: A | B &amp;amp; C&lt;br /&gt;
The AND has higher precedence than the OR.  &lt;br /&gt;
&lt;br /&gt;
The evaluation of expression A can be done in a straightforward way:  (LCIRC-23 01101) is the same as (LCIRC-3 01101) which has a value of 01011, and (RCIRC-14 01011) is the same as (RCIRC-4 01011) which has a value of 10110. Another strategy is to offset the left and right circulates.  So, ((RCIRC-14 (LCIRC-23 01101)) has the same value as (LCIRC-9 01101), which has the same value as (LCIRC-4 01101) which is also 11010.&lt;br /&gt;
&lt;br /&gt;
Expressions B and C are pretty easy to evaluate:&lt;br /&gt;
:B = (LSHIFT-1 10011) = 00110&lt;br /&gt;
:C = (RSHIFT-2 10111) = 00101&lt;br /&gt;
&lt;br /&gt;
The expression becomes&lt;br /&gt;
: A | B &amp;amp; C = 10110 | 00110 &amp;amp; 00101 = 10110 | 00100 = 10110&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/0U6ogoQ5Hkk&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/0U6ogoQ5Hkk &amp;quot;ACSL Math: Bit String Flicking&amp;quot; (Quick Coding Bytes)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IeMsD3harrE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IeMsD3harrE &amp;#039;&amp;#039;Bit String Flicking (Intro)&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A great two-part tutorial on this ACSL category. Part 1 covers bitwise operations AND, OR, NOT, and XOR. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jbKw8oYJPs4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jbKw8oYJPs4 &amp;#039;&amp;#039;Bit String Flicking Shifts and Circs&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Part 2 covers logical shifts and circulate operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/XNBcO25mgCw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/XNBcO25mgCw &amp;#039;&amp;#039;Bit String Flicking&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Shows the solution to the problem: (RSHIFT-3 (LCIRC-2 (NOT 10110)))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aa_lQ8gft60&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aa_lQ8gft60 &amp;#039;&amp;#039;ACSL BitString Flicking Contest 2 Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Solves a handful of problems given in previous years at the Intermediate Division level.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;URL&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [URL &amp;#039;&amp;#039;TITLE&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;AUTHOR&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Bit-String_Flicking&amp;diff=848</id>
		<title>Bit-String Flicking</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Bit-String_Flicking&amp;diff=848"/>
		<updated>2021-01-22T18:16:55Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Video Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Bit strings (strings of binary digits) are frequently manipulated bit-by-bit using the logical operators  &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039;. Bits strings are manipulated as a unit using &amp;#039;&amp;#039;&amp;#039;SHIFT&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;CIRCULATE&amp;#039;&amp;#039;&amp;#039; operators. The bits on the left are called the &amp;#039;&amp;#039;most significant bits&amp;#039;&amp;#039; and those on the right are the &amp;#039;&amp;#039;least significant bits&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Most high-level languages (e.g., Python, Java, C++), support bit-string operations. Programmers typically use bit strings to maintain a set of flags.  Suppose that a program supports 8 options, each of which can be either “on” or “off”.  One could maintain this information using an array of size 8, or one could use a single variable (if it is internally stored using at least 8 bits or 1 byte, which is usually the case) and represent each option with a single bit.  In addition to saving space, the program is often cleaner if a single variable is involved rather than an array.  Bits strings are often used to maintain a set where values are either in the set or not. Shifting of bits is also used to multiply or divide by powers of 2.&lt;br /&gt;
&lt;br /&gt;
Mastering this topic is essential for systems programming, programming in assembly language, optimizing code, and hardware design.&lt;br /&gt;
&lt;br /&gt;
== Operators==&lt;br /&gt;
&lt;br /&gt;
=== Bitwise Operators ===&lt;br /&gt;
&lt;br /&gt;
The logical operators are  &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; (~ or $\neg$), &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; (&amp;amp;), &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; (|), and &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; ($\oplus$). These operators should be familiar to ACSL students from the [[Boolean Algebra]] and [[Digital Electronics]] categories.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; is a unary operator that performs logical negation on each bit. Bits that are 0 become 1, and those that are 1 become 0. For example: ~101110 has a value of 010001.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands.  The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of two values is 1 only if both values are 1. For example, &amp;#039;&amp;#039;&amp;#039;1011011 and 011001&amp;#039;&amp;#039;&amp;#039; has a value of &amp;#039;&amp;#039;&amp;#039;001001&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; function is often used to isolate the value of a bit in a bit-string or to clear the value of a bit in a bit-string.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands. The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of two values is 1 only if one or both values are 1. For example, &amp;#039;&amp;#039;&amp;#039;1011011 or 0011001&amp;#039;&amp;#039;&amp;#039; has a value of &amp;#039;&amp;#039;&amp;#039;1011011&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; function is often use to force the value of a bit in a bit-string to be 1, if it isn&amp;#039;t already.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands. The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of two values is 1 if the values are different and 0 if they are the same. For example, &amp;#039;&amp;#039;&amp;#039;1011011 xor 011001 = 110010&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; function is often used to change the value of a particular bit.&lt;br /&gt;
&lt;br /&gt;
All binary operators (AND, OR, or XOR) must operate on bit-strings that are of the same length. If the operands are not the same length, the shorter one is padded with 0&amp;#039;s on the left as needed. For example, &amp;#039;&amp;#039;&amp;#039;11010 and 1110&amp;#039;&amp;#039;&amp;#039; would have value of &amp;#039;&amp;#039;&amp;#039;11010 and 01110 = 01010&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The following table summarizes the operators:&lt;br /&gt;
&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
! &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;and&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;xor&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Shift Operators ===&lt;br /&gt;
&lt;br /&gt;
Logical shifts (LSHIFT-x and RSHIFT-x) “ripple” the bit-string x positions in the indicated direction, either to the left or to the right.  Bits shifted out are lost; zeros are shifted in at the other end.   &lt;br /&gt;
&lt;br /&gt;
Circulates (RCIRC-x and LCIRC-x) “ripple” the bit string x positions in the indicated direction.  As each bit is shifted out one end, it is shifted in at the other end. The effect of this is that the bits remain in the same order on the other side of the string.&lt;br /&gt;
&lt;br /&gt;
The size of a bit-string  does not change with shifts, or circulates.  If any bit strings are initially of different lengths, all shorter ones are padded with zeros in the left bits until all strings are of the same length.  &lt;br /&gt;
&lt;br /&gt;
The following table gives some examples of these operations:&lt;br /&gt;
&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: right&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!x&lt;br /&gt;
!(LSHIFT-2 x)&lt;br /&gt;
!(RSHIFT-3 x)&lt;br /&gt;
!(LCIRC-3 x)&lt;br /&gt;
!(RCIRC-1 x)&lt;br /&gt;
|-&lt;br /&gt;
!01101&lt;br /&gt;
| 10100&lt;br /&gt;
| 00001&lt;br /&gt;
| 01011&lt;br /&gt;
| 10110&lt;br /&gt;
|-&lt;br /&gt;
!10&lt;br /&gt;
| 00&lt;br /&gt;
| 00&lt;br /&gt;
| 01&lt;br /&gt;
| 01&lt;br /&gt;
|-&lt;br /&gt;
!1110&lt;br /&gt;
| 1000&lt;br /&gt;
| 0001&lt;br /&gt;
| 0111&lt;br /&gt;
| 0111&lt;br /&gt;
|-&lt;br /&gt;
!1011011&lt;br /&gt;
| 1101100&lt;br /&gt;
| 0001011&lt;br /&gt;
| 1011101&lt;br /&gt;
| 1101101&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Order of Precedence ===&lt;br /&gt;
&lt;br /&gt;
The order of precedence (from highest to lowest) is: NOT; SHIFT and CIRC; AND; XOR; and finally, OR.  In other words, all unary operators are performed on a single operator first.  Operators with equal precedence are evaluated left to right; all unary  operators bind from right to left.&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression: &lt;br /&gt;
:(101110 AND NOT 110110 OR (LSHIFT-3 101010))&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The expression evaluates as follows:&lt;br /&gt;
:(101110 AND &amp;#039;&amp;#039;&amp;#039;001001&amp;#039;&amp;#039;&amp;#039; OR (LSHIFT-3 101010))&lt;br /&gt;
:(&amp;#039;&amp;#039;&amp;#039;001000&amp;#039;&amp;#039;&amp;#039; OR (LSHIFT-3 101010))&lt;br /&gt;
:(001000 OR &amp;#039;&amp;#039;&amp;#039;010000&amp;#039;&amp;#039;&amp;#039;)&lt;br /&gt;
:&amp;#039;&amp;#039;&amp;#039;011000&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression: &lt;br /&gt;
:(RSHIFT-1 (LCIRC-4 (RCIRC-2 01101))) &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The expression evaluates as follows, starting at the innermost parentheses:&lt;br /&gt;
:(RCIRC-2 01101) =&amp;gt; 01011&lt;br /&gt;
:(LCIRC-4 01011) =&amp;gt; 10101&lt;br /&gt;
:(RSHIFT-1 10101) = 01010&lt;br /&gt;
&lt;br /&gt;
=== Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
List all possible values of x (5 bits long) that solve the following equation.&lt;br /&gt;
:(LSHIFT-1 (10110 XOR (RCIRC-3 x) AND 11011)) = 01100&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Since x is a string 5 bits long, represent it by abcde.&lt;br /&gt;
:(RCIRC-3 abcde) =&amp;gt; cdeab&lt;br /&gt;
:(cdeab AND 11011) =&amp;gt; cd0ab&lt;br /&gt;
:(10110 XOR cd0ab) =&amp;gt; Cd1Ab (the capital letter is the NOT of its lower case)&lt;br /&gt;
:(LSHIFT-1 Cd1Ab) =&amp;gt; d1Ab0&lt;br /&gt;
&lt;br /&gt;
So, d1Ab0 = 01100.&lt;br /&gt;
&lt;br /&gt;
Meaning, we must have d=0, A=1 (hence a=0), b=0.  Thus, the solution must be in the form 00*0*, where * is an “I-don’t-care”.  &lt;br /&gt;
&lt;br /&gt;
The four possible values of x are: 00000, 00001, 00100 and 00101.&lt;br /&gt;
&lt;br /&gt;
=== Problem 4 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression:&lt;br /&gt;
: ((RCIRC-14 (LCIRC-23 01101)) | (LSHIFT-1 10011) &amp;amp; (RSHIFT-2 10111))&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The problem can be rewritten as &lt;br /&gt;
: A | B &amp;amp; C&lt;br /&gt;
The AND has higher precedence than the OR.  &lt;br /&gt;
&lt;br /&gt;
The evaluation of expression A can be done in a straightforward way:  (LCIRC-23 01101) is the same as (LCIRC-3 01101) which has a value of 01011, and (RCIRC-14 01011) is the same as (RCIRC-4 01011) which has a value of 10110. Another strategy is to offset the left and right circulates.  So, ((RCIRC-14 (LCIRC-23 01101)) has the same value as (LCIRC-9 01101), which has the same value as (LCIRC-4 01101) which is also 11010.&lt;br /&gt;
&lt;br /&gt;
Expressions B and C are pretty easy to evaluate:&lt;br /&gt;
:B = (LSHIFT-1 10011) = 00110&lt;br /&gt;
:C = (RSHIFT-2 10111) = 00101&lt;br /&gt;
&lt;br /&gt;
The expression becomes&lt;br /&gt;
: A | B &amp;amp; C = 10110 | 00110 &amp;amp; 00101 = 10110 | 00100 = 10110&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/0U6ogoQ5Hkk&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/0U6ogoQ5Hkk &amp;quot;ACSL Math: Bit String Flicking&amp;quot; (Quick Coding Bytes)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IeMsD3harrE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IeMsD3harrE &amp;#039;&amp;#039;Bit String Flicking (Intro)&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A great two-part tutorial on this ACSL category. Part 1 covers bitwise operations AND, OR, NOT, and XOR. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jbKw8oYJPs4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jbKw8oYJPs4 &amp;#039;&amp;#039;Bit String Flicking Shifts and Circs&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Part 2 covers logical shifts and circulate operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/XNBcO25mgCw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/XNBcO25mgCw &amp;#039;&amp;#039;Bit String Flicking&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Shows the solution to the problem: (RSHIFT-3 (LCIRC-2 (NOT 10110)))&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/8J9AdxU5CW8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/8J9AdxU5CW8 &amp;#039;&amp;#039;Bit String Flicking by Ravi Yeluru&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;hemsra&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Walks through two problems from the Junior Division.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aa_lQ8gft60&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aa_lQ8gft60 &amp;#039;&amp;#039;ACSL BitString Flicking Contest 2 Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Solves a handful of problems given in previous years at the Intermediate Division level.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;URL&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [URL &amp;#039;&amp;#039;TITLE&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;AUTHOR&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Bit-String_Flicking&amp;diff=847</id>
		<title>Bit-String Flicking</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Bit-String_Flicking&amp;diff=847"/>
		<updated>2021-01-22T18:16:43Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Bitwise Operators */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Bit strings (strings of binary digits) are frequently manipulated bit-by-bit using the logical operators  &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039;. Bits strings are manipulated as a unit using &amp;#039;&amp;#039;&amp;#039;SHIFT&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;CIRCULATE&amp;#039;&amp;#039;&amp;#039; operators. The bits on the left are called the &amp;#039;&amp;#039;most significant bits&amp;#039;&amp;#039; and those on the right are the &amp;#039;&amp;#039;least significant bits&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Most high-level languages (e.g., Python, Java, C++), support bit-string operations. Programmers typically use bit strings to maintain a set of flags.  Suppose that a program supports 8 options, each of which can be either “on” or “off”.  One could maintain this information using an array of size 8, or one could use a single variable (if it is internally stored using at least 8 bits or 1 byte, which is usually the case) and represent each option with a single bit.  In addition to saving space, the program is often cleaner if a single variable is involved rather than an array.  Bits strings are often used to maintain a set where values are either in the set or not. Shifting of bits is also used to multiply or divide by powers of 2.&lt;br /&gt;
&lt;br /&gt;
Mastering this topic is essential for systems programming, programming in assembly language, optimizing code, and hardware design.&lt;br /&gt;
&lt;br /&gt;
== Operators==&lt;br /&gt;
&lt;br /&gt;
=== Bitwise Operators ===&lt;br /&gt;
&lt;br /&gt;
The logical operators are  &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; (~ or $\neg$), &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; (&amp;amp;), &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; (|), and &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; ($\oplus$). These operators should be familiar to ACSL students from the [[Boolean Algebra]] and [[Digital Electronics]] categories.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; is a unary operator that performs logical negation on each bit. Bits that are 0 become 1, and those that are 1 become 0. For example: ~101110 has a value of 010001.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands.  The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of two values is 1 only if both values are 1. For example, &amp;#039;&amp;#039;&amp;#039;1011011 and 011001&amp;#039;&amp;#039;&amp;#039; has a value of &amp;#039;&amp;#039;&amp;#039;001001&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; function is often used to isolate the value of a bit in a bit-string or to clear the value of a bit in a bit-string.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands. The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of two values is 1 only if one or both values are 1. For example, &amp;#039;&amp;#039;&amp;#039;1011011 or 0011001&amp;#039;&amp;#039;&amp;#039; has a value of &amp;#039;&amp;#039;&amp;#039;1011011&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; function is often use to force the value of a bit in a bit-string to be 1, if it isn&amp;#039;t already.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands. The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of two values is 1 if the values are different and 0 if they are the same. For example, &amp;#039;&amp;#039;&amp;#039;1011011 xor 011001 = 110010&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; function is often used to change the value of a particular bit.&lt;br /&gt;
&lt;br /&gt;
All binary operators (AND, OR, or XOR) must operate on bit-strings that are of the same length. If the operands are not the same length, the shorter one is padded with 0&amp;#039;s on the left as needed. For example, &amp;#039;&amp;#039;&amp;#039;11010 and 1110&amp;#039;&amp;#039;&amp;#039; would have value of &amp;#039;&amp;#039;&amp;#039;11010 and 01110 = 01010&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The following table summarizes the operators:&lt;br /&gt;
&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
! &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;and&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;xor&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Shift Operators ===&lt;br /&gt;
&lt;br /&gt;
Logical shifts (LSHIFT-x and RSHIFT-x) “ripple” the bit-string x positions in the indicated direction, either to the left or to the right.  Bits shifted out are lost; zeros are shifted in at the other end.   &lt;br /&gt;
&lt;br /&gt;
Circulates (RCIRC-x and LCIRC-x) “ripple” the bit string x positions in the indicated direction.  As each bit is shifted out one end, it is shifted in at the other end. The effect of this is that the bits remain in the same order on the other side of the string.&lt;br /&gt;
&lt;br /&gt;
The size of a bit-string  does not change with shifts, or circulates.  If any bit strings are initially of different lengths, all shorter ones are padded with zeros in the left bits until all strings are of the same length.  &lt;br /&gt;
&lt;br /&gt;
The following table gives some examples of these operations:&lt;br /&gt;
&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: right&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!x&lt;br /&gt;
!(LSHIFT-2 x)&lt;br /&gt;
!(RSHIFT-3 x)&lt;br /&gt;
!(LCIRC-3 x)&lt;br /&gt;
!(RCIRC-1 x)&lt;br /&gt;
|-&lt;br /&gt;
!01101&lt;br /&gt;
| 10100&lt;br /&gt;
| 00001&lt;br /&gt;
| 01011&lt;br /&gt;
| 10110&lt;br /&gt;
|-&lt;br /&gt;
!10&lt;br /&gt;
| 00&lt;br /&gt;
| 00&lt;br /&gt;
| 01&lt;br /&gt;
| 01&lt;br /&gt;
|-&lt;br /&gt;
!1110&lt;br /&gt;
| 1000&lt;br /&gt;
| 0001&lt;br /&gt;
| 0111&lt;br /&gt;
| 0111&lt;br /&gt;
|-&lt;br /&gt;
!1011011&lt;br /&gt;
| 1101100&lt;br /&gt;
| 0001011&lt;br /&gt;
| 1011101&lt;br /&gt;
| 1101101&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Order of Precedence ===&lt;br /&gt;
&lt;br /&gt;
The order of precedence (from highest to lowest) is: NOT; SHIFT and CIRC; AND; XOR; and finally, OR.  In other words, all unary operators are performed on a single operator first.  Operators with equal precedence are evaluated left to right; all unary  operators bind from right to left.&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression: &lt;br /&gt;
:(101110 AND NOT 110110 OR (LSHIFT-3 101010))&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The expression evaluates as follows:&lt;br /&gt;
:(101110 AND &amp;#039;&amp;#039;&amp;#039;001001&amp;#039;&amp;#039;&amp;#039; OR (LSHIFT-3 101010))&lt;br /&gt;
:(&amp;#039;&amp;#039;&amp;#039;001000&amp;#039;&amp;#039;&amp;#039; OR (LSHIFT-3 101010))&lt;br /&gt;
:(001000 OR &amp;#039;&amp;#039;&amp;#039;010000&amp;#039;&amp;#039;&amp;#039;)&lt;br /&gt;
:&amp;#039;&amp;#039;&amp;#039;011000&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression: &lt;br /&gt;
:(RSHIFT-1 (LCIRC-4 (RCIRC-2 01101))) &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The expression evaluates as follows, starting at the innermost parentheses:&lt;br /&gt;
:(RCIRC-2 01101) =&amp;gt; 01011&lt;br /&gt;
:(LCIRC-4 01011) =&amp;gt; 10101&lt;br /&gt;
:(RSHIFT-1 10101) = 01010&lt;br /&gt;
&lt;br /&gt;
=== Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
List all possible values of x (5 bits long) that solve the following equation.&lt;br /&gt;
:(LSHIFT-1 (10110 XOR (RCIRC-3 x) AND 11011)) = 01100&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Since x is a string 5 bits long, represent it by abcde.&lt;br /&gt;
:(RCIRC-3 abcde) =&amp;gt; cdeab&lt;br /&gt;
:(cdeab AND 11011) =&amp;gt; cd0ab&lt;br /&gt;
:(10110 XOR cd0ab) =&amp;gt; Cd1Ab (the capital letter is the NOT of its lower case)&lt;br /&gt;
:(LSHIFT-1 Cd1Ab) =&amp;gt; d1Ab0&lt;br /&gt;
&lt;br /&gt;
So, d1Ab0 = 01100.&lt;br /&gt;
&lt;br /&gt;
Meaning, we must have d=0, A=1 (hence a=0), b=0.  Thus, the solution must be in the form 00*0*, where * is an “I-don’t-care”.  &lt;br /&gt;
&lt;br /&gt;
The four possible values of x are: 00000, 00001, 00100 and 00101.&lt;br /&gt;
&lt;br /&gt;
=== Problem 4 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression:&lt;br /&gt;
: ((RCIRC-14 (LCIRC-23 01101)) | (LSHIFT-1 10011) &amp;amp; (RSHIFT-2 10111))&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The problem can be rewritten as &lt;br /&gt;
: A | B &amp;amp; C&lt;br /&gt;
The AND has higher precedence than the OR.  &lt;br /&gt;
&lt;br /&gt;
The evaluation of expression A can be done in a straightforward way:  (LCIRC-23 01101) is the same as (LCIRC-3 01101) which has a value of 01011, and (RCIRC-14 01011) is the same as (RCIRC-4 01011) which has a value of 10110. Another strategy is to offset the left and right circulates.  So, ((RCIRC-14 (LCIRC-23 01101)) has the same value as (LCIRC-9 01101), which has the same value as (LCIRC-4 01101) which is also 11010.&lt;br /&gt;
&lt;br /&gt;
Expressions B and C are pretty easy to evaluate:&lt;br /&gt;
:B = (LSHIFT-1 10011) = 00110&lt;br /&gt;
:C = (RSHIFT-2 10111) = 00101&lt;br /&gt;
&lt;br /&gt;
The expression becomes&lt;br /&gt;
: A | B &amp;amp; C = 10110 | 00110 &amp;amp; 00101 = 10110 | 00100 = 10110&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/0U6ogoQ5Hkk&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/0U6ogoQ5Hkk &amp;quot;ACSL Math: Bit String Flicking&amp;quot; (Quick Coding Bytes)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IeMsD3harrE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IeMsD3harrE &amp;#039;&amp;#039;Bit String Flicking (Intro)&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A great two-part tutorial on this ACSL category. Part 1 covers bitwise operations AND, OR, NOT, and XOR. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jbKw8oYJPs4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jbKw8oYJPs4 &amp;#039;&amp;#039;Bit String Flicking Shifts and Circs&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Part 2 covers logical shifts and circulate operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/XNBcO25mgCw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/XNBcO25mgCw &amp;#039;&amp;#039;Bit String Flicking&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Shows the solution to the problem: (RSHIFT-3 (LCIRC-2 (NOT 10110)))&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/8J9AdxU5CW8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/8J9AdxU5CW8 &amp;#039;&amp;#039;Bit String Flicking by Ravi Yeluru&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;hemsra&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Walks through two problems from the Junior Division.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aa_lQ8gft60&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aa_lQ8gft60 &amp;#039;&amp;#039;ACSL BitString Flicking Contest 2 Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Solves a handful of problems given in previous years at the Intermediate Division level.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;URL&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [URL &amp;#039;&amp;#039;TITLE&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;AUTHOR&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
x&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Bit-String_Flicking&amp;diff=846</id>
		<title>Bit-String Flicking</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Bit-String_Flicking&amp;diff=846"/>
		<updated>2021-01-22T18:14:18Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Video Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Bit strings (strings of binary digits) are frequently manipulated bit-by-bit using the logical operators  &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039;. Bits strings are manipulated as a unit using &amp;#039;&amp;#039;&amp;#039;SHIFT&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;CIRCULATE&amp;#039;&amp;#039;&amp;#039; operators. The bits on the left are called the &amp;#039;&amp;#039;most significant bits&amp;#039;&amp;#039; and those on the right are the &amp;#039;&amp;#039;least significant bits&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Most high-level languages (e.g., Python, Java, C++), support bit-string operations. Programmers typically use bit strings to maintain a set of flags.  Suppose that a program supports 8 options, each of which can be either “on” or “off”.  One could maintain this information using an array of size 8, or one could use a single variable (if it is internally stored using at least 8 bits or 1 byte, which is usually the case) and represent each option with a single bit.  In addition to saving space, the program is often cleaner if a single variable is involved rather than an array.  Bits strings are often used to maintain a set where values are either in the set or not. Shifting of bits is also used to multiply or divide by powers of 2.&lt;br /&gt;
&lt;br /&gt;
Mastering this topic is essential for systems programming, programming in assembly language, optimizing code, and hardware design.&lt;br /&gt;
&lt;br /&gt;
== Operators==&lt;br /&gt;
&lt;br /&gt;
=== Bitwise Operators ===&lt;br /&gt;
&lt;br /&gt;
The logical operators are  &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; (~ or $\neg$), &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; (&amp;amp;), &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; (|), and &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; ($\oplus$). These operators should be familiar to ACSL students from the [[Boolean Algebra]] and [[Digital Electronics]] categories.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; is a unary operator that performs logical negation on each bit. Bits that are 0 become 1, and those that are 1 become 0. For example: ~101110 has a value of 010001.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands.  The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of two values is 1 only if both values are 1. For example, &amp;#039;&amp;#039;&amp;#039;1011011 and 011001&amp;#039;&amp;#039;&amp;#039; has a value of &amp;#039;&amp;#039;&amp;#039;001001&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; function is often used to isolate the value of a bit in a bit-string or to clear the value of a bit in a bit-string.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands. The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of two values is 1 only if one or both values are 1. For example, &amp;#039;&amp;#039;&amp;#039;1011011 or 011001&amp;#039;&amp;#039;&amp;#039; has a value of &amp;#039;&amp;#039;&amp;#039;111011&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; function is often use to force the value of a bit in a bit-string to be 1, if it isn&amp;#039;t already.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands. The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of two values is 1 if the values are different and 0 if they are the same. For example, &amp;#039;&amp;#039;&amp;#039;1011011 xor 011001 = 110010&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; function is often used to change the value of a particular bit.&lt;br /&gt;
&lt;br /&gt;
All binary operators (AND, OR, or XOR) must operate on bit-strings that are of the same length. If the operands are not the same length, the shorter one is padded with 0&amp;#039;s on the left as needed. For example, &amp;#039;&amp;#039;&amp;#039;11010 and 1110&amp;#039;&amp;#039;&amp;#039; would have value of &amp;#039;&amp;#039;&amp;#039;11010 and 01110 = 01010&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The following table summarizes the operators:&lt;br /&gt;
&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
! &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;and&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;xor&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Shift Operators ===&lt;br /&gt;
&lt;br /&gt;
Logical shifts (LSHIFT-x and RSHIFT-x) “ripple” the bit-string x positions in the indicated direction, either to the left or to the right.  Bits shifted out are lost; zeros are shifted in at the other end.   &lt;br /&gt;
&lt;br /&gt;
Circulates (RCIRC-x and LCIRC-x) “ripple” the bit string x positions in the indicated direction.  As each bit is shifted out one end, it is shifted in at the other end. The effect of this is that the bits remain in the same order on the other side of the string.&lt;br /&gt;
&lt;br /&gt;
The size of a bit-string  does not change with shifts, or circulates.  If any bit strings are initially of different lengths, all shorter ones are padded with zeros in the left bits until all strings are of the same length.  &lt;br /&gt;
&lt;br /&gt;
The following table gives some examples of these operations:&lt;br /&gt;
&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: right&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!x&lt;br /&gt;
!(LSHIFT-2 x)&lt;br /&gt;
!(RSHIFT-3 x)&lt;br /&gt;
!(LCIRC-3 x)&lt;br /&gt;
!(RCIRC-1 x)&lt;br /&gt;
|-&lt;br /&gt;
!01101&lt;br /&gt;
| 10100&lt;br /&gt;
| 00001&lt;br /&gt;
| 01011&lt;br /&gt;
| 10110&lt;br /&gt;
|-&lt;br /&gt;
!10&lt;br /&gt;
| 00&lt;br /&gt;
| 00&lt;br /&gt;
| 01&lt;br /&gt;
| 01&lt;br /&gt;
|-&lt;br /&gt;
!1110&lt;br /&gt;
| 1000&lt;br /&gt;
| 0001&lt;br /&gt;
| 0111&lt;br /&gt;
| 0111&lt;br /&gt;
|-&lt;br /&gt;
!1011011&lt;br /&gt;
| 1101100&lt;br /&gt;
| 0001011&lt;br /&gt;
| 1011101&lt;br /&gt;
| 1101101&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Order of Precedence ===&lt;br /&gt;
&lt;br /&gt;
The order of precedence (from highest to lowest) is: NOT; SHIFT and CIRC; AND; XOR; and finally, OR.  In other words, all unary operators are performed on a single operator first.  Operators with equal precedence are evaluated left to right; all unary  operators bind from right to left.&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression: &lt;br /&gt;
:(101110 AND NOT 110110 OR (LSHIFT-3 101010))&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The expression evaluates as follows:&lt;br /&gt;
:(101110 AND &amp;#039;&amp;#039;&amp;#039;001001&amp;#039;&amp;#039;&amp;#039; OR (LSHIFT-3 101010))&lt;br /&gt;
:(&amp;#039;&amp;#039;&amp;#039;001000&amp;#039;&amp;#039;&amp;#039; OR (LSHIFT-3 101010))&lt;br /&gt;
:(001000 OR &amp;#039;&amp;#039;&amp;#039;010000&amp;#039;&amp;#039;&amp;#039;)&lt;br /&gt;
:&amp;#039;&amp;#039;&amp;#039;011000&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression: &lt;br /&gt;
:(RSHIFT-1 (LCIRC-4 (RCIRC-2 01101))) &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The expression evaluates as follows, starting at the innermost parentheses:&lt;br /&gt;
:(RCIRC-2 01101) =&amp;gt; 01011&lt;br /&gt;
:(LCIRC-4 01011) =&amp;gt; 10101&lt;br /&gt;
:(RSHIFT-1 10101) = 01010&lt;br /&gt;
&lt;br /&gt;
=== Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
List all possible values of x (5 bits long) that solve the following equation.&lt;br /&gt;
:(LSHIFT-1 (10110 XOR (RCIRC-3 x) AND 11011)) = 01100&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Since x is a string 5 bits long, represent it by abcde.&lt;br /&gt;
:(RCIRC-3 abcde) =&amp;gt; cdeab&lt;br /&gt;
:(cdeab AND 11011) =&amp;gt; cd0ab&lt;br /&gt;
:(10110 XOR cd0ab) =&amp;gt; Cd1Ab (the capital letter is the NOT of its lower case)&lt;br /&gt;
:(LSHIFT-1 Cd1Ab) =&amp;gt; d1Ab0&lt;br /&gt;
&lt;br /&gt;
So, d1Ab0 = 01100.&lt;br /&gt;
&lt;br /&gt;
Meaning, we must have d=0, A=1 (hence a=0), b=0.  Thus, the solution must be in the form 00*0*, where * is an “I-don’t-care”.  &lt;br /&gt;
&lt;br /&gt;
The four possible values of x are: 00000, 00001, 00100 and 00101.&lt;br /&gt;
&lt;br /&gt;
=== Problem 4 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression:&lt;br /&gt;
: ((RCIRC-14 (LCIRC-23 01101)) | (LSHIFT-1 10011) &amp;amp; (RSHIFT-2 10111))&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The problem can be rewritten as &lt;br /&gt;
: A | B &amp;amp; C&lt;br /&gt;
The AND has higher precedence than the OR.  &lt;br /&gt;
&lt;br /&gt;
The evaluation of expression A can be done in a straightforward way:  (LCIRC-23 01101) is the same as (LCIRC-3 01101) which has a value of 01011, and (RCIRC-14 01011) is the same as (RCIRC-4 01011) which has a value of 10110. Another strategy is to offset the left and right circulates.  So, ((RCIRC-14 (LCIRC-23 01101)) has the same value as (LCIRC-9 01101), which has the same value as (LCIRC-4 01101) which is also 11010.&lt;br /&gt;
&lt;br /&gt;
Expressions B and C are pretty easy to evaluate:&lt;br /&gt;
:B = (LSHIFT-1 10011) = 00110&lt;br /&gt;
:C = (RSHIFT-2 10111) = 00101&lt;br /&gt;
&lt;br /&gt;
The expression becomes&lt;br /&gt;
: A | B &amp;amp; C = 10110 | 00110 &amp;amp; 00101 = 10110 | 00100 = 10110&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/0U6ogoQ5Hkk&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/0U6ogoQ5Hkk &amp;quot;ACSL Math: Bit String Flicking&amp;quot; (Quick Coding Bytes)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IeMsD3harrE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IeMsD3harrE &amp;#039;&amp;#039;Bit String Flicking (Intro)&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A great two-part tutorial on this ACSL category. Part 1 covers bitwise operations AND, OR, NOT, and XOR. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jbKw8oYJPs4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jbKw8oYJPs4 &amp;#039;&amp;#039;Bit String Flicking Shifts and Circs&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Part 2 covers logical shifts and circulate operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/XNBcO25mgCw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/XNBcO25mgCw &amp;#039;&amp;#039;Bit String Flicking&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Shows the solution to the problem: (RSHIFT-3 (LCIRC-2 (NOT 10110)))&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/8J9AdxU5CW8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/8J9AdxU5CW8 &amp;#039;&amp;#039;Bit String Flicking by Ravi Yeluru&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;hemsra&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Walks through two problems from the Junior Division.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aa_lQ8gft60&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aa_lQ8gft60 &amp;#039;&amp;#039;ACSL BitString Flicking Contest 2 Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Solves a handful of problems given in previous years at the Intermediate Division level.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;URL&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [URL &amp;#039;&amp;#039;TITLE&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;AUTHOR&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
x&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Bit-String_Flicking&amp;diff=845</id>
		<title>Bit-String Flicking</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Bit-String_Flicking&amp;diff=845"/>
		<updated>2021-01-22T18:13:55Z</updated>

		<summary type="html">&lt;p&gt;Marc: Reverted edits by Jerry (talk) to last revision by Jan&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Bit strings (strings of binary digits) are frequently manipulated bit-by-bit using the logical operators  &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039;. Bits strings are manipulated as a unit using &amp;#039;&amp;#039;&amp;#039;SHIFT&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;CIRCULATE&amp;#039;&amp;#039;&amp;#039; operators. The bits on the left are called the &amp;#039;&amp;#039;most significant bits&amp;#039;&amp;#039; and those on the right are the &amp;#039;&amp;#039;least significant bits&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Most high-level languages (e.g., Python, Java, C++), support bit-string operations. Programmers typically use bit strings to maintain a set of flags.  Suppose that a program supports 8 options, each of which can be either “on” or “off”.  One could maintain this information using an array of size 8, or one could use a single variable (if it is internally stored using at least 8 bits or 1 byte, which is usually the case) and represent each option with a single bit.  In addition to saving space, the program is often cleaner if a single variable is involved rather than an array.  Bits strings are often used to maintain a set where values are either in the set or not. Shifting of bits is also used to multiply or divide by powers of 2.&lt;br /&gt;
&lt;br /&gt;
Mastering this topic is essential for systems programming, programming in assembly language, optimizing code, and hardware design.&lt;br /&gt;
&lt;br /&gt;
== Operators==&lt;br /&gt;
&lt;br /&gt;
=== Bitwise Operators ===&lt;br /&gt;
&lt;br /&gt;
The logical operators are  &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; (~ or $\neg$), &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; (&amp;amp;), &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; (|), and &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; ($\oplus$). These operators should be familiar to ACSL students from the [[Boolean Algebra]] and [[Digital Electronics]] categories.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; is a unary operator that performs logical negation on each bit. Bits that are 0 become 1, and those that are 1 become 0. For example: ~101110 has a value of 010001.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands.  The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of two values is 1 only if both values are 1. For example, &amp;#039;&amp;#039;&amp;#039;1011011 and 011001&amp;#039;&amp;#039;&amp;#039; has a value of &amp;#039;&amp;#039;&amp;#039;001001&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; function is often used to isolate the value of a bit in a bit-string or to clear the value of a bit in a bit-string.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands. The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of two values is 1 only if one or both values are 1. For example, &amp;#039;&amp;#039;&amp;#039;1011011 or 011001&amp;#039;&amp;#039;&amp;#039; has a value of &amp;#039;&amp;#039;&amp;#039;111011&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; function is often use to force the value of a bit in a bit-string to be 1, if it isn&amp;#039;t already.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; is a binary operator that performs the logical &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of each bit in each of its operands. The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of two values is 1 if the values are different and 0 if they are the same. For example, &amp;#039;&amp;#039;&amp;#039;1011011 xor 011001 = 110010&amp;#039;&amp;#039;&amp;#039;. The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; function is often used to change the value of a particular bit.&lt;br /&gt;
&lt;br /&gt;
All binary operators (AND, OR, or XOR) must operate on bit-strings that are of the same length. If the operands are not the same length, the shorter one is padded with 0&amp;#039;s on the left as needed. For example, &amp;#039;&amp;#039;&amp;#039;11010 and 1110&amp;#039;&amp;#039;&amp;#039; would have value of &amp;#039;&amp;#039;&amp;#039;11010 and 01110 = 01010&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The following table summarizes the operators:&lt;br /&gt;
&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
! &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;and&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; &amp;#039;&amp;#039;&amp;#039;xor&amp;#039;&amp;#039;&amp;#039; &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
| 1 &lt;br /&gt;
| 1 &lt;br /&gt;
| 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Shift Operators ===&lt;br /&gt;
&lt;br /&gt;
Logical shifts (LSHIFT-x and RSHIFT-x) “ripple” the bit-string x positions in the indicated direction, either to the left or to the right.  Bits shifted out are lost; zeros are shifted in at the other end.   &lt;br /&gt;
&lt;br /&gt;
Circulates (RCIRC-x and LCIRC-x) “ripple” the bit string x positions in the indicated direction.  As each bit is shifted out one end, it is shifted in at the other end. The effect of this is that the bits remain in the same order on the other side of the string.&lt;br /&gt;
&lt;br /&gt;
The size of a bit-string  does not change with shifts, or circulates.  If any bit strings are initially of different lengths, all shorter ones are padded with zeros in the left bits until all strings are of the same length.  &lt;br /&gt;
&lt;br /&gt;
The following table gives some examples of these operations:&lt;br /&gt;
&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: right&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!x&lt;br /&gt;
!(LSHIFT-2 x)&lt;br /&gt;
!(RSHIFT-3 x)&lt;br /&gt;
!(LCIRC-3 x)&lt;br /&gt;
!(RCIRC-1 x)&lt;br /&gt;
|-&lt;br /&gt;
!01101&lt;br /&gt;
| 10100&lt;br /&gt;
| 00001&lt;br /&gt;
| 01011&lt;br /&gt;
| 10110&lt;br /&gt;
|-&lt;br /&gt;
!10&lt;br /&gt;
| 00&lt;br /&gt;
| 00&lt;br /&gt;
| 01&lt;br /&gt;
| 01&lt;br /&gt;
|-&lt;br /&gt;
!1110&lt;br /&gt;
| 1000&lt;br /&gt;
| 0001&lt;br /&gt;
| 0111&lt;br /&gt;
| 0111&lt;br /&gt;
|-&lt;br /&gt;
!1011011&lt;br /&gt;
| 1101100&lt;br /&gt;
| 0001011&lt;br /&gt;
| 1011101&lt;br /&gt;
| 1101101&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Order of Precedence ===&lt;br /&gt;
&lt;br /&gt;
The order of precedence (from highest to lowest) is: NOT; SHIFT and CIRC; AND; XOR; and finally, OR.  In other words, all unary operators are performed on a single operator first.  Operators with equal precedence are evaluated left to right; all unary  operators bind from right to left.&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression: &lt;br /&gt;
:(101110 AND NOT 110110 OR (LSHIFT-3 101010))&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The expression evaluates as follows:&lt;br /&gt;
:(101110 AND &amp;#039;&amp;#039;&amp;#039;001001&amp;#039;&amp;#039;&amp;#039; OR (LSHIFT-3 101010))&lt;br /&gt;
:(&amp;#039;&amp;#039;&amp;#039;001000&amp;#039;&amp;#039;&amp;#039; OR (LSHIFT-3 101010))&lt;br /&gt;
:(001000 OR &amp;#039;&amp;#039;&amp;#039;010000&amp;#039;&amp;#039;&amp;#039;)&lt;br /&gt;
:&amp;#039;&amp;#039;&amp;#039;011000&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression: &lt;br /&gt;
:(RSHIFT-1 (LCIRC-4 (RCIRC-2 01101))) &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The expression evaluates as follows, starting at the innermost parentheses:&lt;br /&gt;
:(RCIRC-2 01101) =&amp;gt; 01011&lt;br /&gt;
:(LCIRC-4 01011) =&amp;gt; 10101&lt;br /&gt;
:(RSHIFT-1 10101) = 01010&lt;br /&gt;
&lt;br /&gt;
=== Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
List all possible values of x (5 bits long) that solve the following equation.&lt;br /&gt;
:(LSHIFT-1 (10110 XOR (RCIRC-3 x) AND 11011)) = 01100&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Since x is a string 5 bits long, represent it by abcde.&lt;br /&gt;
:(RCIRC-3 abcde) =&amp;gt; cdeab&lt;br /&gt;
:(cdeab AND 11011) =&amp;gt; cd0ab&lt;br /&gt;
:(10110 XOR cd0ab) =&amp;gt; Cd1Ab (the capital letter is the NOT of its lower case)&lt;br /&gt;
:(LSHIFT-1 Cd1Ab) =&amp;gt; d1Ab0&lt;br /&gt;
&lt;br /&gt;
So, d1Ab0 = 01100.&lt;br /&gt;
&lt;br /&gt;
Meaning, we must have d=0, A=1 (hence a=0), b=0.  Thus, the solution must be in the form 00*0*, where * is an “I-don’t-care”.  &lt;br /&gt;
&lt;br /&gt;
The four possible values of x are: 00000, 00001, 00100 and 00101.&lt;br /&gt;
&lt;br /&gt;
=== Problem 4 ===&lt;br /&gt;
&lt;br /&gt;
Evaluate the following expression:&lt;br /&gt;
: ((RCIRC-14 (LCIRC-23 01101)) | (LSHIFT-1 10011) &amp;amp; (RSHIFT-2 10111))&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
The problem can be rewritten as &lt;br /&gt;
: A | B &amp;amp; C&lt;br /&gt;
The AND has higher precedence than the OR.  &lt;br /&gt;
&lt;br /&gt;
The evaluation of expression A can be done in a straightforward way:  (LCIRC-23 01101) is the same as (LCIRC-3 01101) which has a value of 01011, and (RCIRC-14 01011) is the same as (RCIRC-4 01011) which has a value of 10110. Another strategy is to offset the left and right circulates.  So, ((RCIRC-14 (LCIRC-23 01101)) has the same value as (LCIRC-9 01101), which has the same value as (LCIRC-4 01101) which is also 11010.&lt;br /&gt;
&lt;br /&gt;
Expressions B and C are pretty easy to evaluate:&lt;br /&gt;
:B = (LSHIFT-1 10011) = 00110&lt;br /&gt;
:C = (RSHIFT-2 10111) = 00101&lt;br /&gt;
&lt;br /&gt;
The expression becomes&lt;br /&gt;
: A | B &amp;amp; C = 10110 | 00110 &amp;amp; 00101 = 10110 | 00100 = 10110&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/0U6ogoQ5Hkk&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/0U6ogoQ5Hkk &amp;quot;ACSL Math: Bit String Flicking&amp;quot; (Quick Coding Bytes)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/IeMsD3harrE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/IeMsD3harrE &amp;#039;&amp;#039;Bit String Flicking (Intro)&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A great two-part tutorial on this ACSL category. Part 1 covers bitwise operations AND, OR, NOT, and XOR. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jbKw8oYJPs4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jbKw8oYJPs4 &amp;#039;&amp;#039;Bit String Flicking Shifts and Circs&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Part 2 covers logical shifts and circulate operations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/XNBcO25mgCw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/XNBcO25mgCw &amp;#039;&amp;#039;Bit String Flicking&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Shows the solution to the problem: (RSHIFT-3 (LCIRC-2 (NOT 10110)))&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/8J9AdxU5CW8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/8J9AdxU5CW8 &amp;#039;&amp;#039;Bit String Flicking by Ravi Yeluru&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;hemsra&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Walks through two problems from the Junior Division.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aa_lQ8gft60&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aa_lQ8gft60 &amp;#039;&amp;#039;ACSL BitString Flicking Contest 2 Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Solves a handful of problems given in previous years at the Intermediate Division level.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;URL&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [URL &amp;#039;&amp;#039;TITLE&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;AUTHOR&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Assembly_Language_Programming&amp;diff=844</id>
		<title>Assembly Language Programming</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Assembly_Language_Programming&amp;diff=844"/>
		<updated>2021-01-22T17:54:40Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Video Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Programs written in high-level languages are traditionally converted by compilers into assembly language, which is turned into machine language programs – sequences of 1’s and 0’s – by an assembler. Even today, with very good quality compilers available, there is the need for programmers to understand assembly language.  First, it provides programmers with a better understanding of the compiler and its constraints.  Second, on occasion, programmers find themselves needing to program directly in assembly language in order to meet constraints in execution speed or space. &lt;br /&gt;
&lt;br /&gt;
ACSL chose to define its own assembly language rather than use a “real” one in order to eliminate the many sticky details associated with real languages.  The basic concepts of our ACSL topic description are common to all assembly languages.  &lt;br /&gt;
&lt;br /&gt;
== Reference Manual ==&lt;br /&gt;
&lt;br /&gt;
Execution starts at the first line of the program and continues sequentially, except for branch instructions (BG, BE, BL, BU), until the end instruction (END) is encountered.  The result of each operation is stored in a special word of memory, called the “accumulator” (ACC).  The initial value of the ACC is 0. Each line of an assembly language program has the following fields:&lt;br /&gt;
&lt;br /&gt;
 LABEL OPCODE LOC&lt;br /&gt;
&lt;br /&gt;
The LABEL field, if present, is an alphanumeric character string beginning in the first column. A label must begin with an alphabetic character(A through Z, or a through z), and labels are case-sensitive.  Valid OPCODEs are listed in the chart below; they are also case-sensitive and uppercase. Opcodes are reserved words of the language and (the uppercase version) many not be used a label. The LOC field is either a reference to a label or &amp;#039;&amp;#039;immediate data&amp;#039;&amp;#039;.  For example, “LOAD A” would put the contents referenced by the label “A” into the ACC; “LOAD =123” would store the value 123 in the ACC.  Only those instructions that do not modify the LOC field can use the “immediate data” format.  In the following chart, they are indicated by an asterisk in the first column.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
!OP CODE&lt;br /&gt;
!DESCRIPTION&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!*LOAD&lt;br /&gt;
|The contents of LOC are placed in the ACC. LOC is unchanged.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!STORE&lt;br /&gt;
|The contents of the ACC are placed in the LOC. ACC is unchanged.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!*ADD&lt;br /&gt;
|The contents of LOC are added to the contents of the ACC.  The sum is stored in the ACC. LOC is unchanged. Addition is modulo 1,000,000.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!*SUB&lt;br /&gt;
|The contents of LOC are subtracted from the contents of the ACC.  The difference is stored in the ACC.  LOC is unchanged.  Subtraction is modulo 1,000,000.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!*MULT&lt;br /&gt;
|The contents of LOC are multiplied by the contents of the ACC.  The product is stored in the ACC.  LOC is unchanged.  Multiplication is modulo 1,000,000.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!*DIV&lt;br /&gt;
|The contents of LOC are divided into the contents of the ACC.  The signed integer part of the quotient is stored in the ACC.  LOC is unchanged.&lt;br /&gt;
.&lt;br /&gt;
|-&lt;br /&gt;
!BG&lt;br /&gt;
|&lt;br /&gt;
Branch to the instruction labeled with LOC if ACC&amp;gt;0.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!BE&lt;br /&gt;
|&lt;br /&gt;
Branch to the instruction labeled with LOC if ACC=0.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!BL&lt;br /&gt;
|&lt;br /&gt;
Branch to the instruction labeled with LOC if ACC&amp;lt;0.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!BU&lt;br /&gt;
|Branch to the instruction labeled with LOC.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!READ&lt;br /&gt;
|&lt;br /&gt;
Read a signed integer (modulo 1,000,000) into LOC.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!PRINT&lt;br /&gt;
|&lt;br /&gt;
Print the contents of LOC.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!DC&lt;br /&gt;
|&lt;br /&gt;
The value of the memory word defined by the LABEL field is defined to contain the specified constant.  The LABEL field is mandatory for this opcode.  The ACC is not modified.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!END&lt;br /&gt;
| &lt;br /&gt;
Program terminates.  LOC field is ignored and must be empty.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
After the following program is executed, &lt;br /&gt;
what value is in location TEMP?&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|TEMP || DC || 0&lt;br /&gt;
|-&lt;br /&gt;
|A||DC||8&lt;br /&gt;
|-&lt;br /&gt;
|B||DC||-2&lt;br /&gt;
|-&lt;br /&gt;
|C||DC||3&lt;br /&gt;
|-&lt;br /&gt;
| ||LOAD||B&lt;br /&gt;
|-&lt;br /&gt;
| ||MULT||C&lt;br /&gt;
|-&lt;br /&gt;
| ||ADD||A&lt;br /&gt;
|-&lt;br /&gt;
| ||DIV||B&lt;br /&gt;
|-&lt;br /&gt;
| ||SUB||A&lt;br /&gt;
|-&lt;br /&gt;
| ||STORE||TEMP&lt;br /&gt;
|-&lt;br /&gt;
| ||END||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; The ACC takes on values -2, -6, 2, -1, and -9 in that order. The last value, -9, is stored in location TEMP.&lt;br /&gt;
&lt;br /&gt;
=== Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
If the following program has an input value&lt;br /&gt;
of N, what is the final value of X which is&lt;br /&gt;
computed?  Express X as an algebraic&lt;br /&gt;
expression in terms of N.	&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: left&amp;quot;&lt;br /&gt;
|  || READ || X&lt;br /&gt;
|-&lt;br /&gt;
|  || LOAD || X&lt;br /&gt;
|-&lt;br /&gt;
|TOP || SUB || =1&lt;br /&gt;
|-&lt;br /&gt;
|  || BE || DONE&lt;br /&gt;
|-&lt;br /&gt;
|  || STORE || A&lt;br /&gt;
|-&lt;br /&gt;
|  || MULT || X&lt;br /&gt;
|-&lt;br /&gt;
|  || STORE || X&lt;br /&gt;
|-&lt;br /&gt;
|  || LOAD || A&lt;br /&gt;
|-&lt;br /&gt;
|  || BU || TOP&lt;br /&gt;
|-&lt;br /&gt;
|DONE || END || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; This program loops between labels TOP and&lt;br /&gt;
DONE for A times.  A has an initial value of X and subsequent terms of N,&lt;br /&gt;
then values of A-1, A-2, …, 1.  Each time through the loop,&lt;br /&gt;
X is multiplied by the the current value of A.&lt;br /&gt;
Thus, X = A * (A-1) * (A-2) * … * 1 or X=A! or A factorial.&lt;br /&gt;
For example, 5! = 5 * 4 * 3 * 2 * 1 = 120.  Since the&lt;br /&gt;
initial value of A is the number input (i.e. N),&lt;br /&gt;
the algebraic expression is X = N!.&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some ACSL problems that have appeared in previous contests. Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jn2TJ-sHVzY&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jn2TJ-sHVzY ACSL Math: Assembly Language Programming (Quick Coding Bytes)]&lt;br /&gt;
&lt;br /&gt;
This video introduces the topic, then using an example problem, explains the methodology to solve problems that appear on ACSL contests.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/RUm3iHsbO3I&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/RUm3iHsbO3I &amp;#039;&amp;#039;Intro to Assembly Language&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A general introduction into assembly language. In particular, it covers how it fits into the source code to an executable image pipeline.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/i_JYT398O64&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/i_JYT398O64 &amp;#039;&amp;#039;Syntax of ACSL Assembly Language&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A very nice introduction to this ACSL category.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/NEQASUsZ0g4&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/NEQASUsZ0g4 &amp;#039;&amp;#039;Examples&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;CalculusNguyenify&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Walks through a couple of ACSL Assembly language programs that have been used in previous contests.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;URL&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [URL &amp;#039;&amp;#039;TITLE&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;AUTHOR&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
xx&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Main_Page&amp;diff=843</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Main_Page&amp;diff=843"/>
		<updated>2021-01-22T17:53:21Z</updated>

		<summary type="html">&lt;p&gt;Marc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki describing the topics covered in the short programs section of the [//www.acsl.org ACSL] contests.&lt;br /&gt;
&lt;br /&gt;
If you&amp;#039;d like to contribute to this wiki - and we&amp;#039;d love to improve it - please shoot us an email requesting an account. Conversely, if we&amp;#039;ve linked to your material (especially YouTube videos) that you&amp;#039;d prefer that we do not reference, let us know and we will promptly remove those links.&lt;br /&gt;
&lt;br /&gt;
The categories covered during the regular season in the Classroom, Junior, Intermediate, and Senior Divisions are as follows:&lt;br /&gt;
&lt;br /&gt;
* [[Assembly Language Programming]]  &lt;br /&gt;
* [[Bit-String Flicking]] &lt;br /&gt;
* [[Boolean Algebra]]&lt;br /&gt;
* [[Computer Number Systems]]&lt;br /&gt;
* [[Data Structures]]&lt;br /&gt;
* [[Digital Electronics]] &lt;br /&gt;
* [[FSAs and Regular Expressions]] &lt;br /&gt;
* [[Graph Theory]]&lt;br /&gt;
* [[LISP]] &lt;br /&gt;
* [[Prefix/Infix/Postfix Notation]]&lt;br /&gt;
* [[Recursive Functions]]&lt;br /&gt;
* [[What Does This Program Do?]]&lt;br /&gt;
&lt;br /&gt;
The categories covered during the regular season in the Elementary Division are as follows:&lt;br /&gt;
&lt;br /&gt;
* [https://docs.google.com/document/d/17k3HdLUwUUzG02SJKXkvDSpJWxeVbhORnYLkRhLQJMo/edit?usp=sharing Elementary Division: Computer Number Systems (Contest 1)]&lt;br /&gt;
* [https://docs.google.com/document/d/1TpH1oEPR9qjX-xuLyPLQlvbbsPNquQOiPPyIIhOUAes/edit?usp=sharing Elementary Division: Prefix-Postfix-Infix Notation (Contest 2)]]&lt;br /&gt;
* [https://docs.google.com/document/d/1j_4St3SdddrL3xYT3OdTktnOztka1kqXF8AtC8k3KWo/edit?usp=sharing Elementary Division: Boolean Algebra (Contest 3)]&lt;br /&gt;
* [https://docs.google.com/document/d/1SDThTvIHI_rjBFGL1U2aXc5WbWZvgnFBq472F0QtVyg/edit?usp=sharing Elementary Division: Graph Theory (Contest 4)]&lt;br /&gt;
&lt;br /&gt;
Additional categories covered during the end-of-season invitational competition are as follows:&lt;br /&gt;
&lt;br /&gt;
* [[Advanced Regular Expressions]] &lt;br /&gt;
* [[Karnaugh Maps]] &lt;br /&gt;
&lt;br /&gt;
== Getting started ==&lt;br /&gt;
* [//meta.wikimedia.org/wiki/Help:Contents User&amp;#039;s Guide] for information on using the wiki software&lt;br /&gt;
* [//www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings Configuration settings list]&lt;br /&gt;
* [//www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Main_Page&amp;diff=840</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Main_Page&amp;diff=840"/>
		<updated>2020-09-30T17:17:14Z</updated>

		<summary type="html">&lt;p&gt;Marc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki describing the topics covered in the short programs section of the [//www.acsl.org ACSL] contests.&lt;br /&gt;
&lt;br /&gt;
If you&amp;#039;d like to contribute to this wiki - and we&amp;#039;d love to improve it - please shoot us an email requesting an account. Conversely, if we&amp;#039;ve linked to your material (especially YouTube videos) that you&amp;#039;d prefer that we do not reference, let us know and we will promptly remove those links.&lt;br /&gt;
&lt;br /&gt;
The categories covered during the regular season in the Classroom, Junior, Intermediate, and Senior Divisions are as follows:&lt;br /&gt;
&lt;br /&gt;
* [[Assembly Language Programming]]  &lt;br /&gt;
* [[Bit-String Flicking]] &lt;br /&gt;
* [[Boolean Algebra]]&lt;br /&gt;
* [[Computer Number Systems]]&lt;br /&gt;
* [[Data Structures]]&lt;br /&gt;
* [[Digital Electronics]] &lt;br /&gt;
* [[FSAs and Regular Expressions]] &lt;br /&gt;
* [[Graph Theory]]&lt;br /&gt;
* [[LISP]] &lt;br /&gt;
* [[Prefix/Infix/Postfix Notation]]&lt;br /&gt;
* [[Recursive Functions]]&lt;br /&gt;
* [[What Does This Program Do?]]&lt;br /&gt;
&lt;br /&gt;
The categories covered during the regular season in the Elementary Division are as follows:&lt;br /&gt;
&lt;br /&gt;
* [https://docs.google.com/document/d/17k3HdLUwUUzG02SJKXkvDSpJWxeVbhORnYLkRhLQJMo/edit?usp=sharing Elementary Division: Computer Number Systems (Contest 1)]&lt;br /&gt;
* [https://docs.google.com/document/d/1TpH1oEPR9qjX-xuLyPLQlvbbsPNquQOiPPyIIhOUAes/edit?usp=sharing Elementary Division: Prefix-Postfix-Infix Notation (Contest 2)]]&lt;br /&gt;
* [https://docs.google.com/document/d/1j_4St3SdddrL3xYT3OdTktnOztka1kqXF8AtC8k3KWo/edit?usp=sharing Elementary Division: Boolean Algebra (Contest 3)]&lt;br /&gt;
* [https://docs.google.com/document/d/1SDThTvIHI_rjBFGL1U2aXc5WbWZvgnFBq472F0QtVyg/edit?usp=sharing Elementary Division: Graph Theory (Contest 4)]&lt;br /&gt;
&lt;br /&gt;
The categories covered during the end-of-season invitational competition are as follows:&lt;br /&gt;
&lt;br /&gt;
* [[Advanced Regular Expressions]] &lt;br /&gt;
* [[Karnaugh Maps]] &lt;br /&gt;
&lt;br /&gt;
== Getting started ==&lt;br /&gt;
* [//meta.wikimedia.org/wiki/Help:Contents User&amp;#039;s Guide] for information on using the wiki software&lt;br /&gt;
* [//www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings Configuration settings list]&lt;br /&gt;
* [//www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Main_Page&amp;diff=839</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Main_Page&amp;diff=839"/>
		<updated>2020-09-30T17:10:28Z</updated>

		<summary type="html">&lt;p&gt;Marc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki describing the topics covered in the short programs section of the [//www.acsl.org ACSL] contests.&lt;br /&gt;
&lt;br /&gt;
If you&amp;#039;d like to contribute to this wiki - and we&amp;#039;d love to improve it - please shoot us an email requesting an account. Conversely, if we&amp;#039;ve linked to your material (especially YouTube videos) that you&amp;#039;d prefer that we do not reference, let us know and we will promptly remove those links.&lt;br /&gt;
&lt;br /&gt;
The categories covered during the regular season in the Classroom, Junior, Intermediate, and Senior Divisions are as follows:&lt;br /&gt;
&lt;br /&gt;
* [[Assembly Language Programming]]  &lt;br /&gt;
* [[Bit-String Flicking]] &lt;br /&gt;
* [[Boolean Algebra]]&lt;br /&gt;
* [[Computer Number Systems]]&lt;br /&gt;
* [[Data Structures]]&lt;br /&gt;
* [[Digital Electronics]] &lt;br /&gt;
* [[FSAs and Regular Expressions]] &lt;br /&gt;
* [[Graph Theory]]&lt;br /&gt;
* [[LISP]] &lt;br /&gt;
* [[Prefix/Infix/Postfix Notation]]&lt;br /&gt;
* [[Recursive Functions]]&lt;br /&gt;
* [[What Does This Program Do?]]&lt;br /&gt;
&lt;br /&gt;
The categories covered during the regular season in the Elementary Division are as follows:&lt;br /&gt;
&lt;br /&gt;
* [https://docs.google.com/document/d/17k3HdLUwUUzG02SJKXkvDSpJWxeVbhORnYLkRhLQJMo/edit?usp=sharing Elementary Division: Computer Number Systems (Contest 1)]&lt;br /&gt;
* [//classic2020.acsl.org/categories/C2Elem-Prefix-Postfix-InfixNotation.pdf Elementary Division: Prefix-Postfix-Infix Notation (Contest 2)]]&lt;br /&gt;
* [//classic2020.acsl.org/categories/C3Elem-BooleanAlgebra.pdf Elementary Division: Boolean Algebra (Contest 3)]&lt;br /&gt;
* [//classic2020.acsl.org/categories/C4Elem-GraphTheory.pdf Elementary Division: Graph Theory (Contest 4)]&lt;br /&gt;
&lt;br /&gt;
The categories covered during the end-of-season invitational competition are as follows:&lt;br /&gt;
&lt;br /&gt;
* [[Advanced Regular Expressions]] &lt;br /&gt;
* [[Karnaugh Maps]] &lt;br /&gt;
&lt;br /&gt;
== Getting started ==&lt;br /&gt;
* [//meta.wikimedia.org/wiki/Help:Contents User&amp;#039;s Guide] for information on using the wiki software&lt;br /&gt;
* [//www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings Configuration settings list]&lt;br /&gt;
* [//www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Main_Page&amp;diff=838</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Main_Page&amp;diff=838"/>
		<updated>2020-09-27T08:57:37Z</updated>

		<summary type="html">&lt;p&gt;Marc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki describing the topics covered in the short programs section of the [//www.acsl.org ACSL] contests.&lt;br /&gt;
&lt;br /&gt;
If you&amp;#039;d like to contribute to this wiki - and we&amp;#039;d love to improve it - please shoot us an email requesting an account. Conversely, if we&amp;#039;ve linked to your material (especially YouTube videos) that you&amp;#039;d prefer that we do not reference, let us know and we will promptly remove those links.&lt;br /&gt;
&lt;br /&gt;
The categories covered during the regular season in the Classroom, Junior, Intermediate, and Senior Divisions are as follows:&lt;br /&gt;
&lt;br /&gt;
* [[Assembly Language Programming]]  &lt;br /&gt;
* [[Bit-String Flicking]] &lt;br /&gt;
* [[Boolean Algebra]]&lt;br /&gt;
* [[Computer Number Systems]]&lt;br /&gt;
* [[Data Structures]]&lt;br /&gt;
* [[Digital Electronics]] &lt;br /&gt;
* [[FSAs and Regular Expressions]] &lt;br /&gt;
* [[Graph Theory]]&lt;br /&gt;
* [[LISP]] &lt;br /&gt;
* [[Prefix/Infix/Postfix Notation]]&lt;br /&gt;
* [[Recursive Functions]]&lt;br /&gt;
* [[What Does This Program Do?]]&lt;br /&gt;
&lt;br /&gt;
The categories covered during the regular season in the Elementary Division are as follows:&lt;br /&gt;
&lt;br /&gt;
* [//classic2020.acsl.org/categories/C1Elem-ComputerNumberSystems.pdf Elementary Division: Computer Number Systems (Contest 1)]&lt;br /&gt;
* [//classic2020.acsl.org/categories/C2Elem-Prefix-Postfix-InfixNotation.pdf Elementary Division: Prefix-Postfix-Infix Notation (Contest 2)]]&lt;br /&gt;
* [//classic2020.acsl.org/categories/C3Elem-BooleanAlgebra.pdf Elementary Division: Boolean Algebra (Contest 3)]&lt;br /&gt;
* [//classic2020.acsl.org/categories/C4Elem-GraphTheory.pdf Elementary Division: Graph Theory (Contest 4)]&lt;br /&gt;
&lt;br /&gt;
The categories covered during the end-of-season invitational competition are as follows:&lt;br /&gt;
&lt;br /&gt;
* [[Advanced Regular Expressions]] &lt;br /&gt;
* [[Karnaugh Maps]] &lt;br /&gt;
&lt;br /&gt;
== Getting started ==&lt;br /&gt;
* [//meta.wikimedia.org/wiki/Help:Contents User&amp;#039;s Guide] for information on using the wiki software&lt;br /&gt;
* [//www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings Configuration settings list]&lt;br /&gt;
* [//www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=837</id>
		<title>Computer Number Systems</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=837"/>
		<updated>2020-09-02T23:38:40Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Converting to Decimal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All digital computers, from supercomputers to your smartphone, are electronic devices and ultimately can do one thing: detect whether an electrical signal is on or off. That basic information, called a &amp;#039;&amp;#039;bit&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;bi&amp;#039;&amp;#039;&amp;#039;nary digi&amp;#039;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;#039;), has two values: a 1 (or &amp;#039;&amp;#039;true&amp;#039;&amp;#039;) when the signal is on, and a 0 (of &amp;#039;&amp;#039;false&amp;#039;&amp;#039;) when the signal is off. &lt;br /&gt;
&lt;br /&gt;
Larger values can be stored by a group of bits. For example, there are 4 different values stored by 2 bits (00, 01, 10, and 11), 8 values for 3 bits (000, 001, 010, 011, 100, 101, 110, and 111), 16 values for 4 bits (0000, 0001, ..., 1111), and so on. However, large numbers, using 0s and 1s only, are quite unwieldy for humans. For example, a computer would need 19 bits to store the numbers up to 500,000! We use of different number systems to work with large binary strings that represent numbers within computers.&lt;br /&gt;
&lt;br /&gt;
== Different Number Systems ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;number system&amp;#039;&amp;#039; is the way we name and represent numbers. The number system we use in our daily life is known as &amp;#039;&amp;#039;&amp;#039;decimal number system&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;base 10&amp;#039;&amp;#039;&amp;#039; because it is based on 10 different digits: 0, 1, 2, ..., 8, and 9. The base of number is written as subscript to a number. For example, the decimal number &amp;quot;twelve thousand three hundred and forty-five&amp;quot; is written as $12345_{10}$. Without a base or explicit context, it&amp;#039;s assumed that a number is in base 10. &lt;br /&gt;
&lt;br /&gt;
In computer science, apart from the decimal system, three additional number systems are commonly used: &amp;#039;&amp;#039;&amp;#039;binary&amp;#039;&amp;#039;&amp;#039; (base-2), &amp;#039;&amp;#039;&amp;#039;octal&amp;#039;&amp;#039;&amp;#039; (base-8), and &amp;#039;&amp;#039;&amp;#039;hexadecimal&amp;#039;&amp;#039;&amp;#039; or just &amp;#039;&amp;#039;&amp;#039;hex&amp;#039;&amp;#039;&amp;#039; (base-16). Binary numbers are important because that is how numbers are stored in the computer. Octal and hexadecimal are used to represent binary numbers in a user-friendly way. Each octal symbol represents 3 binary bits and each hex digit represents 4 binary bits. For example, the decimal number 53201, stored as in the computer as the binary number 10000001111000101100, is represented by the octal number 2017054, and the hex number 81E2C. The table below compares the number systems: &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Number System&lt;br /&gt;
!Base&lt;br /&gt;
!Digits Used&lt;br /&gt;
!Examples&lt;br /&gt;
|-&lt;br /&gt;
|Binary&lt;br /&gt;
|2&lt;br /&gt;
|0,1&lt;br /&gt;
|$10110_{2}$, $10110011_{2}$&lt;br /&gt;
|-&lt;br /&gt;
|Octal&lt;br /&gt;
|8&lt;br /&gt;
|0,1,2,3,4,5,6,7&lt;br /&gt;
|$75021_{8}$, $231_{8}$, $60012_{8}$&lt;br /&gt;
|-&lt;br /&gt;
|Decimal&lt;br /&gt;
|10&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9&lt;br /&gt;
|$97425_{10}$ or simply 97425&lt;br /&gt;
|-&lt;br /&gt;
|Hexadecimal&lt;br /&gt;
|16&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F&lt;br /&gt;
|$54A2DD0F_{16}$&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In general, $N$ bits have $2^N$ different values. The computers aboard the Apollo spacecraft had 8-bit words of memory. Each word of memory could store 256 different values, and the contents were displayed using 2 hex characters.&lt;br /&gt;
&lt;br /&gt;
The following table shows the first 20 numbers in decimal, binary, octal, and hexadecimal:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
!Decimal&lt;br /&gt;
!Binary&lt;br /&gt;
!Octal&lt;br /&gt;
!Hexadecimal&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0 &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1 &lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|10&lt;br /&gt;
|2&lt;br /&gt;
|2 &lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|11&lt;br /&gt;
|3&lt;br /&gt;
|3 &lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|100&lt;br /&gt;
|4&lt;br /&gt;
|4 &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|101&lt;br /&gt;
|5&lt;br /&gt;
|5 &lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|110&lt;br /&gt;
|6&lt;br /&gt;
|6 &lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|111&lt;br /&gt;
|7&lt;br /&gt;
|7 &lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|1000&lt;br /&gt;
|10&lt;br /&gt;
|8&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|1001&lt;br /&gt;
|11&lt;br /&gt;
|9&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|1010&lt;br /&gt;
|12&lt;br /&gt;
|A&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|1011&lt;br /&gt;
|13&lt;br /&gt;
|B&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|1100&lt;br /&gt;
|14&lt;br /&gt;
|C &lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|1101&lt;br /&gt;
|15&lt;br /&gt;
|D &lt;br /&gt;
|-&lt;br /&gt;
|14&lt;br /&gt;
|1110&lt;br /&gt;
|16&lt;br /&gt;
|E &lt;br /&gt;
|-&lt;br /&gt;
|15&lt;br /&gt;
|1111&lt;br /&gt;
|17&lt;br /&gt;
|F &lt;br /&gt;
|-&lt;br /&gt;
|16&lt;br /&gt;
|10000&lt;br /&gt;
|20&lt;br /&gt;
|10 &lt;br /&gt;
|-&lt;br /&gt;
|17&lt;br /&gt;
|10001&lt;br /&gt;
|21&lt;br /&gt;
|11&lt;br /&gt;
|-&lt;br /&gt;
|18&lt;br /&gt;
|10010&lt;br /&gt;
|22&lt;br /&gt;
|12&lt;br /&gt;
|-&lt;br /&gt;
|19&lt;br /&gt;
|10011&lt;br /&gt;
|23&lt;br /&gt;
|13&lt;br /&gt;
|-&lt;br /&gt;
|20&lt;br /&gt;
|10100&lt;br /&gt;
|24&lt;br /&gt;
|14&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Converting to Decimal ==&lt;br /&gt;
&lt;br /&gt;
As we learned in the first or second grade, the decimal value of a decimal number is simply sum of each digit multiplied by its place value:&lt;br /&gt;
&lt;br /&gt;
:$12345 = 1×10^{4}+ 2×10^{3}+ 3×10^{2}+ 4×10^{1}+ 5×10^{0} =   10000 + 2000+ 300 +40+5 = 12345$&lt;br /&gt;
&lt;br /&gt;
:$3079 = 3×10^{3}+ 0×10^{2}+ 7×10^{1}+ 9×10^{0} = 3000 + 70 + 9 = 3079$&lt;br /&gt;
&lt;br /&gt;
Analogously, the decimal value of a number in an arbitrary base is the sum of each digit multiplied by its place value.  Here are some examples of converting from one base into base 10:&lt;br /&gt;
&lt;br /&gt;
:$1101_{2}  = 1 × 2^3  + 1 × 2^2  + 0 × 2^1  + 1 × 2^0 = 8 + 4  + 0  + 1  = 13_{10}$ &lt;br /&gt;
&lt;br /&gt;
:$175_{8}   = 1 × 8^2  + 7 × 8^1  + 5 × 8^0 = 1 × 64 + 7 × 8 + 5 × 1 = 64 + 56 + 5 = 125_{10}$&lt;br /&gt;
&lt;br /&gt;
:$A5E_{16}  = 10 × 16^2 + 5 × 16^1 + 14 × 16^0 = 10 × 256 + 5 × 16 + 14 × 1 = 2560 + 80 + 14 = 2654_{10}$&lt;br /&gt;
&lt;br /&gt;
== Converting from Decimal ==&lt;br /&gt;
&lt;br /&gt;
The algorithm to convert a number from an arbitrary base requires finding how many times successive powers of the base go into the number, starting with the largest power of the base less than the starting number. For example, converting 3206 from base 10 to octal proceeds as follows:&lt;br /&gt;
&lt;br /&gt;
1) The largest power of 8 that is less than or equal to 3206 is 512 ($8^3$). Divide 3206 by 512:&lt;br /&gt;
:$3206 = 6*8^3 + 234$  &lt;br /&gt;
&lt;br /&gt;
2) The next power of 8 is 64 ($8^2$). Divide 234 by 64:&lt;br /&gt;
:$234 = 3 *8^2 + 42$&lt;br /&gt;
&lt;br /&gt;
3) The next smaller power of 8 is 8 ($8^1$). Divide 42 by 8:&lt;br /&gt;
:$42 = 5*8^1 + 2$&lt;br /&gt;
&lt;br /&gt;
4) Finally, the next smaller power of 8 is 1 ($8^0$). Divide 2 by 1:&lt;br /&gt;
:$2 = 2 * 8^0$&lt;br /&gt;
&lt;br /&gt;
The answer is $6352_8$.&lt;br /&gt;
&lt;br /&gt;
== Converting between Binary, Octal, and Hexadecimal == &lt;br /&gt;
&lt;br /&gt;
Converting from octal to binary is simple: replace each octal digit by its corresponding 3 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$375_{8} = \ \ 011\ \ \ 111\ \ \ 101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from hex to binary is also simple: replace each hex digit by its corresponding 4 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$FD_{16} = \ \ 1111\ \ \ 1101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from binary to either octal or hex is pretty simple as well: group the bits by 3s or 4s (starting at the right), and convert each group:&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 10\ 000\ 001\ 111\ 000\ 101 \ 100 = 2017054_8$&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 1000\ 0001\ 1110\ 0010\ 1100 = 81E2C_{16}$&lt;br /&gt;
&lt;br /&gt;
Converting between base 8 and 16 is easy by expressing the number in base 2 (easy to do!) and then converting that number from base 2 (another easy operation)! This is shown below in Sample Problem #1.&lt;br /&gt;
&lt;br /&gt;
== Using Hexadecimal Numbers to Represent Colors ==&lt;br /&gt;
&lt;br /&gt;
Computers use hexadecimal numbers to represent various colors in computer graphics because all computer screens use combinations of red, green, and blue light or RGB to represent thousands of different colors. Two digits are used for each so the hexadecimal number “#FF0000” represents the color red, “#00FF00” represents green, and “#0000FF” represents blue.  The color black is “#000000” and white is “#FFFFFF”. &lt;br /&gt;
 &lt;br /&gt;
The hash tag or number sign is used to denote a hexadecimal number.  $FF_{16} = F (15) × 16 + F (15) × 1 = 240 + 15 = 255_{10}$ so there are 0 to 255 or 256 different shades of each color or $256^{3} = 16,777,216$ different colors. &lt;br /&gt;
 &lt;br /&gt;
The following web site has nearly every color name, along with its hex code and decimal values:  &lt;br /&gt;
 &lt;br /&gt;
:https://www.rapidtables.com/web/color/RGB_Color.html &lt;br /&gt;
 &lt;br /&gt;
For example “salmon” is “#FA8072” which represents the decimal numbers 250 (hex FA), 128 (hex 80), and 114 (hex 72).&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
[https://ryanstutorials.net/ Ryan&amp;#039;s Tutorials] covers this topic beautifully. Rather than trying to duplicate that work, we&amp;#039;ll point you to the different sections:&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/ 1. Number Systems] - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-conversions.php 2. Binary Conversions] - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the [https://ryanstutorials.net/binary-tutorial/binary-conversions.php#activities &amp;#039;&amp;#039;Activities&amp;#039;&amp;#039;] section, you can practice converting numbers. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-arithmetic.php 3. Binary Arithmetic] - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-negative-numbers.php 4. Negative Numbers] - ACSL problems will not cover how negative numbers are represented in binary. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-floating-point.php 5. Binary Fractions and Floating Point] - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section [https://ryanstutorials.net/binary-tutorial/binary-floating-point.php#convertfraction Converting to a Binary Fraction], but keep in mind that ACSL problems may also cover octal and hexadecimal fractions.&lt;br /&gt;
&lt;br /&gt;
The  [https://coolconversion.com/math/binary-octal-hexa-decimal/ CoolConversion.com online calculator] is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion. &lt;br /&gt;
&lt;br /&gt;
The AskNumbers.com site has a nice description of the conversions between [https://www.asknumbers.com/hex-to-octal.aspx binary, octal, decimal and hexadecimal] numbers. &lt;br /&gt;
&lt;br /&gt;
== Format of ACSL Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.&lt;br /&gt;
&lt;br /&gt;
To be successful in this category, you must know the following facts cold:&lt;br /&gt;
&lt;br /&gt;
# The binary value of each octal digit 0, 1, ..., 7&lt;br /&gt;
# The binary value of each hex digit 0, 1, ..., 9, A, B, C, D, E, F&lt;br /&gt;
# The decimal value of each hex digit 0, 1, ..., F  &lt;br /&gt;
# Powers  of  2,  up  to 4096&lt;br /&gt;
# Powers  of  8,  up  to 4096&lt;br /&gt;
# Powers  of  16,  up  to  65,536&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ where $x_{16}=3676_8$.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.&lt;br /&gt;
&lt;br /&gt;
An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:&lt;br /&gt;
 &lt;br /&gt;
$$\begin{align}&lt;br /&gt;
3676_8 &amp;amp;= 011 ~  110 ~ 111 ~ 110_2  &amp;amp; \text{convert each octal digit into base 2}\hfill\cr &lt;br /&gt;
&amp;amp;= 0111 ~ 1011 ~ 1110_2  &amp;amp; \text{group by 4 bits, from right-to-left}\hfill\cr&lt;br /&gt;
&amp;amp;= 7 ~ \text{B} ~ \text{E}_{16}  &amp;amp; \text{convert each group of 4 bits into a hex digit}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ in the following hexadecimal equation: $ x= \text{F5AD}_{16} - \text{69EB}_{16}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, &lt;br /&gt;
working directly in base 16 isn&amp;#039;t too hard. &lt;br /&gt;
As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.  &lt;br /&gt;
&lt;br /&gt;
:The rightmost digit becomes 2, because D-B=2.  &lt;br /&gt;
:The next column is A-E. We need to &amp;#039;&amp;#039;borrow&amp;#039;&amp;#039; a one from the 5 column, and 1A-E=C &lt;br /&gt;
:In the next column, 4-9=B, again, borrowing a 1 from the next column.&lt;br /&gt;
:Finally, the leftmost column,  E-6=8&lt;br /&gt;
&lt;br /&gt;
Combining these results of each column, we get a final answer of $8BC2_{16}$.&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
How many numbers from 100 to 200 in base 10 consist of distinct&lt;br /&gt;
ascending digits and also have distinct ascending hex digits when&lt;br /&gt;
converted to base 16? &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; There are 13 numbers that have ascending digits in both bases from 100&lt;br /&gt;
to 200.  They are (in base 10):&lt;br /&gt;
123 (7B), 124, 125, 126, 127 (7F), 137 (89), 138, 139 (8B), 156 (9C), 157, 158, 159 (9F), 189 (BD)&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely, without too many ads:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aW3qCcH6Dao&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aW3qCcH6Dao &amp;#039;&amp;#039;Number Systems - Converting Decimal, Binary and Hexadecimal&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Joe James&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
An introduction to number systems, and how to convert between decimal, binary and hexadecimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m1JtWKuTLR0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m1JtWKuTLR0 &amp;#039;&amp;#039;Lesson 2.3 : Hexadecimal Tutorial&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carl Herold&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video focuses on hexadecimal numbers: their relationship to binary numbers and how to convert to decimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/WR67syBDzew&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/WR67syBDzew &amp;#039;&amp;#039;Hexes and the Magic of Base 16 - Vaidehi Joshi - May 2017&amp;#039; (&amp;#039;&amp;#039;&amp;#039;DonutJS&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A fun introduction to hexadecimal numbers, focusing a bit &lt;br /&gt;
on using hex numbers for specifying RGB colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jvx-NrILgpE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jvx-NrILgpE &amp;#039;&amp;#039;Collins Lab: Binary &amp;amp; Hex&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Adafruit Industries&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A professionally produced video that explains the number systems, how and why binary numbers are fundamental to computer science, and why hexadecimal is important to computer programmers.  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=836</id>
		<title>Computer Number Systems</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=836"/>
		<updated>2020-09-02T23:33:20Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Converting to Decimal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All digital computers, from supercomputers to your smartphone, are electronic devices and ultimately can do one thing: detect whether an electrical signal is on or off. That basic information, called a &amp;#039;&amp;#039;bit&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;bi&amp;#039;&amp;#039;&amp;#039;nary digi&amp;#039;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;#039;), has two values: a 1 (or &amp;#039;&amp;#039;true&amp;#039;&amp;#039;) when the signal is on, and a 0 (of &amp;#039;&amp;#039;false&amp;#039;&amp;#039;) when the signal is off. &lt;br /&gt;
&lt;br /&gt;
Larger values can be stored by a group of bits. For example, there are 4 different values stored by 2 bits (00, 01, 10, and 11), 8 values for 3 bits (000, 001, 010, 011, 100, 101, 110, and 111), 16 values for 4 bits (0000, 0001, ..., 1111), and so on. However, large numbers, using 0s and 1s only, are quite unwieldy for humans. For example, a computer would need 19 bits to store the numbers up to 500,000! We use of different number systems to work with large binary strings that represent numbers within computers.&lt;br /&gt;
&lt;br /&gt;
== Different Number Systems ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;number system&amp;#039;&amp;#039; is the way we name and represent numbers. The number system we use in our daily life is known as &amp;#039;&amp;#039;&amp;#039;decimal number system&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;base 10&amp;#039;&amp;#039;&amp;#039; because it is based on 10 different digits: 0, 1, 2, ..., 8, and 9. The base of number is written as subscript to a number. For example, the decimal number &amp;quot;twelve thousand three hundred and forty-five&amp;quot; is written as $12345_{10}$. Without a base or explicit context, it&amp;#039;s assumed that a number is in base 10. &lt;br /&gt;
&lt;br /&gt;
In computer science, apart from the decimal system, three additional number systems are commonly used: &amp;#039;&amp;#039;&amp;#039;binary&amp;#039;&amp;#039;&amp;#039; (base-2), &amp;#039;&amp;#039;&amp;#039;octal&amp;#039;&amp;#039;&amp;#039; (base-8), and &amp;#039;&amp;#039;&amp;#039;hexadecimal&amp;#039;&amp;#039;&amp;#039; or just &amp;#039;&amp;#039;&amp;#039;hex&amp;#039;&amp;#039;&amp;#039; (base-16). Binary numbers are important because that is how numbers are stored in the computer. Octal and hexadecimal are used to represent binary numbers in a user-friendly way. Each octal symbol represents 3 binary bits and each hex digit represents 4 binary bits. For example, the decimal number 53201, stored as in the computer as the binary number 10000001111000101100, is represented by the octal number 2017054, and the hex number 81E2C. The table below compares the number systems: &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Number System&lt;br /&gt;
!Base&lt;br /&gt;
!Digits Used&lt;br /&gt;
!Examples&lt;br /&gt;
|-&lt;br /&gt;
|Binary&lt;br /&gt;
|2&lt;br /&gt;
|0,1&lt;br /&gt;
|$10110_{2}$, $10110011_{2}$&lt;br /&gt;
|-&lt;br /&gt;
|Octal&lt;br /&gt;
|8&lt;br /&gt;
|0,1,2,3,4,5,6,7&lt;br /&gt;
|$75021_{8}$, $231_{8}$, $60012_{8}$&lt;br /&gt;
|-&lt;br /&gt;
|Decimal&lt;br /&gt;
|10&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9&lt;br /&gt;
|$97425_{10}$ or simply 97425&lt;br /&gt;
|-&lt;br /&gt;
|Hexadecimal&lt;br /&gt;
|16&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F&lt;br /&gt;
|$54A2DD0F_{16}$&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In general, $N$ bits have $2^N$ different values. The computers aboard the Apollo spacecraft had 8-bit words of memory. Each word of memory could store 256 different values, and the contents were displayed using 2 hex characters.&lt;br /&gt;
&lt;br /&gt;
The following table shows the first 20 numbers in decimal, binary, octal, and hexadecimal:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
!Decimal&lt;br /&gt;
!Binary&lt;br /&gt;
!Octal&lt;br /&gt;
!Hexadecimal&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0 &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1 &lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|10&lt;br /&gt;
|2&lt;br /&gt;
|2 &lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|11&lt;br /&gt;
|3&lt;br /&gt;
|3 &lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|100&lt;br /&gt;
|4&lt;br /&gt;
|4 &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|101&lt;br /&gt;
|5&lt;br /&gt;
|5 &lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|110&lt;br /&gt;
|6&lt;br /&gt;
|6 &lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|111&lt;br /&gt;
|7&lt;br /&gt;
|7 &lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|1000&lt;br /&gt;
|10&lt;br /&gt;
|8&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|1001&lt;br /&gt;
|11&lt;br /&gt;
|9&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|1010&lt;br /&gt;
|12&lt;br /&gt;
|A&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|1011&lt;br /&gt;
|13&lt;br /&gt;
|B&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|1100&lt;br /&gt;
|14&lt;br /&gt;
|C &lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|1101&lt;br /&gt;
|15&lt;br /&gt;
|D &lt;br /&gt;
|-&lt;br /&gt;
|14&lt;br /&gt;
|1110&lt;br /&gt;
|16&lt;br /&gt;
|E &lt;br /&gt;
|-&lt;br /&gt;
|15&lt;br /&gt;
|1111&lt;br /&gt;
|17&lt;br /&gt;
|F &lt;br /&gt;
|-&lt;br /&gt;
|16&lt;br /&gt;
|10000&lt;br /&gt;
|20&lt;br /&gt;
|10 &lt;br /&gt;
|-&lt;br /&gt;
|17&lt;br /&gt;
|10001&lt;br /&gt;
|21&lt;br /&gt;
|11&lt;br /&gt;
|-&lt;br /&gt;
|18&lt;br /&gt;
|10010&lt;br /&gt;
|22&lt;br /&gt;
|12&lt;br /&gt;
|-&lt;br /&gt;
|19&lt;br /&gt;
|10011&lt;br /&gt;
|23&lt;br /&gt;
|13&lt;br /&gt;
|-&lt;br /&gt;
|20&lt;br /&gt;
|10100&lt;br /&gt;
|24&lt;br /&gt;
|14&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Converting to Decimal ==&lt;br /&gt;
&lt;br /&gt;
As we learned in the first or second grade, the decimal value of a decimal number is simply sum of each digit multiplied by its place value:&lt;br /&gt;
&lt;br /&gt;
:$12345 = 1×10^{4}+ 2×10^{3}+ 3×10^{2}+ 4×10^{1}+ 5×10{0} = 1×10000 + 2×1000 + 3×100 + 4×10 + 5×1 = 10000 + 2000+ 300 +40+5 = 12345$&lt;br /&gt;
&lt;br /&gt;
:$3079 = 3×10^{3}+ 0×10^{2}+ 7×10^{1}+ 9×10^{0} = 3000 + 70 + 9 = 3079$&lt;br /&gt;
&lt;br /&gt;
Analogously, the decimal value of a number in an arbitrary base is the sum of each digit multiplied by its place value.  Here are some examples of converting from one base into base 10:&lt;br /&gt;
&lt;br /&gt;
:$1101_{2}  = 1 × 2^3  + 1 × 2^2  + 0 × 2^1  + 1 × 2^0 = 8 + 4  + 0  + 1  = 13_{10}$ &lt;br /&gt;
&lt;br /&gt;
:$175_{8}   = 1 × 8^2  + 7 × 8^1  + 5 × 8^0 = 1 × 64 + 7 × 8 + 5 × 1 = 64 + 56 + 5 = 125_{10}$&lt;br /&gt;
&lt;br /&gt;
:$A5E_{16}  = 10 × 16^2 + 5 × 16^1 + 14 × 16^0 = 10 × 256 + 5 × 16 + 14 × 1 = 2560 + 80 + 14 = 2654_{10}$&lt;br /&gt;
&lt;br /&gt;
== Converting from Decimal ==&lt;br /&gt;
&lt;br /&gt;
The algorithm to convert a number from an arbitrary base requires finding how many times successive powers of the base go into the number, starting with the largest power of the base less than the starting number. For example, converting 3206 from base 10 to octal proceeds as follows:&lt;br /&gt;
&lt;br /&gt;
1) The largest power of 8 that is less than or equal to 3206 is 512 ($8^3$). Divide 3206 by 512:&lt;br /&gt;
:$3206 = 6*8^3 + 234$  &lt;br /&gt;
&lt;br /&gt;
2) The next power of 8 is 64 ($8^2$). Divide 234 by 64:&lt;br /&gt;
:$234 = 3 *8^2 + 42$&lt;br /&gt;
&lt;br /&gt;
3) The next smaller power of 8 is 8 ($8^1$). Divide 42 by 8:&lt;br /&gt;
:$42 = 5*8^1 + 2$&lt;br /&gt;
&lt;br /&gt;
4) Finally, the next smaller power of 8 is 1 ($8^0$). Divide 2 by 1:&lt;br /&gt;
:$2 = 2 * 8^0$&lt;br /&gt;
&lt;br /&gt;
The answer is $6352_8$.&lt;br /&gt;
&lt;br /&gt;
== Converting between Binary, Octal, and Hexadecimal == &lt;br /&gt;
&lt;br /&gt;
Converting from octal to binary is simple: replace each octal digit by its corresponding 3 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$375_{8} = \ \ 011\ \ \ 111\ \ \ 101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from hex to binary is also simple: replace each hex digit by its corresponding 4 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$FD_{16} = \ \ 1111\ \ \ 1101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from binary to either octal or hex is pretty simple as well: group the bits by 3s or 4s (starting at the right), and convert each group:&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 10\ 000\ 001\ 111\ 000\ 101 \ 100 = 2017054_8$&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 1000\ 0001\ 1110\ 0010\ 1100 = 81E2C_{16}$&lt;br /&gt;
&lt;br /&gt;
Converting between base 8 and 16 is easy by expressing the number in base 2 (easy to do!) and then converting that number from base 2 (another easy operation)! This is shown below in Sample Problem #1.&lt;br /&gt;
&lt;br /&gt;
== Using Hexadecimal Numbers to Represent Colors ==&lt;br /&gt;
&lt;br /&gt;
Computers use hexadecimal numbers to represent various colors in computer graphics because all computer screens use combinations of red, green, and blue light or RGB to represent thousands of different colors. Two digits are used for each so the hexadecimal number “#FF0000” represents the color red, “#00FF00” represents green, and “#0000FF” represents blue.  The color black is “#000000” and white is “#FFFFFF”. &lt;br /&gt;
 &lt;br /&gt;
The hash tag or number sign is used to denote a hexadecimal number.  $FF_{16} = F (15) × 16 + F (15) × 1 = 240 + 15 = 255_{10}$ so there are 0 to 255 or 256 different shades of each color or $256^{3} = 16,777,216$ different colors. &lt;br /&gt;
 &lt;br /&gt;
The following web site has nearly every color name, along with its hex code and decimal values:  &lt;br /&gt;
 &lt;br /&gt;
:https://www.rapidtables.com/web/color/RGB_Color.html &lt;br /&gt;
 &lt;br /&gt;
For example “salmon” is “#FA8072” which represents the decimal numbers 250 (hex FA), 128 (hex 80), and 114 (hex 72).&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
[https://ryanstutorials.net/ Ryan&amp;#039;s Tutorials] covers this topic beautifully. Rather than trying to duplicate that work, we&amp;#039;ll point you to the different sections:&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/ 1. Number Systems] - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-conversions.php 2. Binary Conversions] - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the [https://ryanstutorials.net/binary-tutorial/binary-conversions.php#activities &amp;#039;&amp;#039;Activities&amp;#039;&amp;#039;] section, you can practice converting numbers. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-arithmetic.php 3. Binary Arithmetic] - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-negative-numbers.php 4. Negative Numbers] - ACSL problems will not cover how negative numbers are represented in binary. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-floating-point.php 5. Binary Fractions and Floating Point] - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section [https://ryanstutorials.net/binary-tutorial/binary-floating-point.php#convertfraction Converting to a Binary Fraction], but keep in mind that ACSL problems may also cover octal and hexadecimal fractions.&lt;br /&gt;
&lt;br /&gt;
The  [https://coolconversion.com/math/binary-octal-hexa-decimal/ CoolConversion.com online calculator] is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion. &lt;br /&gt;
&lt;br /&gt;
The AskNumbers.com site has a nice description of the conversions between [https://www.asknumbers.com/hex-to-octal.aspx binary, octal, decimal and hexadecimal] numbers. &lt;br /&gt;
&lt;br /&gt;
== Format of ACSL Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.&lt;br /&gt;
&lt;br /&gt;
To be successful in this category, you must know the following facts cold:&lt;br /&gt;
&lt;br /&gt;
# The binary value of each octal digit 0, 1, ..., 7&lt;br /&gt;
# The binary value of each hex digit 0, 1, ..., 9, A, B, C, D, E, F&lt;br /&gt;
# The decimal value of each hex digit 0, 1, ..., F  &lt;br /&gt;
# Powers  of  2,  up  to 4096&lt;br /&gt;
# Powers  of  8,  up  to 4096&lt;br /&gt;
# Powers  of  16,  up  to  65,536&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ where $x_{16}=3676_8$.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.&lt;br /&gt;
&lt;br /&gt;
An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:&lt;br /&gt;
 &lt;br /&gt;
$$\begin{align}&lt;br /&gt;
3676_8 &amp;amp;= 011 ~  110 ~ 111 ~ 110_2  &amp;amp; \text{convert each octal digit into base 2}\hfill\cr &lt;br /&gt;
&amp;amp;= 0111 ~ 1011 ~ 1110_2  &amp;amp; \text{group by 4 bits, from right-to-left}\hfill\cr&lt;br /&gt;
&amp;amp;= 7 ~ \text{B} ~ \text{E}_{16}  &amp;amp; \text{convert each group of 4 bits into a hex digit}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ in the following hexadecimal equation: $ x= \text{F5AD}_{16} - \text{69EB}_{16}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, &lt;br /&gt;
working directly in base 16 isn&amp;#039;t too hard. &lt;br /&gt;
As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.  &lt;br /&gt;
&lt;br /&gt;
:The rightmost digit becomes 2, because D-B=2.  &lt;br /&gt;
:The next column is A-E. We need to &amp;#039;&amp;#039;borrow&amp;#039;&amp;#039; a one from the 5 column, and 1A-E=C &lt;br /&gt;
:In the next column, 4-9=B, again, borrowing a 1 from the next column.&lt;br /&gt;
:Finally, the leftmost column,  E-6=8&lt;br /&gt;
&lt;br /&gt;
Combining these results of each column, we get a final answer of $8BC2_{16}$.&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
How many numbers from 100 to 200 in base 10 consist of distinct&lt;br /&gt;
ascending digits and also have distinct ascending hex digits when&lt;br /&gt;
converted to base 16? &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; There are 13 numbers that have ascending digits in both bases from 100&lt;br /&gt;
to 200.  They are (in base 10):&lt;br /&gt;
123 (7B), 124, 125, 126, 127 (7F), 137 (89), 138, 139 (8B), 156 (9C), 157, 158, 159 (9F), 189 (BD)&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely, without too many ads:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aW3qCcH6Dao&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aW3qCcH6Dao &amp;#039;&amp;#039;Number Systems - Converting Decimal, Binary and Hexadecimal&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Joe James&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
An introduction to number systems, and how to convert between decimal, binary and hexadecimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m1JtWKuTLR0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m1JtWKuTLR0 &amp;#039;&amp;#039;Lesson 2.3 : Hexadecimal Tutorial&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carl Herold&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video focuses on hexadecimal numbers: their relationship to binary numbers and how to convert to decimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/WR67syBDzew&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/WR67syBDzew &amp;#039;&amp;#039;Hexes and the Magic of Base 16 - Vaidehi Joshi - May 2017&amp;#039; (&amp;#039;&amp;#039;&amp;#039;DonutJS&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A fun introduction to hexadecimal numbers, focusing a bit &lt;br /&gt;
on using hex numbers for specifying RGB colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jvx-NrILgpE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jvx-NrILgpE &amp;#039;&amp;#039;Collins Lab: Binary &amp;amp; Hex&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Adafruit Industries&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A professionally produced video that explains the number systems, how and why binary numbers are fundamental to computer science, and why hexadecimal is important to computer programmers.  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=835</id>
		<title>Computer Number Systems</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=835"/>
		<updated>2020-09-02T23:05:07Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Decimal Values */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All digital computers, from supercomputers to your smartphone, are electronic devices and ultimately can do one thing: detect whether an electrical signal is on or off. That basic information, called a &amp;#039;&amp;#039;bit&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;bi&amp;#039;&amp;#039;&amp;#039;nary digi&amp;#039;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;#039;), has two values: a 1 (or &amp;#039;&amp;#039;true&amp;#039;&amp;#039;) when the signal is on, and a 0 (of &amp;#039;&amp;#039;false&amp;#039;&amp;#039;) when the signal is off. &lt;br /&gt;
&lt;br /&gt;
Larger values can be stored by a group of bits. For example, there are 4 different values stored by 2 bits (00, 01, 10, and 11), 8 values for 3 bits (000, 001, 010, 011, 100, 101, 110, and 111), 16 values for 4 bits (0000, 0001, ..., 1111), and so on. However, large numbers, using 0s and 1s only, are quite unwieldy for humans. For example, a computer would need 19 bits to store the numbers up to 500,000! We use of different number systems to work with large binary strings that represent numbers within computers.&lt;br /&gt;
&lt;br /&gt;
== Different Number Systems ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;number system&amp;#039;&amp;#039; is the way we name and represent numbers. The number system we use in our daily life is known as &amp;#039;&amp;#039;&amp;#039;decimal number system&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;base 10&amp;#039;&amp;#039;&amp;#039; because it is based on 10 different digits: 0, 1, 2, ..., 8, and 9. The base of number is written as subscript to a number. For example, the decimal number &amp;quot;twelve thousand three hundred and forty-five&amp;quot; is written as $12345_{10}$. Without a base or explicit context, it&amp;#039;s assumed that a number is in base 10. &lt;br /&gt;
&lt;br /&gt;
In computer science, apart from the decimal system, three additional number systems are commonly used: &amp;#039;&amp;#039;&amp;#039;binary&amp;#039;&amp;#039;&amp;#039; (base-2), &amp;#039;&amp;#039;&amp;#039;octal&amp;#039;&amp;#039;&amp;#039; (base-8), and &amp;#039;&amp;#039;&amp;#039;hexadecimal&amp;#039;&amp;#039;&amp;#039; or just &amp;#039;&amp;#039;&amp;#039;hex&amp;#039;&amp;#039;&amp;#039; (base-16). Binary numbers are important because that is how numbers are stored in the computer. Octal and hexadecimal are used to represent binary numbers in a user-friendly way. Each octal symbol represents 3 binary bits and each hex digit represents 4 binary bits. For example, the decimal number 53201, stored as in the computer as the binary number 10000001111000101100, is represented by the octal number 2017054, and the hex number 81E2C. The table below compares the number systems: &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Number System&lt;br /&gt;
!Base&lt;br /&gt;
!Digits Used&lt;br /&gt;
!Examples&lt;br /&gt;
|-&lt;br /&gt;
|Binary&lt;br /&gt;
|2&lt;br /&gt;
|0,1&lt;br /&gt;
|$10110_{2}$, $10110011_{2}$&lt;br /&gt;
|-&lt;br /&gt;
|Octal&lt;br /&gt;
|8&lt;br /&gt;
|0,1,2,3,4,5,6,7&lt;br /&gt;
|$75021_{8}$, $231_{8}$, $60012_{8}$&lt;br /&gt;
|-&lt;br /&gt;
|Decimal&lt;br /&gt;
|10&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9&lt;br /&gt;
|$97425_{10}$ or simply 97425&lt;br /&gt;
|-&lt;br /&gt;
|Hexadecimal&lt;br /&gt;
|16&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F&lt;br /&gt;
|$54A2DD0F_{16}$&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In general, $N$ bits have $2^N$ different values. The computers aboard the Apollo spacecraft had 8-bit words of memory. Each word of memory could store 256 different values, and the contents were displayed using 2 hex characters.&lt;br /&gt;
&lt;br /&gt;
The following table shows the first 20 numbers in decimal, binary, octal, and hexadecimal:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
!Decimal&lt;br /&gt;
!Binary&lt;br /&gt;
!Octal&lt;br /&gt;
!Hexadecimal&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0 &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1 &lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|10&lt;br /&gt;
|2&lt;br /&gt;
|2 &lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|11&lt;br /&gt;
|3&lt;br /&gt;
|3 &lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|100&lt;br /&gt;
|4&lt;br /&gt;
|4 &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|101&lt;br /&gt;
|5&lt;br /&gt;
|5 &lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|110&lt;br /&gt;
|6&lt;br /&gt;
|6 &lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|111&lt;br /&gt;
|7&lt;br /&gt;
|7 &lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|1000&lt;br /&gt;
|10&lt;br /&gt;
|8&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|1001&lt;br /&gt;
|11&lt;br /&gt;
|9&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|1010&lt;br /&gt;
|12&lt;br /&gt;
|A&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|1011&lt;br /&gt;
|13&lt;br /&gt;
|B&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|1100&lt;br /&gt;
|14&lt;br /&gt;
|C &lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|1101&lt;br /&gt;
|15&lt;br /&gt;
|D &lt;br /&gt;
|-&lt;br /&gt;
|14&lt;br /&gt;
|1110&lt;br /&gt;
|16&lt;br /&gt;
|E &lt;br /&gt;
|-&lt;br /&gt;
|15&lt;br /&gt;
|1111&lt;br /&gt;
|17&lt;br /&gt;
|F &lt;br /&gt;
|-&lt;br /&gt;
|16&lt;br /&gt;
|10000&lt;br /&gt;
|20&lt;br /&gt;
|10 &lt;br /&gt;
|-&lt;br /&gt;
|17&lt;br /&gt;
|10001&lt;br /&gt;
|21&lt;br /&gt;
|11&lt;br /&gt;
|-&lt;br /&gt;
|18&lt;br /&gt;
|10010&lt;br /&gt;
|22&lt;br /&gt;
|12&lt;br /&gt;
|-&lt;br /&gt;
|19&lt;br /&gt;
|10011&lt;br /&gt;
|23&lt;br /&gt;
|13&lt;br /&gt;
|-&lt;br /&gt;
|20&lt;br /&gt;
|10100&lt;br /&gt;
|24&lt;br /&gt;
|14&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Converting to Decimal ==&lt;br /&gt;
&lt;br /&gt;
The decimal value of a number in an arbitrary base is the sum of each digit multiplied by its place value.  Here are some examples of converting from one base into base 10:&lt;br /&gt;
&lt;br /&gt;
:$12345 = 1×10000 + 2×1000 + 3×100 + 4×10 + 5×1 = 1×10^{4}+ 2×10^{3}+ 3×10^{2}+ 4×10^{1}+ 5×10{0}$&lt;br /&gt;
&lt;br /&gt;
:$1101_{2}  = 1 × 2^3  + 1 × 2^2  + 0 × 2^1  + 1 × 2^0 = 8 + 4  + 0  + 1  = 13_{10}$ &lt;br /&gt;
&lt;br /&gt;
:$175_{8}   = 1 × 8^2  + 7 × 8^1  + 5 × 8^0 = 1 × 64 + 7 × 8 + 5 × 1 = 64 + 56 + 5 = 125_{10}$&lt;br /&gt;
&lt;br /&gt;
:$A5E_{16}  = 10 × 16^2 + 5 × 16^1 + 14 × 16^0 = 10 × 256 + 5 × 16 + 14 × 1 = 2560 + 80 + 14 = 2654_{10}$&lt;br /&gt;
&lt;br /&gt;
== Converting between Binary, Octal, and Hexadecimal == &lt;br /&gt;
&lt;br /&gt;
Converting from octal to binary is simple: replace each octal digit by its corresponding 3 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$375_{8} = \ \ 011\ \ \ 111\ \ \ 101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from hex to binary is also simple: replace each hex digit by its corresponding 4 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$FD_{16} = \ \ 1111\ \ \ 1101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from binary to either octal or hex is pretty simple as well: group the bits by 3s or 4s (starting at the right), and convert each group:&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 10\ 000\ 001\ 111\ 000\ 101 \ 100 = 2017054_8$&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 1000\ 0001\ 1110\ 0010\ 1100 = 81E2C_{16}$&lt;br /&gt;
&lt;br /&gt;
Converting between base 8 and 16 is easy by expressing the number in base 2 (easy to do!) and then converting that number from base 2 (another easy operation)! This is shown below in Sample Problem #1.&lt;br /&gt;
&lt;br /&gt;
== Using Hexadecimal Numbers to Represent Colors ==&lt;br /&gt;
&lt;br /&gt;
Computers use hexadecimal numbers to represent various colors in computer graphics because all computer screens use combinations of red, green, and blue light or RGB to represent thousands of different colors. Two digits are used for each so the hexadecimal number “#FF0000” represents the color red, “#00FF00” represents green, and “#0000FF” represents blue.  The color black is “#000000” and white is “#FFFFFF”. &lt;br /&gt;
 &lt;br /&gt;
The hash tag or number sign is used to denote a hexadecimal number.  $FF_{16} = F (15) × 16 + F (15) × 1 = 240 + 15 = 255_{10}$ so there are 0 to 255 or 256 different shades of each color or $256^{3} = 16,777,216$ different colors. &lt;br /&gt;
 &lt;br /&gt;
The following web site has nearly every color name, along with its hex code and decimal values:  &lt;br /&gt;
 &lt;br /&gt;
:https://www.rapidtables.com/web/color/RGB_Color.html &lt;br /&gt;
 &lt;br /&gt;
For example “salmon” is “#FA8072” which represents the decimal numbers 250 (hex FA), 128 (hex 80), and 114 (hex 72).&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
[https://ryanstutorials.net/ Ryan&amp;#039;s Tutorials] covers this topic beautifully. Rather than trying to duplicate that work, we&amp;#039;ll point you to the different sections:&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/ 1. Number Systems] - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-conversions.php 2. Binary Conversions] - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the [https://ryanstutorials.net/binary-tutorial/binary-conversions.php#activities &amp;#039;&amp;#039;Activities&amp;#039;&amp;#039;] section, you can practice converting numbers. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-arithmetic.php 3. Binary Arithmetic] - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-negative-numbers.php 4. Negative Numbers] - ACSL problems will not cover how negative numbers are represented in binary. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-floating-point.php 5. Binary Fractions and Floating Point] - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section [https://ryanstutorials.net/binary-tutorial/binary-floating-point.php#convertfraction Converting to a Binary Fraction], but keep in mind that ACSL problems may also cover octal and hexadecimal fractions.&lt;br /&gt;
&lt;br /&gt;
The  [https://coolconversion.com/math/binary-octal-hexa-decimal/ CoolConversion.com online calculator] is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion. &lt;br /&gt;
&lt;br /&gt;
The AskNumbers.com site has a nice description of the conversions between [https://www.asknumbers.com/hex-to-octal.aspx binary, octal, decimal and hexadecimal] numbers. &lt;br /&gt;
&lt;br /&gt;
== Format of ACSL Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.&lt;br /&gt;
&lt;br /&gt;
To be successful in this category, you must know the following facts cold:&lt;br /&gt;
&lt;br /&gt;
# The binary value of each octal digit 0, 1, ..., 7&lt;br /&gt;
# The binary value of each hex digit 0, 1, ..., 9, A, B, C, D, E, F&lt;br /&gt;
# The decimal value of each hex digit 0, 1, ..., F  &lt;br /&gt;
# Powers  of  2,  up  to 4096&lt;br /&gt;
# Powers  of  8,  up  to 4096&lt;br /&gt;
# Powers  of  16,  up  to  65,536&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ where $x_{16}=3676_8$.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.&lt;br /&gt;
&lt;br /&gt;
An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:&lt;br /&gt;
 &lt;br /&gt;
$$\begin{align}&lt;br /&gt;
3676_8 &amp;amp;= 011 ~  110 ~ 111 ~ 110_2  &amp;amp; \text{convert each octal digit into base 2}\hfill\cr &lt;br /&gt;
&amp;amp;= 0111 ~ 1011 ~ 1110_2  &amp;amp; \text{group by 4 bits, from right-to-left}\hfill\cr&lt;br /&gt;
&amp;amp;= 7 ~ \text{B} ~ \text{E}_{16}  &amp;amp; \text{convert each group of 4 bits into a hex digit}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ in the following hexadecimal equation: $ x= \text{F5AD}_{16} - \text{69EB}_{16}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, &lt;br /&gt;
working directly in base 16 isn&amp;#039;t too hard. &lt;br /&gt;
As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.  &lt;br /&gt;
&lt;br /&gt;
:The rightmost digit becomes 2, because D-B=2.  &lt;br /&gt;
:The next column is A-E. We need to &amp;#039;&amp;#039;borrow&amp;#039;&amp;#039; a one from the 5 column, and 1A-E=C &lt;br /&gt;
:In the next column, 4-9=B, again, borrowing a 1 from the next column.&lt;br /&gt;
:Finally, the leftmost column,  E-6=8&lt;br /&gt;
&lt;br /&gt;
Combining these results of each column, we get a final answer of $8BC2_{16}$.&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
How many numbers from 100 to 200 in base 10 consist of distinct&lt;br /&gt;
ascending digits and also have distinct ascending hex digits when&lt;br /&gt;
converted to base 16? &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; There are 13 numbers that have ascending digits in both bases from 100&lt;br /&gt;
to 200.  They are (in base 10):&lt;br /&gt;
123 (7B), 124, 125, 126, 127 (7F), 137 (89), 138, 139 (8B), 156 (9C), 157, 158, 159 (9F), 189 (BD)&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely, without too many ads:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aW3qCcH6Dao&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aW3qCcH6Dao &amp;#039;&amp;#039;Number Systems - Converting Decimal, Binary and Hexadecimal&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Joe James&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
An introduction to number systems, and how to convert between decimal, binary and hexadecimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m1JtWKuTLR0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m1JtWKuTLR0 &amp;#039;&amp;#039;Lesson 2.3 : Hexadecimal Tutorial&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carl Herold&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video focuses on hexadecimal numbers: their relationship to binary numbers and how to convert to decimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/WR67syBDzew&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/WR67syBDzew &amp;#039;&amp;#039;Hexes and the Magic of Base 16 - Vaidehi Joshi - May 2017&amp;#039; (&amp;#039;&amp;#039;&amp;#039;DonutJS&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A fun introduction to hexadecimal numbers, focusing a bit &lt;br /&gt;
on using hex numbers for specifying RGB colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jvx-NrILgpE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jvx-NrILgpE &amp;#039;&amp;#039;Collins Lab: Binary &amp;amp; Hex&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Adafruit Industries&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A professionally produced video that explains the number systems, how and why binary numbers are fundamental to computer science, and why hexadecimal is important to computer programmers.  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=834</id>
		<title>Computer Number Systems</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=834"/>
		<updated>2020-09-02T18:40:15Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Converting between Binary, Octal, and Hexadecimal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All digital computers, from supercomputers to your smartphone, are electronic devices and ultimately can do one thing: detect whether an electrical signal is on or off. That basic information, called a &amp;#039;&amp;#039;bit&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;bi&amp;#039;&amp;#039;&amp;#039;nary digi&amp;#039;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;#039;), has two values: a 1 (or &amp;#039;&amp;#039;true&amp;#039;&amp;#039;) when the signal is on, and a 0 (of &amp;#039;&amp;#039;false&amp;#039;&amp;#039;) when the signal is off. &lt;br /&gt;
&lt;br /&gt;
Larger values can be stored by a group of bits. For example, there are 4 different values stored by 2 bits (00, 01, 10, and 11), 8 values for 3 bits (000, 001, 010, 011, 100, 101, 110, and 111), 16 values for 4 bits (0000, 0001, ..., 1111), and so on. However, large numbers, using 0s and 1s only, are quite unwieldy for humans. For example, a computer would need 19 bits to store the numbers up to 500,000! We use of different number systems to work with large binary strings that represent numbers within computers.&lt;br /&gt;
&lt;br /&gt;
== Different Number Systems ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;number system&amp;#039;&amp;#039; is the way we name and represent numbers. The number system we use in our daily life is known as &amp;#039;&amp;#039;&amp;#039;decimal number system&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;base 10&amp;#039;&amp;#039;&amp;#039; because it is based on 10 different digits: 0, 1, 2, ..., 8, and 9. The base of number is written as subscript to a number. For example, the decimal number &amp;quot;twelve thousand three hundred and forty-five&amp;quot; is written as $12345_{10}$. Without a base or explicit context, it&amp;#039;s assumed that a number is in base 10. &lt;br /&gt;
&lt;br /&gt;
In computer science, apart from the decimal system, three additional number systems are commonly used: &amp;#039;&amp;#039;&amp;#039;binary&amp;#039;&amp;#039;&amp;#039; (base-2), &amp;#039;&amp;#039;&amp;#039;octal&amp;#039;&amp;#039;&amp;#039; (base-8), and &amp;#039;&amp;#039;&amp;#039;hexadecimal&amp;#039;&amp;#039;&amp;#039; or just &amp;#039;&amp;#039;&amp;#039;hex&amp;#039;&amp;#039;&amp;#039; (base-16). Binary numbers are important because that is how numbers are stored in the computer. Octal and hexadecimal are used to represent binary numbers in a user-friendly way. Each octal symbol represents 3 binary bits and each hex digit represents 4 binary bits. For example, the decimal number 53201, stored as in the computer as the binary number 10000001111000101100, is represented by the octal number 2017054, and the hex number 81E2C. The table below compares the number systems: &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Number System&lt;br /&gt;
!Base&lt;br /&gt;
!Digits Used&lt;br /&gt;
!Examples&lt;br /&gt;
|-&lt;br /&gt;
|Binary&lt;br /&gt;
|2&lt;br /&gt;
|0,1&lt;br /&gt;
|$10110_{2}$, $10110011_{2}$&lt;br /&gt;
|-&lt;br /&gt;
|Octal&lt;br /&gt;
|8&lt;br /&gt;
|0,1,2,3,4,5,6,7&lt;br /&gt;
|$75021_{8}$, $231_{8}$, $60012_{8}$&lt;br /&gt;
|-&lt;br /&gt;
|Decimal&lt;br /&gt;
|10&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9&lt;br /&gt;
|$97425_{10}$ or simply 97425&lt;br /&gt;
|-&lt;br /&gt;
|Hexadecimal&lt;br /&gt;
|16&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F&lt;br /&gt;
|$54A2DD0F_{16}$&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In general, $N$ bits have $2^N$ different values. The computers aboard the Apollo spacecraft had 8-bit words of memory. Each word of memory could store 256 different values, and the contents were displayed using 2 hex characters.&lt;br /&gt;
&lt;br /&gt;
The following table shows the first 20 numbers in decimal, binary, octal, and hexadecimal:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
!Decimal&lt;br /&gt;
!Binary&lt;br /&gt;
!Octal&lt;br /&gt;
!Hexadecimal&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0 &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1 &lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|10&lt;br /&gt;
|2&lt;br /&gt;
|2 &lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|11&lt;br /&gt;
|3&lt;br /&gt;
|3 &lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|100&lt;br /&gt;
|4&lt;br /&gt;
|4 &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|101&lt;br /&gt;
|5&lt;br /&gt;
|5 &lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|110&lt;br /&gt;
|6&lt;br /&gt;
|6 &lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|111&lt;br /&gt;
|7&lt;br /&gt;
|7 &lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|1000&lt;br /&gt;
|10&lt;br /&gt;
|8&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|1001&lt;br /&gt;
|11&lt;br /&gt;
|9&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|1010&lt;br /&gt;
|12&lt;br /&gt;
|A&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|1011&lt;br /&gt;
|13&lt;br /&gt;
|B&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|1100&lt;br /&gt;
|14&lt;br /&gt;
|C &lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|1101&lt;br /&gt;
|15&lt;br /&gt;
|D &lt;br /&gt;
|-&lt;br /&gt;
|14&lt;br /&gt;
|1110&lt;br /&gt;
|16&lt;br /&gt;
|E &lt;br /&gt;
|-&lt;br /&gt;
|15&lt;br /&gt;
|1111&lt;br /&gt;
|17&lt;br /&gt;
|F &lt;br /&gt;
|-&lt;br /&gt;
|16&lt;br /&gt;
|10000&lt;br /&gt;
|20&lt;br /&gt;
|10 &lt;br /&gt;
|-&lt;br /&gt;
|17&lt;br /&gt;
|10001&lt;br /&gt;
|21&lt;br /&gt;
|11&lt;br /&gt;
|-&lt;br /&gt;
|18&lt;br /&gt;
|10010&lt;br /&gt;
|22&lt;br /&gt;
|12&lt;br /&gt;
|-&lt;br /&gt;
|19&lt;br /&gt;
|10011&lt;br /&gt;
|23&lt;br /&gt;
|13&lt;br /&gt;
|-&lt;br /&gt;
|20&lt;br /&gt;
|10100&lt;br /&gt;
|24&lt;br /&gt;
|14&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Decimal Values ==&lt;br /&gt;
&lt;br /&gt;
The decimal value of a number in an arbitrary base is the sum of each digit multiplied by its place value.  Here are some examples of converting from one base into base 10:&lt;br /&gt;
&lt;br /&gt;
:$12345 = 1×10000 + 2×1000 + 3×100 + 4×10 + 5×1 = 1×10^{4}+ 2×10^{3}+ 3×10^{2}+ 4×10^{1}+ 5×10{0}.$&lt;br /&gt;
&lt;br /&gt;
:$1101_{2}  = 1 × 2^3  + 1 × 2^2  + 0 × 2^1  + 1 × 2^0 = 8 + 4  + 0  + 1  = 13_{10}$ &lt;br /&gt;
&lt;br /&gt;
:$175_{8}   = 1 × 8^2  + 7 × 8^1  + 5 × 8^0 = 1 × 64 + 7 × 8 + 5 × 1 = 64 + 56 + 5 = 125_{10}$. &lt;br /&gt;
&lt;br /&gt;
:$A5E_{16}  = 10 × 16^2 + 5 × 16^1 + 14 × 16^0 = 10 × 256 + 5 × 16 + 14 × 1 = 2560 + 80 + 14 = 2654_{10}$.&lt;br /&gt;
&lt;br /&gt;
== Converting between Binary, Octal, and Hexadecimal == &lt;br /&gt;
&lt;br /&gt;
Converting from octal to binary is simple: replace each octal digit by its corresponding 3 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$375_{8} = \ \ 011\ \ \ 111\ \ \ 101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from hex to binary is also simple: replace each hex digit by its corresponding 4 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$FD_{16} = \ \ 1111\ \ \ 1101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from binary to either octal or hex is pretty simple as well: group the bits by 3s or 4s (starting at the right), and convert each group:&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 10\ 000\ 001\ 111\ 000\ 101 \ 100 = 2017054_8$&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 1000\ 0001\ 1110\ 0010\ 1100 = 81E2C_{16}$&lt;br /&gt;
&lt;br /&gt;
Converting between base 8 and 16 is easy by expressing the number in base 2 (easy to do!) and then converting that number from base 2 (another easy operation)! This is shown below in Sample Problem #1.&lt;br /&gt;
&lt;br /&gt;
== Using Hexadecimal Numbers to Represent Colors ==&lt;br /&gt;
&lt;br /&gt;
Computers use hexadecimal numbers to represent various colors in computer graphics because all computer screens use combinations of red, green, and blue light or RGB to represent thousands of different colors. Two digits are used for each so the hexadecimal number “#FF0000” represents the color red, “#00FF00” represents green, and “#0000FF” represents blue.  The color black is “#000000” and white is “#FFFFFF”. &lt;br /&gt;
 &lt;br /&gt;
The hash tag or number sign is used to denote a hexadecimal number.  $FF_{16} = F (15) × 16 + F (15) × 1 = 240 + 15 = 255_{10}$ so there are 0 to 255 or 256 different shades of each color or $256^{3} = 16,777,216$ different colors. &lt;br /&gt;
 &lt;br /&gt;
The following web site has nearly every color name, along with its hex code and decimal values:  &lt;br /&gt;
 &lt;br /&gt;
:https://www.rapidtables.com/web/color/RGB_Color.html &lt;br /&gt;
 &lt;br /&gt;
For example “salmon” is “#FA8072” which represents the decimal numbers 250 (hex FA), 128 (hex 80), and 114 (hex 72).&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
[https://ryanstutorials.net/ Ryan&amp;#039;s Tutorials] covers this topic beautifully. Rather than trying to duplicate that work, we&amp;#039;ll point you to the different sections:&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/ 1. Number Systems] - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-conversions.php 2. Binary Conversions] - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the [https://ryanstutorials.net/binary-tutorial/binary-conversions.php#activities &amp;#039;&amp;#039;Activities&amp;#039;&amp;#039;] section, you can practice converting numbers. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-arithmetic.php 3. Binary Arithmetic] - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-negative-numbers.php 4. Negative Numbers] - ACSL problems will not cover how negative numbers are represented in binary. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-floating-point.php 5. Binary Fractions and Floating Point] - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section [https://ryanstutorials.net/binary-tutorial/binary-floating-point.php#convertfraction Converting to a Binary Fraction], but keep in mind that ACSL problems may also cover octal and hexadecimal fractions.&lt;br /&gt;
&lt;br /&gt;
The  [https://coolconversion.com/math/binary-octal-hexa-decimal/ CoolConversion.com online calculator] is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion. &lt;br /&gt;
&lt;br /&gt;
The AskNumbers.com site has a nice description of the conversions between [https://www.asknumbers.com/hex-to-octal.aspx binary, octal, decimal and hexadecimal] numbers. &lt;br /&gt;
&lt;br /&gt;
== Format of ACSL Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.&lt;br /&gt;
&lt;br /&gt;
To be successful in this category, you must know the following facts cold:&lt;br /&gt;
&lt;br /&gt;
# The binary value of each octal digit 0, 1, ..., 7&lt;br /&gt;
# The binary value of each hex digit 0, 1, ..., 9, A, B, C, D, E, F&lt;br /&gt;
# The decimal value of each hex digit 0, 1, ..., F  &lt;br /&gt;
# Powers  of  2,  up  to 4096&lt;br /&gt;
# Powers  of  8,  up  to 4096&lt;br /&gt;
# Powers  of  16,  up  to  65,536&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ where $x_{16}=3676_8$.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.&lt;br /&gt;
&lt;br /&gt;
An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:&lt;br /&gt;
 &lt;br /&gt;
$$\begin{align}&lt;br /&gt;
3676_8 &amp;amp;= 011 ~  110 ~ 111 ~ 110_2  &amp;amp; \text{convert each octal digit into base 2}\hfill\cr &lt;br /&gt;
&amp;amp;= 0111 ~ 1011 ~ 1110_2  &amp;amp; \text{group by 4 bits, from right-to-left}\hfill\cr&lt;br /&gt;
&amp;amp;= 7 ~ \text{B} ~ \text{E}_{16}  &amp;amp; \text{convert each group of 4 bits into a hex digit}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ in the following hexadecimal equation: $ x= \text{F5AD}_{16} - \text{69EB}_{16}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, &lt;br /&gt;
working directly in base 16 isn&amp;#039;t too hard. &lt;br /&gt;
As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.  &lt;br /&gt;
&lt;br /&gt;
:The rightmost digit becomes 2, because D-B=2.  &lt;br /&gt;
:The next column is A-E. We need to &amp;#039;&amp;#039;borrow&amp;#039;&amp;#039; a one from the 5 column, and 1A-E=C &lt;br /&gt;
:In the next column, 4-9=B, again, borrowing a 1 from the next column.&lt;br /&gt;
:Finally, the leftmost column,  E-6=8&lt;br /&gt;
&lt;br /&gt;
Combining these results of each column, we get a final answer of $8BC2_{16}$.&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
How many numbers from 100 to 200 in base 10 consist of distinct&lt;br /&gt;
ascending digits and also have distinct ascending hex digits when&lt;br /&gt;
converted to base 16? &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; There are 13 numbers that have ascending digits in both bases from 100&lt;br /&gt;
to 200.  They are (in base 10):&lt;br /&gt;
123 (7B), 124, 125, 126, 127 (7F), 137 (89), 138, 139 (8B), 156 (9C), 157, 158, 159 (9F), 189 (BD)&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely, without too many ads:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aW3qCcH6Dao&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aW3qCcH6Dao &amp;#039;&amp;#039;Number Systems - Converting Decimal, Binary and Hexadecimal&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Joe James&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
An introduction to number systems, and how to convert between decimal, binary and hexadecimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m1JtWKuTLR0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m1JtWKuTLR0 &amp;#039;&amp;#039;Lesson 2.3 : Hexadecimal Tutorial&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carl Herold&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video focuses on hexadecimal numbers: their relationship to binary numbers and how to convert to decimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/WR67syBDzew&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/WR67syBDzew &amp;#039;&amp;#039;Hexes and the Magic of Base 16 - Vaidehi Joshi - May 2017&amp;#039; (&amp;#039;&amp;#039;&amp;#039;DonutJS&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A fun introduction to hexadecimal numbers, focusing a bit &lt;br /&gt;
on using hex numbers for specifying RGB colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jvx-NrILgpE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jvx-NrILgpE &amp;#039;&amp;#039;Collins Lab: Binary &amp;amp; Hex&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Adafruit Industries&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A professionally produced video that explains the number systems, how and why binary numbers are fundamental to computer science, and why hexadecimal is important to computer programmers.  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=833</id>
		<title>Computer Number Systems</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=833"/>
		<updated>2020-09-02T16:33:15Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Different Number Systems */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All digital computers, from supercomputers to your smartphone, are electronic devices and ultimately can do one thing: detect whether an electrical signal is on or off. That basic information, called a &amp;#039;&amp;#039;bit&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;bi&amp;#039;&amp;#039;&amp;#039;nary digi&amp;#039;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;#039;), has two values: a 1 (or &amp;#039;&amp;#039;true&amp;#039;&amp;#039;) when the signal is on, and a 0 (of &amp;#039;&amp;#039;false&amp;#039;&amp;#039;) when the signal is off. &lt;br /&gt;
&lt;br /&gt;
Larger values can be stored by a group of bits. For example, there are 4 different values stored by 2 bits (00, 01, 10, and 11), 8 values for 3 bits (000, 001, 010, 011, 100, 101, 110, and 111), 16 values for 4 bits (0000, 0001, ..., 1111), and so on. However, large numbers, using 0s and 1s only, are quite unwieldy for humans. For example, a computer would need 19 bits to store the numbers up to 500,000! We use of different number systems to work with large binary strings that represent numbers within computers.&lt;br /&gt;
&lt;br /&gt;
== Different Number Systems ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;number system&amp;#039;&amp;#039; is the way we name and represent numbers. The number system we use in our daily life is known as &amp;#039;&amp;#039;&amp;#039;decimal number system&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;base 10&amp;#039;&amp;#039;&amp;#039; because it is based on 10 different digits: 0, 1, 2, ..., 8, and 9. The base of number is written as subscript to a number. For example, the decimal number &amp;quot;twelve thousand three hundred and forty-five&amp;quot; is written as $12345_{10}$. Without a base or explicit context, it&amp;#039;s assumed that a number is in base 10. &lt;br /&gt;
&lt;br /&gt;
In computer science, apart from the decimal system, three additional number systems are commonly used: &amp;#039;&amp;#039;&amp;#039;binary&amp;#039;&amp;#039;&amp;#039; (base-2), &amp;#039;&amp;#039;&amp;#039;octal&amp;#039;&amp;#039;&amp;#039; (base-8), and &amp;#039;&amp;#039;&amp;#039;hexadecimal&amp;#039;&amp;#039;&amp;#039; or just &amp;#039;&amp;#039;&amp;#039;hex&amp;#039;&amp;#039;&amp;#039; (base-16). Binary numbers are important because that is how numbers are stored in the computer. Octal and hexadecimal are used to represent binary numbers in a user-friendly way. Each octal symbol represents 3 binary bits and each hex digit represents 4 binary bits. For example, the decimal number 53201, stored as in the computer as the binary number 10000001111000101100, is represented by the octal number 2017054, and the hex number 81E2C. The table below compares the number systems: &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Number System&lt;br /&gt;
!Base&lt;br /&gt;
!Digits Used&lt;br /&gt;
!Examples&lt;br /&gt;
|-&lt;br /&gt;
|Binary&lt;br /&gt;
|2&lt;br /&gt;
|0,1&lt;br /&gt;
|$10110_{2}$, $10110011_{2}$&lt;br /&gt;
|-&lt;br /&gt;
|Octal&lt;br /&gt;
|8&lt;br /&gt;
|0,1,2,3,4,5,6,7&lt;br /&gt;
|$75021_{8}$, $231_{8}$, $60012_{8}$&lt;br /&gt;
|-&lt;br /&gt;
|Decimal&lt;br /&gt;
|10&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9&lt;br /&gt;
|$97425_{10}$ or simply 97425&lt;br /&gt;
|-&lt;br /&gt;
|Hexadecimal&lt;br /&gt;
|16&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F&lt;br /&gt;
|$54A2DD0F_{16}$&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In general, $N$ bits have $2^N$ different values. The computers aboard the Apollo spacecraft had 8-bit words of memory. Each word of memory could store 256 different values, and the contents were displayed using 2 hex characters.&lt;br /&gt;
&lt;br /&gt;
The following table shows the first 20 numbers in decimal, binary, octal, and hexadecimal:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
!Decimal&lt;br /&gt;
!Binary&lt;br /&gt;
!Octal&lt;br /&gt;
!Hexadecimal&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0 &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1 &lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|10&lt;br /&gt;
|2&lt;br /&gt;
|2 &lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|11&lt;br /&gt;
|3&lt;br /&gt;
|3 &lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|100&lt;br /&gt;
|4&lt;br /&gt;
|4 &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|101&lt;br /&gt;
|5&lt;br /&gt;
|5 &lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|110&lt;br /&gt;
|6&lt;br /&gt;
|6 &lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|111&lt;br /&gt;
|7&lt;br /&gt;
|7 &lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|1000&lt;br /&gt;
|10&lt;br /&gt;
|8&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|1001&lt;br /&gt;
|11&lt;br /&gt;
|9&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|1010&lt;br /&gt;
|12&lt;br /&gt;
|A&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|1011&lt;br /&gt;
|13&lt;br /&gt;
|B&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|1100&lt;br /&gt;
|14&lt;br /&gt;
|C &lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|1101&lt;br /&gt;
|15&lt;br /&gt;
|D &lt;br /&gt;
|-&lt;br /&gt;
|14&lt;br /&gt;
|1110&lt;br /&gt;
|16&lt;br /&gt;
|E &lt;br /&gt;
|-&lt;br /&gt;
|15&lt;br /&gt;
|1111&lt;br /&gt;
|17&lt;br /&gt;
|F &lt;br /&gt;
|-&lt;br /&gt;
|16&lt;br /&gt;
|10000&lt;br /&gt;
|20&lt;br /&gt;
|10 &lt;br /&gt;
|-&lt;br /&gt;
|17&lt;br /&gt;
|10001&lt;br /&gt;
|21&lt;br /&gt;
|11&lt;br /&gt;
|-&lt;br /&gt;
|18&lt;br /&gt;
|10010&lt;br /&gt;
|22&lt;br /&gt;
|12&lt;br /&gt;
|-&lt;br /&gt;
|19&lt;br /&gt;
|10011&lt;br /&gt;
|23&lt;br /&gt;
|13&lt;br /&gt;
|-&lt;br /&gt;
|20&lt;br /&gt;
|10100&lt;br /&gt;
|24&lt;br /&gt;
|14&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Decimal Values ==&lt;br /&gt;
&lt;br /&gt;
The decimal value of a number in an arbitrary base is the sum of each digit multiplied by its place value.  Here are some examples of converting from one base into base 10:&lt;br /&gt;
&lt;br /&gt;
:$12345 = 1×10000 + 2×1000 + 3×100 + 4×10 + 5×1 = 1×10^{4}+ 2×10^{3}+ 3×10^{2}+ 4×10^{1}+ 5×10{0}.$&lt;br /&gt;
&lt;br /&gt;
:$1101_{2}  = 1 × 2^3  + 1 × 2^2  + 0 × 2^1  + 1 × 2^0 = 8 + 4  + 0  + 1  = 13_{10}$ &lt;br /&gt;
&lt;br /&gt;
:$175_{8}   = 1 × 8^2  + 7 × 8^1  + 5 × 8^0 = 1 × 64 + 7 × 8 + 5 × 1 = 64 + 56 + 5 = 125_{10}$. &lt;br /&gt;
&lt;br /&gt;
:$A5E_{16}  = 10 × 16^2 + 5 × 16^1 + 14 × 16^0 = 10 × 256 + 5 × 16 + 14 × 1 = 2560 + 80 + 14 = 2654_{10}$.&lt;br /&gt;
&lt;br /&gt;
== Converting between Binary, Octal, and Hexadecimal == &lt;br /&gt;
&lt;br /&gt;
Converting from octal to base 2 is simple: replace each octal digit by its corresponding 3 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$375_{8} = \ \ 011\ \ \ 111\ \ \ 101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from hex to base is also simple: replace each hex digit by its corresponding 4 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$FD_{16} = \ \ 1111\ \ \ 1101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from binary to either octal or hex is pretty simple as well: group the bit by 3s or 4s (starting at the right), and convert each group:&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 10\ 000\ 001\ 111\ 000\ 101 \ 100 = 2017054_8$&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 1000\ 0001\ 1110\ 0010\ 1100 = 81E2C_{16}$&lt;br /&gt;
&lt;br /&gt;
You can convert between base 8 and 16 by expressing the number in base 2 (easy to do!) and then converting that number from base 2 (another easy operation)! This is shown below in Sample Problem #1.&lt;br /&gt;
&lt;br /&gt;
== Using Hexadecimal Numbers to Represent Colors ==&lt;br /&gt;
&lt;br /&gt;
Computers use hexadecimal numbers to represent various colors in computer graphics because all computer screens use combinations of red, green, and blue light or RGB to represent thousands of different colors. Two digits are used for each so the hexadecimal number “#FF0000” represents the color red, “#00FF00” represents green, and “#0000FF” represents blue.  The color black is “#000000” and white is “#FFFFFF”. &lt;br /&gt;
 &lt;br /&gt;
The hash tag or number sign is used to denote a hexadecimal number.  $FF_{16} = F (15) × 16 + F (15) × 1 = 240 + 15 = 255_{10}$ so there are 0 to 255 or 256 different shades of each color or $256^{3} = 16,777,216$ different colors. &lt;br /&gt;
 &lt;br /&gt;
The following web site has nearly every color name, along with its hex code and decimal values:  &lt;br /&gt;
 &lt;br /&gt;
:https://www.rapidtables.com/web/color/RGB_Color.html &lt;br /&gt;
 &lt;br /&gt;
For example “salmon” is “#FA8072” which represents the decimal numbers 250 (hex FA), 128 (hex 80), and 114 (hex 72).&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
[https://ryanstutorials.net/ Ryan&amp;#039;s Tutorials] covers this topic beautifully. Rather than trying to duplicate that work, we&amp;#039;ll point you to the different sections:&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/ 1. Number Systems] - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-conversions.php 2. Binary Conversions] - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the [https://ryanstutorials.net/binary-tutorial/binary-conversions.php#activities &amp;#039;&amp;#039;Activities&amp;#039;&amp;#039;] section, you can practice converting numbers. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-arithmetic.php 3. Binary Arithmetic] - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-negative-numbers.php 4. Negative Numbers] - ACSL problems will not cover how negative numbers are represented in binary. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-floating-point.php 5. Binary Fractions and Floating Point] - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section [https://ryanstutorials.net/binary-tutorial/binary-floating-point.php#convertfraction Converting to a Binary Fraction], but keep in mind that ACSL problems may also cover octal and hexadecimal fractions.&lt;br /&gt;
&lt;br /&gt;
The  [https://coolconversion.com/math/binary-octal-hexa-decimal/ CoolConversion.com online calculator] is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion. &lt;br /&gt;
&lt;br /&gt;
The AskNumbers.com site has a nice description of the conversions between [https://www.asknumbers.com/hex-to-octal.aspx binary, octal, decimal and hexadecimal] numbers. &lt;br /&gt;
&lt;br /&gt;
== Format of ACSL Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.&lt;br /&gt;
&lt;br /&gt;
To be successful in this category, you must know the following facts cold:&lt;br /&gt;
&lt;br /&gt;
# The binary value of each octal digit 0, 1, ..., 7&lt;br /&gt;
# The binary value of each hex digit 0, 1, ..., 9, A, B, C, D, E, F&lt;br /&gt;
# The decimal value of each hex digit 0, 1, ..., F  &lt;br /&gt;
# Powers  of  2,  up  to 4096&lt;br /&gt;
# Powers  of  8,  up  to 4096&lt;br /&gt;
# Powers  of  16,  up  to  65,536&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ where $x_{16}=3676_8$.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.&lt;br /&gt;
&lt;br /&gt;
An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:&lt;br /&gt;
 &lt;br /&gt;
$$\begin{align}&lt;br /&gt;
3676_8 &amp;amp;= 011 ~  110 ~ 111 ~ 110_2  &amp;amp; \text{convert each octal digit into base 2}\hfill\cr &lt;br /&gt;
&amp;amp;= 0111 ~ 1011 ~ 1110_2  &amp;amp; \text{group by 4 bits, from right-to-left}\hfill\cr&lt;br /&gt;
&amp;amp;= 7 ~ \text{B} ~ \text{E}_{16}  &amp;amp; \text{convert each group of 4 bits into a hex digit}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ in the following hexadecimal equation: $ x= \text{F5AD}_{16} - \text{69EB}_{16}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, &lt;br /&gt;
working directly in base 16 isn&amp;#039;t too hard. &lt;br /&gt;
As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.  &lt;br /&gt;
&lt;br /&gt;
:The rightmost digit becomes 2, because D-B=2.  &lt;br /&gt;
:The next column is A-E. We need to &amp;#039;&amp;#039;borrow&amp;#039;&amp;#039; a one from the 5 column, and 1A-E=C &lt;br /&gt;
:In the next column, 4-9=B, again, borrowing a 1 from the next column.&lt;br /&gt;
:Finally, the leftmost column,  E-6=8&lt;br /&gt;
&lt;br /&gt;
Combining these results of each column, we get a final answer of $8BC2_{16}$.&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
How many numbers from 100 to 200 in base 10 consist of distinct&lt;br /&gt;
ascending digits and also have distinct ascending hex digits when&lt;br /&gt;
converted to base 16? &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; There are 13 numbers that have ascending digits in both bases from 100&lt;br /&gt;
to 200.  They are (in base 10):&lt;br /&gt;
123 (7B), 124, 125, 126, 127 (7F), 137 (89), 138, 139 (8B), 156 (9C), 157, 158, 159 (9F), 189 (BD)&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely, without too many ads:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aW3qCcH6Dao&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aW3qCcH6Dao &amp;#039;&amp;#039;Number Systems - Converting Decimal, Binary and Hexadecimal&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Joe James&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
An introduction to number systems, and how to convert between decimal, binary and hexadecimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m1JtWKuTLR0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m1JtWKuTLR0 &amp;#039;&amp;#039;Lesson 2.3 : Hexadecimal Tutorial&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carl Herold&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video focuses on hexadecimal numbers: their relationship to binary numbers and how to convert to decimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/WR67syBDzew&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/WR67syBDzew &amp;#039;&amp;#039;Hexes and the Magic of Base 16 - Vaidehi Joshi - May 2017&amp;#039; (&amp;#039;&amp;#039;&amp;#039;DonutJS&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A fun introduction to hexadecimal numbers, focusing a bit &lt;br /&gt;
on using hex numbers for specifying RGB colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jvx-NrILgpE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jvx-NrILgpE &amp;#039;&amp;#039;Collins Lab: Binary &amp;amp; Hex&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Adafruit Industries&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A professionally produced video that explains the number systems, how and why binary numbers are fundamental to computer science, and why hexadecimal is important to computer programmers.  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Karnaugh_Map&amp;diff=832</id>
		<title>Karnaugh Map</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Karnaugh_Map&amp;diff=832"/>
		<updated>2020-09-02T16:31:07Z</updated>

		<summary type="html">&lt;p&gt;Marc: Marc moved page Karnaugh Map to Karnaugh Maps&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Karnaugh Maps]]&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Karnaugh_Maps&amp;diff=831</id>
		<title>Karnaugh Maps</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Karnaugh_Maps&amp;diff=831"/>
		<updated>2020-09-02T16:31:07Z</updated>

		<summary type="html">&lt;p&gt;Marc: Marc moved page Karnaugh Map to Karnaugh Maps&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
Logic design implies the analysis, synthesis, minimization, and implementation of binary functions.&lt;br /&gt;
Combinational logic refers to networks whose output is strictly dependent on the inputs. The analysis of such networks requires first the writing of the Boolean  algebraic equation representative of the network, and then the complete characterization of the output as a result of all the possible combinations of the inputs.&lt;br /&gt;
Minimization involves reducing the Boolean algebraic expression to some minimal form. &amp;lt;br /&amp;gt;&lt;br /&gt;
Any minimization tool in Boolean is based on the algebraic theorems. Algebraic reduction of Boolean functions is not easy and requires considerable experience, judgement and luck. It becomes more apparent as the complexity of the function increases.&lt;br /&gt;
&lt;br /&gt;
For example the two input variable expression as $ A \overline{B}  + \overline{A}  \overline{B}$ is obviously dependent only on $ \overline{B} $. But it is not so obvious that the following three input expression $ A \overline{B} + \overline{B} C + \overline{A} C $ is represented by $ A \overline{B} + \overline{A} C $ . &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a result extensive effort has been devoted toward developing techniques, aids or tools, that will allow the logic designer to minimize a function.  The Venn diagram, Veitch diagram, Karnaugh map, Quine-McCluskey method, and other techniques have all been developed with but one objective-to allow the designed to arrive at a minimal expression as rapidly as possible with the least amount of effort.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Among these methods the &amp;#039;&amp;#039;&amp;#039;Karnaugh Maps&amp;#039;&amp;#039;&amp;#039; (made by G. Karnaugh in 1953) will be presented bellow.&lt;br /&gt;
&lt;br /&gt;
The Karnaugh map is an orderly arrangement of squares with assignments such that the difference between any two adjacent squares is a one-variable change. The map must contain a square or cell for each unique combination of input variables. A map for two variables A and B must have four cells, because there are 2&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; different combinations of two input variables. A map for three variables A, B and C must contain 2&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt; or eight cells, and a map on n variables must contain 2&amp;lt;sup&amp;gt;n&amp;lt;/sup&amp;gt; cells. An assignment of 1 for uncomplemented variable and 0 for a complemented variable is made. For instance, a term $ A \overline{B} C $ is equivalent to the binary notations 101. The table bellow shows the ways to define each cell of two, three and four variables functions. &amp;lt;br/&amp;gt;&lt;br /&gt;
The alphabetical input variables are identified at the upper left-hand corner of the box. For example, for three input variable function, the diagonal lines indicates that the variables A and B are represented by the binary notations across the top of the matrix (which is a Gray Code with the unique property of only a single bit change when going from one state to the next) and are contained in the vertical column below each assignment. The variable C is designed down the side of the matrix and is represented by horizontal rows within the matrix. Each cell represents a unique combination of the variables. &lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;Karnaugh map&amp;#039;&amp;#039;&amp;#039; technique is thought to be the most valuable tool available for dealing with Boolean functions. It provides instant recognition of the basic patterns, can be used to obtain all possible combinations and minimal terms, and is easily applied to all varieties of complex problems. Minimization with the map is accomplished through recognition of basic patterns.&amp;lt;br /&amp;gt;&lt;br /&gt;
The appearance of 1’s in adjacent cells immediately identifies the presence of a redundant variable. &amp;lt;br /&amp;gt;&lt;br /&gt;
The following table illustrates some examples of minimizing with two, three, four and five-variable map.&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This table illustrates the grouping of one, two, four, eight and sixteen cells, depending on the number of inputs. For example, in a four-variable map, the grouping of two cells eliminates one variable, the grouping of four cells eliminates two variables, and the grouping of eight cells eliminates three variables. The rule is the same for different number of input variables. &amp;lt;br/&amp;gt;&lt;br /&gt;
Any given grouping of 1’s in the Karnaugh map is identified by a product form. &amp;lt;br/&amp;gt;&lt;br /&gt;
Minimization involves the gathering of the various groups in the most efficient manner. The mapping of a sum of product terms is accomplished by inserting a 1 in each cell of a map containing a particular product term. &amp;lt;br/&amp;gt;&lt;br /&gt;
The advantage of the map is that it gives a clear and complete picture of the function. It can immediately be determined if the reduction is unique or if there exist other minimal expressions.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Karnaugh Map examples =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
[[File:T21.jpg|152px]]&lt;br /&gt;
|| &lt;br /&gt;
[[File:T22.jpg|152px]]&lt;br /&gt;
||&lt;br /&gt;
[[File:T23.jpg|152px]]&lt;br /&gt;
|| &lt;br /&gt;
[[File:T24.jpg|152px]]&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
[[File:T31.jpg|256px]]&lt;br /&gt;
|| &lt;br /&gt;
[[File:T32.jpg|256px]]&lt;br /&gt;
||&lt;br /&gt;
[[File:T33.jpg|256px]]&lt;br /&gt;
|| &lt;br /&gt;
[[File:T34.jpg|256px]]&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
[[File:T35.jpg|256px]]&lt;br /&gt;
|| &lt;br /&gt;
[[File:T36.jpg|256px]]&lt;br /&gt;
||&lt;br /&gt;
[[File:T37.jpg|256px]]&lt;br /&gt;
|| &lt;br /&gt;
[[File:T38.jpg|256px]]&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
[[File:T41.jpg|256px]]&lt;br /&gt;
|| &lt;br /&gt;
[[File:T42.jpg|256px]]&lt;br /&gt;
||&lt;br /&gt;
[[File:T43.jpg|256px]]&lt;br /&gt;
|| &lt;br /&gt;
[[File:T44.jpg|256px]]&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
[[File:T45.jpg|256px]]&lt;br /&gt;
|| &lt;br /&gt;
[[File:T47.jpg|256px]]&lt;br /&gt;
||&lt;br /&gt;
[[File:T48.jpg|256px]]&lt;br /&gt;
|| &lt;br /&gt;
[[File:T49.jpg|256px]]&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
[[File:T410.jpg|256px]]&lt;br /&gt;
|| &lt;br /&gt;
[[File:T411.jpg|256px]]&lt;br /&gt;
||&lt;br /&gt;
[[File:T412.jpg|256px]]&lt;br /&gt;
|| &lt;br /&gt;
[[File:T413.jpg|256px]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;525pt&amp;quot;|[[File:T71.jpg|469px]] ||width=&amp;quot;525pt&amp;quot;| [[File:T72.jpg|469px]]&lt;br /&gt;
|-&lt;br /&gt;
|width=&amp;quot;525pt&amp;quot;|[[File:T73.jpg|469px]] ||width=&amp;quot;525pt&amp;quot;| [[File:T75.jpg|469px]] &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; RULES SUMMARY&amp;#039;&amp;#039;&amp;#039;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
No zeros allowed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
No diagonals.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Only power of 2 number of cells in each group.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Groups should be as large as possible.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every one must be in at least one group.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overlapping allowed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wrap around allowed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fewest number of groups possible.&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
= Sample problems =&lt;br /&gt;
== Sample problem 1 ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; Karnaugh Map to minimize a digital circuit &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Initial circuit !! Karnaugh Map !! AND/OR circuit&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|width=&amp;quot;425pt&amp;quot;|&amp;lt;center&amp;gt; [[File:C2IN1.jpg|380px]]&amp;lt;/center&amp;gt; ||width=&amp;quot;288pt&amp;quot;| [[File:T2IN1.jpg|160px]] ||width=&amp;quot;380pt&amp;quot;| &amp;lt;center&amp;gt;[[File:C2OUT1.jpg|190px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
== Sample problem 2 ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; Karnaugh Map to minimize a digital circuit &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Initial circuit !! Karnaugh Map !! AND/OR circuit&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| [[File:CIR6_A.jpg|420px]]  || [[File:T6n.jpg|290px]] || [[File:c6b.jpg|380px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Sample problem 3 ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; Karnaugh Map to minimize a digital circuit &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Initial circuit !! Karnaugh Map !! AND/OR circuit&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| [[File:C4IN1.jpg|460px]]  || [[File:T4IN1N.jpg|286px]] ||width=&amp;quot;346pt&amp;quot;| &amp;lt;center&amp;gt; [[File:C4OUT1.jpg|230px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Sample problem 4 ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; Simplify the following Boolean three variable equation using Karnaugh map. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Initial function !! Karnaugh Map !! Minimal function&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| $ f = \overline{A} \overline{B} \overline{C}  + A B \overline{C}  +A \overline{B} + \overline{A} \overline{C} $  || [[File:TEX4.jpg|286px]] || $ f = \overline{C} + A \overline{B} $  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Sample problem 5 ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; Simplify the following Boolean four variable equation using Karnaugh map. &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Initial function !! Karnaugh Map !! Minimal function&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| $ f = A \overline{B} \overline{D} + A B \overline{C} \overline{D} + A B C + B \overline{C} D + \overline{A} B C D $  || [[File:TEX5.jpg|286px]] || $ f = B D + A \overline{D} $ &lt;br /&gt;
|}&lt;br /&gt;
1. William E. Wickes, Logic Design with Integrated Circuits, John Willey &amp;amp; Sons, Inc, New York-London-Sydney&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=830</id>
		<title>Computer Number Systems</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=830"/>
		<updated>2020-09-02T16:19:31Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Decimal Values */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All digital computers, from supercomputers to your smartphone, are electronic devices and ultimately can do one thing: detect whether an electrical signal is on or off. That basic information, called a &amp;#039;&amp;#039;bit&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;bi&amp;#039;&amp;#039;&amp;#039;nary digi&amp;#039;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;#039;), has two values: a 1 (or &amp;#039;&amp;#039;true&amp;#039;&amp;#039;) when the signal is on, and a 0 (of &amp;#039;&amp;#039;false&amp;#039;&amp;#039;) when the signal is off. &lt;br /&gt;
&lt;br /&gt;
Larger values can be stored by a group of bits. For example, there are 4 different values stored by 2 bits (00, 01, 10, and 11), 8 values for 3 bits (000, 001, 010, 011, 100, 101, 110, and 111), 16 values for 4 bits (0000, 0001, ..., 1111), and so on. However, large numbers, using 0s and 1s only, are quite unwieldy for humans. For example, a computer would need 19 bits to store the numbers up to 500,000! We use of different number systems to work with large binary strings that represent numbers within computers.&lt;br /&gt;
&lt;br /&gt;
== Different Number Systems ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;number system&amp;#039;&amp;#039; is the way we name and represent numbers. The number system we use in our daily life is known as &amp;#039;&amp;#039;&amp;#039;decimal number system&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;base 10&amp;#039;&amp;#039;&amp;#039; because it is based on 10 different digits: 0, 1, 2, ..., 8, and 9. The base of number is written as subscript to a number. For example, the decimal number &amp;quot;twelve thousand three hundred and forty-five&amp;quot; is written as $12345_{10}$. Without a base, it&amp;#039;s assumed that a number is in base 10. &lt;br /&gt;
&lt;br /&gt;
In computer science, apart from the decimal system, three additional number systems are commonly used: &amp;#039;&amp;#039;&amp;#039;binary&amp;#039;&amp;#039;&amp;#039; (base-2), &amp;#039;&amp;#039;&amp;#039;octal&amp;#039;&amp;#039;&amp;#039; (base-8), and &amp;#039;&amp;#039;&amp;#039;hexadecimal&amp;#039;&amp;#039;&amp;#039; or just &amp;#039;&amp;#039;&amp;#039;hex&amp;#039;&amp;#039;&amp;#039; (base-16). Binary numbers are important because that is how number are stored in the computer. Octal and hexadecimal are used to represent binary numbers is a user-friendly way. Each octal symbol represents 3 binary bits and each hex digit represents 4 binary bits. For example, the decimal number 53201, stored as in the computer as the binary number 10000001111000101100, is represented by the octal number 2017054, and the hex number 81E2C. The table below compares the number systems: &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Number System&lt;br /&gt;
!Base&lt;br /&gt;
!Digits Used&lt;br /&gt;
!Examples&lt;br /&gt;
|-&lt;br /&gt;
|Binary&lt;br /&gt;
|2&lt;br /&gt;
|0,1&lt;br /&gt;
|$10110_{2}$, $10110011_{2}$&lt;br /&gt;
|-&lt;br /&gt;
|Octal&lt;br /&gt;
|8&lt;br /&gt;
|0,1,2,3,4,5,6,7&lt;br /&gt;
|$75021_{8}$, $231_{8}$, $60012_{8}$&lt;br /&gt;
|-&lt;br /&gt;
|Decimal&lt;br /&gt;
|10&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9&lt;br /&gt;
|$97425_{10}$ or simply 97425&lt;br /&gt;
|-&lt;br /&gt;
|Hexadecimal&lt;br /&gt;
|16&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F&lt;br /&gt;
|$54A2DD0F_{16}$&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In general, $N$ bits have $2^N$ different values. The computers aboard the Apollo spacecraft had 8-bit words of memory. Each word of memory could store 256 different values, and the contents were displayed using 2 hex characters.&lt;br /&gt;
&lt;br /&gt;
The following table shows the first 20 numbers in decimal, binary, octal, and hexadecimal:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
!Decimal&lt;br /&gt;
!Binary&lt;br /&gt;
!Octal&lt;br /&gt;
!Hexadecimal&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0 &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1 &lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|10&lt;br /&gt;
|2&lt;br /&gt;
|2 &lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|11&lt;br /&gt;
|3&lt;br /&gt;
|3 &lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|100&lt;br /&gt;
|4&lt;br /&gt;
|4 &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|101&lt;br /&gt;
|5&lt;br /&gt;
|5 &lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|110&lt;br /&gt;
|6&lt;br /&gt;
|6 &lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|111&lt;br /&gt;
|7&lt;br /&gt;
|7 &lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|1000&lt;br /&gt;
|10&lt;br /&gt;
|8&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|1001&lt;br /&gt;
|11&lt;br /&gt;
|9&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|1010&lt;br /&gt;
|12&lt;br /&gt;
|A&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|1011&lt;br /&gt;
|13&lt;br /&gt;
|B&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|1100&lt;br /&gt;
|14&lt;br /&gt;
|C &lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|1101&lt;br /&gt;
|15&lt;br /&gt;
|D &lt;br /&gt;
|-&lt;br /&gt;
|14&lt;br /&gt;
|1110&lt;br /&gt;
|16&lt;br /&gt;
|E &lt;br /&gt;
|-&lt;br /&gt;
|15&lt;br /&gt;
|1111&lt;br /&gt;
|17&lt;br /&gt;
|F &lt;br /&gt;
|-&lt;br /&gt;
|16&lt;br /&gt;
|10000&lt;br /&gt;
|20&lt;br /&gt;
|10 &lt;br /&gt;
|-&lt;br /&gt;
|17&lt;br /&gt;
|10001&lt;br /&gt;
|21&lt;br /&gt;
|11&lt;br /&gt;
|-&lt;br /&gt;
|18&lt;br /&gt;
|10010&lt;br /&gt;
|22&lt;br /&gt;
|12&lt;br /&gt;
|-&lt;br /&gt;
|19&lt;br /&gt;
|10011&lt;br /&gt;
|23&lt;br /&gt;
|13&lt;br /&gt;
|-&lt;br /&gt;
|20&lt;br /&gt;
|10100&lt;br /&gt;
|24&lt;br /&gt;
|14&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
== Decimal Values ==&lt;br /&gt;
&lt;br /&gt;
The decimal value of a number in an arbitrary base is the sum of each digit multiplied by its place value.  Here are some examples of converting from one base into base 10:&lt;br /&gt;
&lt;br /&gt;
:$12345 = 1×10000 + 2×1000 + 3×100 + 4×10 + 5×1 = 1×10^{4}+ 2×10^{3}+ 3×10^{2}+ 4×10^{1}+ 5×10{0}.$&lt;br /&gt;
&lt;br /&gt;
:$1101_{2}  = 1 × 2^3  + 1 × 2^2  + 0 × 2^1  + 1 × 2^0 = 8 + 4  + 0  + 1  = 13_{10}$ &lt;br /&gt;
&lt;br /&gt;
:$175_{8}   = 1 × 8^2  + 7 × 8^1  + 5 × 8^0 = 1 × 64 + 7 × 8 + 5 × 1 = 64 + 56 + 5 = 125_{10}$. &lt;br /&gt;
&lt;br /&gt;
:$A5E_{16}  = 10 × 16^2 + 5 × 16^1 + 14 × 16^0 = 10 × 256 + 5 × 16 + 14 × 1 = 2560 + 80 + 14 = 2654_{10}$.&lt;br /&gt;
&lt;br /&gt;
== Converting between Binary, Octal, and Hexadecimal == &lt;br /&gt;
&lt;br /&gt;
Converting from octal to base 2 is simple: replace each octal digit by its corresponding 3 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$375_{8} = \ \ 011\ \ \ 111\ \ \ 101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from hex to base is also simple: replace each hex digit by its corresponding 4 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$FD_{16} = \ \ 1111\ \ \ 1101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from binary to either octal or hex is pretty simple as well: group the bit by 3s or 4s (starting at the right), and convert each group:&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 10\ 000\ 001\ 111\ 000\ 101 \ 100 = 2017054_8$&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 1000\ 0001\ 1110\ 0010\ 1100 = 81E2C_{16}$&lt;br /&gt;
&lt;br /&gt;
You can convert between base 8 and 16 by expressing the number in base 2 (easy to do!) and then converting that number from base 2 (another easy operation)! This is shown below in Sample Problem #1.&lt;br /&gt;
&lt;br /&gt;
== Using Hexadecimal Numbers to Represent Colors ==&lt;br /&gt;
&lt;br /&gt;
Computers use hexadecimal numbers to represent various colors in computer graphics because all computer screens use combinations of red, green, and blue light or RGB to represent thousands of different colors. Two digits are used for each so the hexadecimal number “#FF0000” represents the color red, “#00FF00” represents green, and “#0000FF” represents blue.  The color black is “#000000” and white is “#FFFFFF”. &lt;br /&gt;
 &lt;br /&gt;
The hash tag or number sign is used to denote a hexadecimal number.  $FF_{16} = F (15) × 16 + F (15) × 1 = 240 + 15 = 255_{10}$ so there are 0 to 255 or 256 different shades of each color or $256^{3} = 16,777,216$ different colors. &lt;br /&gt;
 &lt;br /&gt;
The following web site has nearly every color name, along with its hex code and decimal values:  &lt;br /&gt;
 &lt;br /&gt;
:https://www.rapidtables.com/web/color/RGB_Color.html &lt;br /&gt;
 &lt;br /&gt;
For example “salmon” is “#FA8072” which represents the decimal numbers 250 (hex FA), 128 (hex 80), and 114 (hex 72).&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
[https://ryanstutorials.net/ Ryan&amp;#039;s Tutorials] covers this topic beautifully. Rather than trying to duplicate that work, we&amp;#039;ll point you to the different sections:&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/ 1. Number Systems] - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-conversions.php 2. Binary Conversions] - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the [https://ryanstutorials.net/binary-tutorial/binary-conversions.php#activities &amp;#039;&amp;#039;Activities&amp;#039;&amp;#039;] section, you can practice converting numbers. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-arithmetic.php 3. Binary Arithmetic] - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-negative-numbers.php 4. Negative Numbers] - ACSL problems will not cover how negative numbers are represented in binary. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-floating-point.php 5. Binary Fractions and Floating Point] - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section [https://ryanstutorials.net/binary-tutorial/binary-floating-point.php#convertfraction Converting to a Binary Fraction], but keep in mind that ACSL problems may also cover octal and hexadecimal fractions.&lt;br /&gt;
&lt;br /&gt;
The  [https://coolconversion.com/math/binary-octal-hexa-decimal/ CoolConversion.com online calculator] is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion. &lt;br /&gt;
&lt;br /&gt;
The AskNumbers.com site has a nice description of the conversions between [https://www.asknumbers.com/hex-to-octal.aspx binary, octal, decimal and hexadecimal] numbers. &lt;br /&gt;
&lt;br /&gt;
== Format of ACSL Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.&lt;br /&gt;
&lt;br /&gt;
To be successful in this category, you must know the following facts cold:&lt;br /&gt;
&lt;br /&gt;
# The binary value of each octal digit 0, 1, ..., 7&lt;br /&gt;
# The binary value of each hex digit 0, 1, ..., 9, A, B, C, D, E, F&lt;br /&gt;
# The decimal value of each hex digit 0, 1, ..., F  &lt;br /&gt;
# Powers  of  2,  up  to 4096&lt;br /&gt;
# Powers  of  8,  up  to 4096&lt;br /&gt;
# Powers  of  16,  up  to  65,536&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ where $x_{16}=3676_8$.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.&lt;br /&gt;
&lt;br /&gt;
An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:&lt;br /&gt;
 &lt;br /&gt;
$$\begin{align}&lt;br /&gt;
3676_8 &amp;amp;= 011 ~  110 ~ 111 ~ 110_2  &amp;amp; \text{convert each octal digit into base 2}\hfill\cr &lt;br /&gt;
&amp;amp;= 0111 ~ 1011 ~ 1110_2  &amp;amp; \text{group by 4 bits, from right-to-left}\hfill\cr&lt;br /&gt;
&amp;amp;= 7 ~ \text{B} ~ \text{E}_{16}  &amp;amp; \text{convert each group of 4 bits into a hex digit}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ in the following hexadecimal equation: $ x= \text{F5AD}_{16} - \text{69EB}_{16}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, &lt;br /&gt;
working directly in base 16 isn&amp;#039;t too hard. &lt;br /&gt;
As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.  &lt;br /&gt;
&lt;br /&gt;
:The rightmost digit becomes 2, because D-B=2.  &lt;br /&gt;
:The next column is A-E. We need to &amp;#039;&amp;#039;borrow&amp;#039;&amp;#039; a one from the 5 column, and 1A-E=C &lt;br /&gt;
:In the next column, 4-9=B, again, borrowing a 1 from the next column.&lt;br /&gt;
:Finally, the leftmost column,  E-6=8&lt;br /&gt;
&lt;br /&gt;
Combining these results of each column, we get a final answer of $8BC2_{16}$.&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
How many numbers from 100 to 200 in base 10 consist of distinct&lt;br /&gt;
ascending digits and also have distinct ascending hex digits when&lt;br /&gt;
converted to base 16? &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; There are 13 numbers that have ascending digits in both bases from 100&lt;br /&gt;
to 200.  They are (in base 10):&lt;br /&gt;
123 (7B), 124, 125, 126, 127 (7F), 137 (89), 138, 139 (8B), 156 (9C), 157, 158, 159 (9F), 189 (BD)&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely, without too many ads:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aW3qCcH6Dao&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aW3qCcH6Dao &amp;#039;&amp;#039;Number Systems - Converting Decimal, Binary and Hexadecimal&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Joe James&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
An introduction to number systems, and how to convert between decimal, binary and hexadecimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m1JtWKuTLR0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m1JtWKuTLR0 &amp;#039;&amp;#039;Lesson 2.3 : Hexadecimal Tutorial&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carl Herold&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video focuses on hexadecimal numbers: their relationship to binary numbers and how to convert to decimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/WR67syBDzew&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/WR67syBDzew &amp;#039;&amp;#039;Hexes and the Magic of Base 16 - Vaidehi Joshi - May 2017&amp;#039; (&amp;#039;&amp;#039;&amp;#039;DonutJS&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A fun introduction to hexadecimal numbers, focusing a bit &lt;br /&gt;
on using hex numbers for specifying RGB colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jvx-NrILgpE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jvx-NrILgpE &amp;#039;&amp;#039;Collins Lab: Binary &amp;amp; Hex&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Adafruit Industries&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A professionally produced video that explains the number systems, how and why binary numbers are fundamental to computer science, and why hexadecimal is important to computer programmers.  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=829</id>
		<title>Computer Number Systems</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=829"/>
		<updated>2020-09-02T16:18:44Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Converting between Binary, Octal, and Hexadecimal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All digital computers, from supercomputers to your smartphone, are electronic devices and ultimately can do one thing: detect whether an electrical signal is on or off. That basic information, called a &amp;#039;&amp;#039;bit&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;bi&amp;#039;&amp;#039;&amp;#039;nary digi&amp;#039;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;#039;), has two values: a 1 (or &amp;#039;&amp;#039;true&amp;#039;&amp;#039;) when the signal is on, and a 0 (of &amp;#039;&amp;#039;false&amp;#039;&amp;#039;) when the signal is off. &lt;br /&gt;
&lt;br /&gt;
Larger values can be stored by a group of bits. For example, there are 4 different values stored by 2 bits (00, 01, 10, and 11), 8 values for 3 bits (000, 001, 010, 011, 100, 101, 110, and 111), 16 values for 4 bits (0000, 0001, ..., 1111), and so on. However, large numbers, using 0s and 1s only, are quite unwieldy for humans. For example, a computer would need 19 bits to store the numbers up to 500,000! We use of different number systems to work with large binary strings that represent numbers within computers.&lt;br /&gt;
&lt;br /&gt;
== Different Number Systems ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;number system&amp;#039;&amp;#039; is the way we name and represent numbers. The number system we use in our daily life is known as &amp;#039;&amp;#039;&amp;#039;decimal number system&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;base 10&amp;#039;&amp;#039;&amp;#039; because it is based on 10 different digits: 0, 1, 2, ..., 8, and 9. The base of number is written as subscript to a number. For example, the decimal number &amp;quot;twelve thousand three hundred and forty-five&amp;quot; is written as $12345_{10}$. Without a base, it&amp;#039;s assumed that a number is in base 10. &lt;br /&gt;
&lt;br /&gt;
In computer science, apart from the decimal system, three additional number systems are commonly used: &amp;#039;&amp;#039;&amp;#039;binary&amp;#039;&amp;#039;&amp;#039; (base-2), &amp;#039;&amp;#039;&amp;#039;octal&amp;#039;&amp;#039;&amp;#039; (base-8), and &amp;#039;&amp;#039;&amp;#039;hexadecimal&amp;#039;&amp;#039;&amp;#039; or just &amp;#039;&amp;#039;&amp;#039;hex&amp;#039;&amp;#039;&amp;#039; (base-16). Binary numbers are important because that is how number are stored in the computer. Octal and hexadecimal are used to represent binary numbers is a user-friendly way. Each octal symbol represents 3 binary bits and each hex digit represents 4 binary bits. For example, the decimal number 53201, stored as in the computer as the binary number 10000001111000101100, is represented by the octal number 2017054, and the hex number 81E2C. The table below compares the number systems: &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Number System&lt;br /&gt;
!Base&lt;br /&gt;
!Digits Used&lt;br /&gt;
!Examples&lt;br /&gt;
|-&lt;br /&gt;
|Binary&lt;br /&gt;
|2&lt;br /&gt;
|0,1&lt;br /&gt;
|$10110_{2}$, $10110011_{2}$&lt;br /&gt;
|-&lt;br /&gt;
|Octal&lt;br /&gt;
|8&lt;br /&gt;
|0,1,2,3,4,5,6,7&lt;br /&gt;
|$75021_{8}$, $231_{8}$, $60012_{8}$&lt;br /&gt;
|-&lt;br /&gt;
|Decimal&lt;br /&gt;
|10&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9&lt;br /&gt;
|$97425_{10}$ or simply 97425&lt;br /&gt;
|-&lt;br /&gt;
|Hexadecimal&lt;br /&gt;
|16&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F&lt;br /&gt;
|$54A2DD0F_{16}$&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In general, $N$ bits have $2^N$ different values. The computers aboard the Apollo spacecraft had 8-bit words of memory. Each word of memory could store 256 different values, and the contents were displayed using 2 hex characters.&lt;br /&gt;
&lt;br /&gt;
The following table shows the first 20 numbers in decimal, binary, octal, and hexadecimal:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
!Decimal&lt;br /&gt;
!Binary&lt;br /&gt;
!Octal&lt;br /&gt;
!Hexadecimal&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0 &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1 &lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|10&lt;br /&gt;
|2&lt;br /&gt;
|2 &lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|11&lt;br /&gt;
|3&lt;br /&gt;
|3 &lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|100&lt;br /&gt;
|4&lt;br /&gt;
|4 &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|101&lt;br /&gt;
|5&lt;br /&gt;
|5 &lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|110&lt;br /&gt;
|6&lt;br /&gt;
|6 &lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|111&lt;br /&gt;
|7&lt;br /&gt;
|7 &lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|1000&lt;br /&gt;
|10&lt;br /&gt;
|8&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|1001&lt;br /&gt;
|11&lt;br /&gt;
|9&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|1010&lt;br /&gt;
|12&lt;br /&gt;
|A&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|1011&lt;br /&gt;
|13&lt;br /&gt;
|B&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|1100&lt;br /&gt;
|14&lt;br /&gt;
|C &lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|1101&lt;br /&gt;
|15&lt;br /&gt;
|D &lt;br /&gt;
|-&lt;br /&gt;
|14&lt;br /&gt;
|1110&lt;br /&gt;
|16&lt;br /&gt;
|E &lt;br /&gt;
|-&lt;br /&gt;
|15&lt;br /&gt;
|1111&lt;br /&gt;
|17&lt;br /&gt;
|F &lt;br /&gt;
|-&lt;br /&gt;
|16&lt;br /&gt;
|10000&lt;br /&gt;
|20&lt;br /&gt;
|10 &lt;br /&gt;
|-&lt;br /&gt;
|17&lt;br /&gt;
|10001&lt;br /&gt;
|21&lt;br /&gt;
|11&lt;br /&gt;
|-&lt;br /&gt;
|18&lt;br /&gt;
|10010&lt;br /&gt;
|22&lt;br /&gt;
|12&lt;br /&gt;
|-&lt;br /&gt;
|19&lt;br /&gt;
|10011&lt;br /&gt;
|23&lt;br /&gt;
|13&lt;br /&gt;
|-&lt;br /&gt;
|20&lt;br /&gt;
|10100&lt;br /&gt;
|24&lt;br /&gt;
|14&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
== Decimal Values ==&lt;br /&gt;
&lt;br /&gt;
The value of a any number is the sum of each digit multiplied by its place value.  Here are some examples of converting from one base into base 10:&lt;br /&gt;
&lt;br /&gt;
:$12345 = 1×10000 + 2×1000 + 3×100 + 4×10 + 5×1 = 1×10^{4}+ 2×10^{3}+ 3×10^{2}+ 4×10^{1}+ 5×10{0}.$&lt;br /&gt;
&lt;br /&gt;
:$1101_{2}  = 1 × 2^3  + 1 × 2^2  + 0 × 2^1  + 1 × 2^0 = 8 + 4  + 0  + 1  = 13_{10}$ &lt;br /&gt;
&lt;br /&gt;
:$175_{8}   = 1 × 8^2  + 7 × 8^1  + 5 × 8^0 = 1 × 64 + 7 × 8 + 5 × 1 = 64 + 56 + 5 = 125_{10}$. &lt;br /&gt;
&lt;br /&gt;
:$A5E_{16}  = 10 × 16^2 + 5 × 16^1 + 14 × 16^0 = 10 × 256 + 5 × 16 + 14 × 1 = 2560 + 80 + 14 = 2654_{10}$.&lt;br /&gt;
&lt;br /&gt;
== Converting between Binary, Octal, and Hexadecimal == &lt;br /&gt;
&lt;br /&gt;
Converting from octal to base 2 is simple: replace each octal digit by its corresponding 3 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$375_{8} = \ \ 011\ \ \ 111\ \ \ 101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from hex to base is also simple: replace each hex digit by its corresponding 4 binary bits. For example:&lt;br /&gt;
&lt;br /&gt;
:$FD_{16} = \ \ 1111\ \ \ 1101_{2} = 11111101_2$&lt;br /&gt;
&lt;br /&gt;
Converting from binary to either octal or hex is pretty simple as well: group the bit by 3s or 4s (starting at the right), and convert each group:&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 10\ 000\ 001\ 111\ 000\ 101 \ 100 = 2017054_8$&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 1000\ 0001\ 1110\ 0010\ 1100 = 81E2C_{16}$&lt;br /&gt;
&lt;br /&gt;
You can convert between base 8 and 16 by expressing the number in base 2 (easy to do!) and then converting that number from base 2 (another easy operation)! This is shown below in Sample Problem #1.&lt;br /&gt;
&lt;br /&gt;
== Using Hexadecimal Numbers to Represent Colors ==&lt;br /&gt;
&lt;br /&gt;
Computers use hexadecimal numbers to represent various colors in computer graphics because all computer screens use combinations of red, green, and blue light or RGB to represent thousands of different colors. Two digits are used for each so the hexadecimal number “#FF0000” represents the color red, “#00FF00” represents green, and “#0000FF” represents blue.  The color black is “#000000” and white is “#FFFFFF”. &lt;br /&gt;
 &lt;br /&gt;
The hash tag or number sign is used to denote a hexadecimal number.  $FF_{16} = F (15) × 16 + F (15) × 1 = 240 + 15 = 255_{10}$ so there are 0 to 255 or 256 different shades of each color or $256^{3} = 16,777,216$ different colors. &lt;br /&gt;
 &lt;br /&gt;
The following web site has nearly every color name, along with its hex code and decimal values:  &lt;br /&gt;
 &lt;br /&gt;
:https://www.rapidtables.com/web/color/RGB_Color.html &lt;br /&gt;
 &lt;br /&gt;
For example “salmon” is “#FA8072” which represents the decimal numbers 250 (hex FA), 128 (hex 80), and 114 (hex 72).&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
[https://ryanstutorials.net/ Ryan&amp;#039;s Tutorials] covers this topic beautifully. Rather than trying to duplicate that work, we&amp;#039;ll point you to the different sections:&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/ 1. Number Systems] - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-conversions.php 2. Binary Conversions] - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the [https://ryanstutorials.net/binary-tutorial/binary-conversions.php#activities &amp;#039;&amp;#039;Activities&amp;#039;&amp;#039;] section, you can practice converting numbers. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-arithmetic.php 3. Binary Arithmetic] - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-negative-numbers.php 4. Negative Numbers] - ACSL problems will not cover how negative numbers are represented in binary. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-floating-point.php 5. Binary Fractions and Floating Point] - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section [https://ryanstutorials.net/binary-tutorial/binary-floating-point.php#convertfraction Converting to a Binary Fraction], but keep in mind that ACSL problems may also cover octal and hexadecimal fractions.&lt;br /&gt;
&lt;br /&gt;
The  [https://coolconversion.com/math/binary-octal-hexa-decimal/ CoolConversion.com online calculator] is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion. &lt;br /&gt;
&lt;br /&gt;
The AskNumbers.com site has a nice description of the conversions between [https://www.asknumbers.com/hex-to-octal.aspx binary, octal, decimal and hexadecimal] numbers. &lt;br /&gt;
&lt;br /&gt;
== Format of ACSL Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.&lt;br /&gt;
&lt;br /&gt;
To be successful in this category, you must know the following facts cold:&lt;br /&gt;
&lt;br /&gt;
# The binary value of each octal digit 0, 1, ..., 7&lt;br /&gt;
# The binary value of each hex digit 0, 1, ..., 9, A, B, C, D, E, F&lt;br /&gt;
# The decimal value of each hex digit 0, 1, ..., F  &lt;br /&gt;
# Powers  of  2,  up  to 4096&lt;br /&gt;
# Powers  of  8,  up  to 4096&lt;br /&gt;
# Powers  of  16,  up  to  65,536&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ where $x_{16}=3676_8$.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.&lt;br /&gt;
&lt;br /&gt;
An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:&lt;br /&gt;
 &lt;br /&gt;
$$\begin{align}&lt;br /&gt;
3676_8 &amp;amp;= 011 ~  110 ~ 111 ~ 110_2  &amp;amp; \text{convert each octal digit into base 2}\hfill\cr &lt;br /&gt;
&amp;amp;= 0111 ~ 1011 ~ 1110_2  &amp;amp; \text{group by 4 bits, from right-to-left}\hfill\cr&lt;br /&gt;
&amp;amp;= 7 ~ \text{B} ~ \text{E}_{16}  &amp;amp; \text{convert each group of 4 bits into a hex digit}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ in the following hexadecimal equation: $ x= \text{F5AD}_{16} - \text{69EB}_{16}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, &lt;br /&gt;
working directly in base 16 isn&amp;#039;t too hard. &lt;br /&gt;
As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.  &lt;br /&gt;
&lt;br /&gt;
:The rightmost digit becomes 2, because D-B=2.  &lt;br /&gt;
:The next column is A-E. We need to &amp;#039;&amp;#039;borrow&amp;#039;&amp;#039; a one from the 5 column, and 1A-E=C &lt;br /&gt;
:In the next column, 4-9=B, again, borrowing a 1 from the next column.&lt;br /&gt;
:Finally, the leftmost column,  E-6=8&lt;br /&gt;
&lt;br /&gt;
Combining these results of each column, we get a final answer of $8BC2_{16}$.&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
How many numbers from 100 to 200 in base 10 consist of distinct&lt;br /&gt;
ascending digits and also have distinct ascending hex digits when&lt;br /&gt;
converted to base 16? &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; There are 13 numbers that have ascending digits in both bases from 100&lt;br /&gt;
to 200.  They are (in base 10):&lt;br /&gt;
123 (7B), 124, 125, 126, 127 (7F), 137 (89), 138, 139 (8B), 156 (9C), 157, 158, 159 (9F), 189 (BD)&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely, without too many ads:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aW3qCcH6Dao&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aW3qCcH6Dao &amp;#039;&amp;#039;Number Systems - Converting Decimal, Binary and Hexadecimal&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Joe James&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
An introduction to number systems, and how to convert between decimal, binary and hexadecimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m1JtWKuTLR0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m1JtWKuTLR0 &amp;#039;&amp;#039;Lesson 2.3 : Hexadecimal Tutorial&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carl Herold&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video focuses on hexadecimal numbers: their relationship to binary numbers and how to convert to decimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/WR67syBDzew&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/WR67syBDzew &amp;#039;&amp;#039;Hexes and the Magic of Base 16 - Vaidehi Joshi - May 2017&amp;#039; (&amp;#039;&amp;#039;&amp;#039;DonutJS&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A fun introduction to hexadecimal numbers, focusing a bit &lt;br /&gt;
on using hex numbers for specifying RGB colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jvx-NrILgpE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jvx-NrILgpE &amp;#039;&amp;#039;Collins Lab: Binary &amp;amp; Hex&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Adafruit Industries&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A professionally produced video that explains the number systems, how and why binary numbers are fundamental to computer science, and why hexadecimal is important to computer programmers.  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=828</id>
		<title>Computer Number Systems</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=828"/>
		<updated>2020-09-02T16:16:34Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Decimal Values */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All digital computers, from supercomputers to your smartphone, are electronic devices and ultimately can do one thing: detect whether an electrical signal is on or off. That basic information, called a &amp;#039;&amp;#039;bit&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;bi&amp;#039;&amp;#039;&amp;#039;nary digi&amp;#039;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;#039;), has two values: a 1 (or &amp;#039;&amp;#039;true&amp;#039;&amp;#039;) when the signal is on, and a 0 (of &amp;#039;&amp;#039;false&amp;#039;&amp;#039;) when the signal is off. &lt;br /&gt;
&lt;br /&gt;
Larger values can be stored by a group of bits. For example, there are 4 different values stored by 2 bits (00, 01, 10, and 11), 8 values for 3 bits (000, 001, 010, 011, 100, 101, 110, and 111), 16 values for 4 bits (0000, 0001, ..., 1111), and so on. However, large numbers, using 0s and 1s only, are quite unwieldy for humans. For example, a computer would need 19 bits to store the numbers up to 500,000! We use of different number systems to work with large binary strings that represent numbers within computers.&lt;br /&gt;
&lt;br /&gt;
== Different Number Systems ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;number system&amp;#039;&amp;#039; is the way we name and represent numbers. The number system we use in our daily life is known as &amp;#039;&amp;#039;&amp;#039;decimal number system&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;base 10&amp;#039;&amp;#039;&amp;#039; because it is based on 10 different digits: 0, 1, 2, ..., 8, and 9. The base of number is written as subscript to a number. For example, the decimal number &amp;quot;twelve thousand three hundred and forty-five&amp;quot; is written as $12345_{10}$. Without a base, it&amp;#039;s assumed that a number is in base 10. &lt;br /&gt;
&lt;br /&gt;
In computer science, apart from the decimal system, three additional number systems are commonly used: &amp;#039;&amp;#039;&amp;#039;binary&amp;#039;&amp;#039;&amp;#039; (base-2), &amp;#039;&amp;#039;&amp;#039;octal&amp;#039;&amp;#039;&amp;#039; (base-8), and &amp;#039;&amp;#039;&amp;#039;hexadecimal&amp;#039;&amp;#039;&amp;#039; or just &amp;#039;&amp;#039;&amp;#039;hex&amp;#039;&amp;#039;&amp;#039; (base-16). Binary numbers are important because that is how number are stored in the computer. Octal and hexadecimal are used to represent binary numbers is a user-friendly way. Each octal symbol represents 3 binary bits and each hex digit represents 4 binary bits. For example, the decimal number 53201, stored as in the computer as the binary number 10000001111000101100, is represented by the octal number 2017054, and the hex number 81E2C. The table below compares the number systems: &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Number System&lt;br /&gt;
!Base&lt;br /&gt;
!Digits Used&lt;br /&gt;
!Examples&lt;br /&gt;
|-&lt;br /&gt;
|Binary&lt;br /&gt;
|2&lt;br /&gt;
|0,1&lt;br /&gt;
|$10110_{2}$, $10110011_{2}$&lt;br /&gt;
|-&lt;br /&gt;
|Octal&lt;br /&gt;
|8&lt;br /&gt;
|0,1,2,3,4,5,6,7&lt;br /&gt;
|$75021_{8}$, $231_{8}$, $60012_{8}$&lt;br /&gt;
|-&lt;br /&gt;
|Decimal&lt;br /&gt;
|10&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9&lt;br /&gt;
|$97425_{10}$ or simply 97425&lt;br /&gt;
|-&lt;br /&gt;
|Hexadecimal&lt;br /&gt;
|16&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F&lt;br /&gt;
|$54A2DD0F_{16}$&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In general, $N$ bits have $2^N$ different values. The computers aboard the Apollo spacecraft had 8-bit words of memory. Each word of memory could store 256 different values, and the contents were displayed using 2 hex characters.&lt;br /&gt;
&lt;br /&gt;
The following table shows the first 20 numbers in decimal, binary, octal, and hexadecimal:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
!Decimal&lt;br /&gt;
!Binary&lt;br /&gt;
!Octal&lt;br /&gt;
!Hexadecimal&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0 &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1 &lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|10&lt;br /&gt;
|2&lt;br /&gt;
|2 &lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|11&lt;br /&gt;
|3&lt;br /&gt;
|3 &lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|100&lt;br /&gt;
|4&lt;br /&gt;
|4 &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|101&lt;br /&gt;
|5&lt;br /&gt;
|5 &lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|110&lt;br /&gt;
|6&lt;br /&gt;
|6 &lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|111&lt;br /&gt;
|7&lt;br /&gt;
|7 &lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|1000&lt;br /&gt;
|10&lt;br /&gt;
|8&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|1001&lt;br /&gt;
|11&lt;br /&gt;
|9&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|1010&lt;br /&gt;
|12&lt;br /&gt;
|A&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|1011&lt;br /&gt;
|13&lt;br /&gt;
|B&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|1100&lt;br /&gt;
|14&lt;br /&gt;
|C &lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|1101&lt;br /&gt;
|15&lt;br /&gt;
|D &lt;br /&gt;
|-&lt;br /&gt;
|14&lt;br /&gt;
|1110&lt;br /&gt;
|16&lt;br /&gt;
|E &lt;br /&gt;
|-&lt;br /&gt;
|15&lt;br /&gt;
|1111&lt;br /&gt;
|17&lt;br /&gt;
|F &lt;br /&gt;
|-&lt;br /&gt;
|16&lt;br /&gt;
|10000&lt;br /&gt;
|20&lt;br /&gt;
|10 &lt;br /&gt;
|-&lt;br /&gt;
|17&lt;br /&gt;
|10001&lt;br /&gt;
|21&lt;br /&gt;
|11&lt;br /&gt;
|-&lt;br /&gt;
|18&lt;br /&gt;
|10010&lt;br /&gt;
|22&lt;br /&gt;
|12&lt;br /&gt;
|-&lt;br /&gt;
|19&lt;br /&gt;
|10011&lt;br /&gt;
|23&lt;br /&gt;
|13&lt;br /&gt;
|-&lt;br /&gt;
|20&lt;br /&gt;
|10100&lt;br /&gt;
|24&lt;br /&gt;
|14&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
== Decimal Values ==&lt;br /&gt;
&lt;br /&gt;
The value of a any number is the sum of each digit multiplied by its place value.  Here are some examples of converting from one base into base 10:&lt;br /&gt;
&lt;br /&gt;
:$12345 = 1×10000 + 2×1000 + 3×100 + 4×10 + 5×1 = 1×10^{4}+ 2×10^{3}+ 3×10^{2}+ 4×10^{1}+ 5×10{0}.$&lt;br /&gt;
&lt;br /&gt;
:$1101_{2}  = 1 × 2^3  + 1 × 2^2  + 0 × 2^1  + 1 × 2^0 = 8 + 4  + 0  + 1  = 13_{10}$ &lt;br /&gt;
&lt;br /&gt;
:$175_{8}   = 1 × 8^2  + 7 × 8^1  + 5 × 8^0 = 1 × 64 + 7 × 8 + 5 × 1 = 64 + 56 + 5 = 125_{10}$. &lt;br /&gt;
&lt;br /&gt;
:$A5E_{16}  = 10 × 16^2 + 5 × 16^1 + 14 × 16^0 = 10 × 256 + 5 × 16 + 14 × 1 = 2560 + 80 + 14 = 2654_{10}$.&lt;br /&gt;
&lt;br /&gt;
== Converting between Binary, Octal, and Hexadecimal == &lt;br /&gt;
&lt;br /&gt;
Converting from octal to base 2 is simple: replace each octal digit by its corresponding 3 binary bits. For example:&lt;br /&gt;
:$375_{8} = \ \ 011\ \ \ 111\ \ \ 101_{2}$&lt;br /&gt;
Converting from hex to base is also simple: replace each hex digit by its corresponding 4 binary bits. For example:&lt;br /&gt;
:$FD_{16} = \ \ 1111\ \ \ 1101_{2}$&lt;br /&gt;
Converting from binary to either octal or hex is pretty simple as well: group the bit by 3s or 4s (starting at the right), and convert each group:&lt;br /&gt;
:$10000001111000101100 = 10\ 000\ 001\ 111\ 000\ 101 \ 100 = 2017054_8$&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 1000\ 0001\ 1110\ 0010\ 1100 = 81E2C_{16}$&lt;br /&gt;
You can convert between base 8 and 16 by expressing the number in base 2 (easy to do!) and then converting that number from base 2 (another easy operation)! This is shown below in Sample Problem #1.&lt;br /&gt;
&lt;br /&gt;
== Using Hexadecimal Numbers to Represent Colors ==&lt;br /&gt;
&lt;br /&gt;
Computers use hexadecimal numbers to represent various colors in computer graphics because all computer screens use combinations of red, green, and blue light or RGB to represent thousands of different colors. Two digits are used for each so the hexadecimal number “#FF0000” represents the color red, “#00FF00” represents green, and “#0000FF” represents blue.  The color black is “#000000” and white is “#FFFFFF”. &lt;br /&gt;
 &lt;br /&gt;
The hash tag or number sign is used to denote a hexadecimal number.  $FF_{16} = F (15) × 16 + F (15) × 1 = 240 + 15 = 255_{10}$ so there are 0 to 255 or 256 different shades of each color or $256^{3} = 16,777,216$ different colors. &lt;br /&gt;
 &lt;br /&gt;
The following web site has nearly every color name, along with its hex code and decimal values:  &lt;br /&gt;
 &lt;br /&gt;
:https://www.rapidtables.com/web/color/RGB_Color.html &lt;br /&gt;
 &lt;br /&gt;
For example “salmon” is “#FA8072” which represents the decimal numbers 250 (hex FA), 128 (hex 80), and 114 (hex 72).&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
[https://ryanstutorials.net/ Ryan&amp;#039;s Tutorials] covers this topic beautifully. Rather than trying to duplicate that work, we&amp;#039;ll point you to the different sections:&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/ 1. Number Systems] - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-conversions.php 2. Binary Conversions] - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the [https://ryanstutorials.net/binary-tutorial/binary-conversions.php#activities &amp;#039;&amp;#039;Activities&amp;#039;&amp;#039;] section, you can practice converting numbers. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-arithmetic.php 3. Binary Arithmetic] - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-negative-numbers.php 4. Negative Numbers] - ACSL problems will not cover how negative numbers are represented in binary. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-floating-point.php 5. Binary Fractions and Floating Point] - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section [https://ryanstutorials.net/binary-tutorial/binary-floating-point.php#convertfraction Converting to a Binary Fraction], but keep in mind that ACSL problems may also cover octal and hexadecimal fractions.&lt;br /&gt;
&lt;br /&gt;
The  [https://coolconversion.com/math/binary-octal-hexa-decimal/ CoolConversion.com online calculator] is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion. &lt;br /&gt;
&lt;br /&gt;
The AskNumbers.com site has a nice description of the conversions between [https://www.asknumbers.com/hex-to-octal.aspx binary, octal, decimal and hexadecimal] numbers. &lt;br /&gt;
&lt;br /&gt;
== Format of ACSL Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.&lt;br /&gt;
&lt;br /&gt;
To be successful in this category, you must know the following facts cold:&lt;br /&gt;
&lt;br /&gt;
# The binary value of each octal digit 0, 1, ..., 7&lt;br /&gt;
# The binary value of each hex digit 0, 1, ..., 9, A, B, C, D, E, F&lt;br /&gt;
# The decimal value of each hex digit 0, 1, ..., F  &lt;br /&gt;
# Powers  of  2,  up  to 4096&lt;br /&gt;
# Powers  of  8,  up  to 4096&lt;br /&gt;
# Powers  of  16,  up  to  65,536&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ where $x_{16}=3676_8$.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.&lt;br /&gt;
&lt;br /&gt;
An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:&lt;br /&gt;
 &lt;br /&gt;
$$\begin{align}&lt;br /&gt;
3676_8 &amp;amp;= 011 ~  110 ~ 111 ~ 110_2  &amp;amp; \text{convert each octal digit into base 2}\hfill\cr &lt;br /&gt;
&amp;amp;= 0111 ~ 1011 ~ 1110_2  &amp;amp; \text{group by 4 bits, from right-to-left}\hfill\cr&lt;br /&gt;
&amp;amp;= 7 ~ \text{B} ~ \text{E}_{16}  &amp;amp; \text{convert each group of 4 bits into a hex digit}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ in the following hexadecimal equation: $ x= \text{F5AD}_{16} - \text{69EB}_{16}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, &lt;br /&gt;
working directly in base 16 isn&amp;#039;t too hard. &lt;br /&gt;
As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.  &lt;br /&gt;
&lt;br /&gt;
:The rightmost digit becomes 2, because D-B=2.  &lt;br /&gt;
:The next column is A-E. We need to &amp;#039;&amp;#039;borrow&amp;#039;&amp;#039; a one from the 5 column, and 1A-E=C &lt;br /&gt;
:In the next column, 4-9=B, again, borrowing a 1 from the next column.&lt;br /&gt;
:Finally, the leftmost column,  E-6=8&lt;br /&gt;
&lt;br /&gt;
Combining these results of each column, we get a final answer of $8BC2_{16}$.&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
How many numbers from 100 to 200 in base 10 consist of distinct&lt;br /&gt;
ascending digits and also have distinct ascending hex digits when&lt;br /&gt;
converted to base 16? &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; There are 13 numbers that have ascending digits in both bases from 100&lt;br /&gt;
to 200.  They are (in base 10):&lt;br /&gt;
123 (7B), 124, 125, 126, 127 (7F), 137 (89), 138, 139 (8B), 156 (9C), 157, 158, 159 (9F), 189 (BD)&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely, without too many ads:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aW3qCcH6Dao&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aW3qCcH6Dao &amp;#039;&amp;#039;Number Systems - Converting Decimal, Binary and Hexadecimal&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Joe James&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
An introduction to number systems, and how to convert between decimal, binary and hexadecimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m1JtWKuTLR0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m1JtWKuTLR0 &amp;#039;&amp;#039;Lesson 2.3 : Hexadecimal Tutorial&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carl Herold&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video focuses on hexadecimal numbers: their relationship to binary numbers and how to convert to decimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/WR67syBDzew&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/WR67syBDzew &amp;#039;&amp;#039;Hexes and the Magic of Base 16 - Vaidehi Joshi - May 2017&amp;#039; (&amp;#039;&amp;#039;&amp;#039;DonutJS&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A fun introduction to hexadecimal numbers, focusing a bit &lt;br /&gt;
on using hex numbers for specifying RGB colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jvx-NrILgpE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jvx-NrILgpE &amp;#039;&amp;#039;Collins Lab: Binary &amp;amp; Hex&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Adafruit Industries&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A professionally produced video that explains the number systems, how and why binary numbers are fundamental to computer science, and why hexadecimal is important to computer programmers.  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=827</id>
		<title>Computer Number Systems</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=827"/>
		<updated>2020-09-02T16:14:28Z</updated>

		<summary type="html">&lt;p&gt;Marc: more wordsmithing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All digital computers, from supercomputers to your smartphone, are electronic devices and ultimately can do one thing: detect whether an electrical signal is on or off. That basic information, called a &amp;#039;&amp;#039;bit&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;bi&amp;#039;&amp;#039;&amp;#039;nary digi&amp;#039;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;#039;), has two values: a 1 (or &amp;#039;&amp;#039;true&amp;#039;&amp;#039;) when the signal is on, and a 0 (of &amp;#039;&amp;#039;false&amp;#039;&amp;#039;) when the signal is off. &lt;br /&gt;
&lt;br /&gt;
Larger values can be stored by a group of bits. For example, there are 4 different values stored by 2 bits (00, 01, 10, and 11), 8 values for 3 bits (000, 001, 010, 011, 100, 101, 110, and 111), 16 values for 4 bits (0000, 0001, ..., 1111), and so on. However, large numbers, using 0s and 1s only, are quite unwieldy for humans. For example, a computer would need 19 bits to store the numbers up to 500,000! We use of different number systems to work with large binary strings that represent numbers within computers.&lt;br /&gt;
&lt;br /&gt;
== Different Number Systems ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;number system&amp;#039;&amp;#039; is the way we name and represent numbers. The number system we use in our daily life is known as &amp;#039;&amp;#039;&amp;#039;decimal number system&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;base 10&amp;#039;&amp;#039;&amp;#039; because it is based on 10 different digits: 0, 1, 2, ..., 8, and 9. The base of number is written as subscript to a number. For example, the decimal number &amp;quot;twelve thousand three hundred and forty-five&amp;quot; is written as $12345_{10}$. Without a base, it&amp;#039;s assumed that a number is in base 10. &lt;br /&gt;
&lt;br /&gt;
In computer science, apart from the decimal system, three additional number systems are commonly used: &amp;#039;&amp;#039;&amp;#039;binary&amp;#039;&amp;#039;&amp;#039; (base-2), &amp;#039;&amp;#039;&amp;#039;octal&amp;#039;&amp;#039;&amp;#039; (base-8), and &amp;#039;&amp;#039;&amp;#039;hexadecimal&amp;#039;&amp;#039;&amp;#039; or just &amp;#039;&amp;#039;&amp;#039;hex&amp;#039;&amp;#039;&amp;#039; (base-16). Binary numbers are important because that is how number are stored in the computer. Octal and hexadecimal are used to represent binary numbers is a user-friendly way. Each octal symbol represents 3 binary bits and each hex digit represents 4 binary bits. For example, the decimal number 53201, stored as in the computer as the binary number 10000001111000101100, is represented by the octal number 2017054, and the hex number 81E2C. The table below compares the number systems: &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Number System&lt;br /&gt;
!Base&lt;br /&gt;
!Digits Used&lt;br /&gt;
!Examples&lt;br /&gt;
|-&lt;br /&gt;
|Binary&lt;br /&gt;
|2&lt;br /&gt;
|0,1&lt;br /&gt;
|$10110_{2}$, $10110011_{2}$&lt;br /&gt;
|-&lt;br /&gt;
|Octal&lt;br /&gt;
|8&lt;br /&gt;
|0,1,2,3,4,5,6,7&lt;br /&gt;
|$75021_{8}$, $231_{8}$, $60012_{8}$&lt;br /&gt;
|-&lt;br /&gt;
|Decimal&lt;br /&gt;
|10&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9&lt;br /&gt;
|$97425_{10}$ or simply 97425&lt;br /&gt;
|-&lt;br /&gt;
|Hexadecimal&lt;br /&gt;
|16&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F&lt;br /&gt;
|$54A2DD0F_{16}$&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In general, $N$ bits have $2^N$ different values. The computers aboard the Apollo spacecraft had 8-bit words of memory. Each word of memory could store 256 different values, and the contents were displayed using 2 hex characters.&lt;br /&gt;
&lt;br /&gt;
The following table shows the first 20 numbers in decimal, binary, octal, and hexadecimal:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
!Decimal&lt;br /&gt;
!Binary&lt;br /&gt;
!Octal&lt;br /&gt;
!Hexadecimal&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0 &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1 &lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|10&lt;br /&gt;
|2&lt;br /&gt;
|2 &lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|11&lt;br /&gt;
|3&lt;br /&gt;
|3 &lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|100&lt;br /&gt;
|4&lt;br /&gt;
|4 &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|101&lt;br /&gt;
|5&lt;br /&gt;
|5 &lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|110&lt;br /&gt;
|6&lt;br /&gt;
|6 &lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|111&lt;br /&gt;
|7&lt;br /&gt;
|7 &lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|1000&lt;br /&gt;
|10&lt;br /&gt;
|8&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|1001&lt;br /&gt;
|11&lt;br /&gt;
|9&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|1010&lt;br /&gt;
|12&lt;br /&gt;
|A&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|1011&lt;br /&gt;
|13&lt;br /&gt;
|B&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|1100&lt;br /&gt;
|14&lt;br /&gt;
|C &lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|1101&lt;br /&gt;
|15&lt;br /&gt;
|D &lt;br /&gt;
|-&lt;br /&gt;
|14&lt;br /&gt;
|1110&lt;br /&gt;
|16&lt;br /&gt;
|E &lt;br /&gt;
|-&lt;br /&gt;
|15&lt;br /&gt;
|1111&lt;br /&gt;
|17&lt;br /&gt;
|F &lt;br /&gt;
|-&lt;br /&gt;
|16&lt;br /&gt;
|10000&lt;br /&gt;
|20&lt;br /&gt;
|10 &lt;br /&gt;
|-&lt;br /&gt;
|17&lt;br /&gt;
|10001&lt;br /&gt;
|21&lt;br /&gt;
|11&lt;br /&gt;
|-&lt;br /&gt;
|18&lt;br /&gt;
|10010&lt;br /&gt;
|22&lt;br /&gt;
|12&lt;br /&gt;
|-&lt;br /&gt;
|19&lt;br /&gt;
|10011&lt;br /&gt;
|23&lt;br /&gt;
|13&lt;br /&gt;
|-&lt;br /&gt;
|20&lt;br /&gt;
|10100&lt;br /&gt;
|24&lt;br /&gt;
|14&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
== Decimal Values ==&lt;br /&gt;
&lt;br /&gt;
The value of a any number is the sum of each digit multiplied by its place value.  Here are some examples:&lt;br /&gt;
&lt;br /&gt;
:$12345 = 1×10000 + 2×1000 + 3×100 + 4×10 + 5×1 = 1×10^{4}+ 2×10^{3}+ 3×10^{2}+ 4×10^{1}+ 5×10{0}.$&lt;br /&gt;
&lt;br /&gt;
:$1101_{2}  = 1 × 2^3  + 1 × 2^2  + 0 × 2^1  + 1 × 2^0 = 8 + 4  + 0  + 1  = 13_{10}$ &lt;br /&gt;
&lt;br /&gt;
:$175_{8}   = 1 × 8^2  + 7 × 8^1  + 5 × 8^0 = 1 × 64 + 7 × 8 + 5 × 1 = 64 + 56 + 5 = 125_{10}$. &lt;br /&gt;
&lt;br /&gt;
:$A5E_{16}  = 10 × 16^2 + 5 × 16^1 + 14 × 16^0 = 10 × 256 + 5 × 16 + 14 × 1 = 2560 + 80 + 14 = 2654_{10}$. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Converting between Binary, Octal, and Hexadecimal == &lt;br /&gt;
&lt;br /&gt;
Converting from octal to base 2 is simple: replace each octal digit by its corresponding 3 binary bits. For example:&lt;br /&gt;
:$375_{8} = \ \ 011\ \ \ 111\ \ \ 101_{2}$&lt;br /&gt;
Converting from hex to base is also simple: replace each hex digit by its corresponding 4 binary bits. For example:&lt;br /&gt;
:$FD_{16} = \ \ 1111\ \ \ 1101_{2}$&lt;br /&gt;
Converting from binary to either octal or hex is pretty simple as well: group the bit by 3s or 4s (starting at the right), and convert each group:&lt;br /&gt;
:$10000001111000101100 = 10\ 000\ 001\ 111\ 000\ 101 \ 100 = 2017054_8$&lt;br /&gt;
&lt;br /&gt;
:$10000001111000101100 = 1000\ 0001\ 1110\ 0010\ 1100 = 81E2C_{16}$&lt;br /&gt;
You can convert between base 8 and 16 by expressing the number in base 2 (easy to do!) and then converting that number from base 2 (another easy operation)! This is shown below in Sample Problem #1.&lt;br /&gt;
&lt;br /&gt;
== Using Hexadecimal Numbers to Represent Colors ==&lt;br /&gt;
&lt;br /&gt;
Computers use hexadecimal numbers to represent various colors in computer graphics because all computer screens use combinations of red, green, and blue light or RGB to represent thousands of different colors. Two digits are used for each so the hexadecimal number “#FF0000” represents the color red, “#00FF00” represents green, and “#0000FF” represents blue.  The color black is “#000000” and white is “#FFFFFF”. &lt;br /&gt;
 &lt;br /&gt;
The hash tag or number sign is used to denote a hexadecimal number.  $FF_{16} = F (15) × 16 + F (15) × 1 = 240 + 15 = 255_{10}$ so there are 0 to 255 or 256 different shades of each color or $256^{3} = 16,777,216$ different colors. &lt;br /&gt;
 &lt;br /&gt;
The following web site has nearly every color name, along with its hex code and decimal values:  &lt;br /&gt;
 &lt;br /&gt;
:https://www.rapidtables.com/web/color/RGB_Color.html &lt;br /&gt;
 &lt;br /&gt;
For example “salmon” is “#FA8072” which represents the decimal numbers 250 (hex FA), 128 (hex 80), and 114 (hex 72).&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
[https://ryanstutorials.net/ Ryan&amp;#039;s Tutorials] covers this topic beautifully. Rather than trying to duplicate that work, we&amp;#039;ll point you to the different sections:&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/ 1. Number Systems] - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-conversions.php 2. Binary Conversions] - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the [https://ryanstutorials.net/binary-tutorial/binary-conversions.php#activities &amp;#039;&amp;#039;Activities&amp;#039;&amp;#039;] section, you can practice converting numbers. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-arithmetic.php 3. Binary Arithmetic] - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-negative-numbers.php 4. Negative Numbers] - ACSL problems will not cover how negative numbers are represented in binary. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-floating-point.php 5. Binary Fractions and Floating Point] - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section [https://ryanstutorials.net/binary-tutorial/binary-floating-point.php#convertfraction Converting to a Binary Fraction], but keep in mind that ACSL problems may also cover octal and hexadecimal fractions.&lt;br /&gt;
&lt;br /&gt;
The  [https://coolconversion.com/math/binary-octal-hexa-decimal/ CoolConversion.com online calculator] is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion. &lt;br /&gt;
&lt;br /&gt;
The AskNumbers.com site has a nice description of the conversions between [https://www.asknumbers.com/hex-to-octal.aspx binary, octal, decimal and hexadecimal] numbers. &lt;br /&gt;
&lt;br /&gt;
== Format of ACSL Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.&lt;br /&gt;
&lt;br /&gt;
To be successful in this category, you must know the following facts cold:&lt;br /&gt;
&lt;br /&gt;
# The binary value of each octal digit 0, 1, ..., 7&lt;br /&gt;
# The binary value of each hex digit 0, 1, ..., 9, A, B, C, D, E, F&lt;br /&gt;
# The decimal value of each hex digit 0, 1, ..., F  &lt;br /&gt;
# Powers  of  2,  up  to 4096&lt;br /&gt;
# Powers  of  8,  up  to 4096&lt;br /&gt;
# Powers  of  16,  up  to  65,536&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ where $x_{16}=3676_8$.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.&lt;br /&gt;
&lt;br /&gt;
An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:&lt;br /&gt;
 &lt;br /&gt;
$$\begin{align}&lt;br /&gt;
3676_8 &amp;amp;= 011 ~  110 ~ 111 ~ 110_2  &amp;amp; \text{convert each octal digit into base 2}\hfill\cr &lt;br /&gt;
&amp;amp;= 0111 ~ 1011 ~ 1110_2  &amp;amp; \text{group by 4 bits, from right-to-left}\hfill\cr&lt;br /&gt;
&amp;amp;= 7 ~ \text{B} ~ \text{E}_{16}  &amp;amp; \text{convert each group of 4 bits into a hex digit}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ in the following hexadecimal equation: $ x= \text{F5AD}_{16} - \text{69EB}_{16}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, &lt;br /&gt;
working directly in base 16 isn&amp;#039;t too hard. &lt;br /&gt;
As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.  &lt;br /&gt;
&lt;br /&gt;
:The rightmost digit becomes 2, because D-B=2.  &lt;br /&gt;
:The next column is A-E. We need to &amp;#039;&amp;#039;borrow&amp;#039;&amp;#039; a one from the 5 column, and 1A-E=C &lt;br /&gt;
:In the next column, 4-9=B, again, borrowing a 1 from the next column.&lt;br /&gt;
:Finally, the leftmost column,  E-6=8&lt;br /&gt;
&lt;br /&gt;
Combining these results of each column, we get a final answer of $8BC2_{16}$.&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
How many numbers from 100 to 200 in base 10 consist of distinct&lt;br /&gt;
ascending digits and also have distinct ascending hex digits when&lt;br /&gt;
converted to base 16? &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; There are 13 numbers that have ascending digits in both bases from 100&lt;br /&gt;
to 200.  They are (in base 10):&lt;br /&gt;
123 (7B), 124, 125, 126, 127 (7F), 137 (89), 138, 139 (8B), 156 (9C), 157, 158, 159 (9F), 189 (BD)&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely, without too many ads:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aW3qCcH6Dao&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aW3qCcH6Dao &amp;#039;&amp;#039;Number Systems - Converting Decimal, Binary and Hexadecimal&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Joe James&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
An introduction to number systems, and how to convert between decimal, binary and hexadecimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m1JtWKuTLR0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m1JtWKuTLR0 &amp;#039;&amp;#039;Lesson 2.3 : Hexadecimal Tutorial&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carl Herold&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video focuses on hexadecimal numbers: their relationship to binary numbers and how to convert to decimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/WR67syBDzew&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/WR67syBDzew &amp;#039;&amp;#039;Hexes and the Magic of Base 16 - Vaidehi Joshi - May 2017&amp;#039; (&amp;#039;&amp;#039;&amp;#039;DonutJS&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A fun introduction to hexadecimal numbers, focusing a bit &lt;br /&gt;
on using hex numbers for specifying RGB colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jvx-NrILgpE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jvx-NrILgpE &amp;#039;&amp;#039;Collins Lab: Binary &amp;amp; Hex&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Adafruit Industries&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A professionally produced video that explains the number systems, how and why binary numbers are fundamental to computer science, and why hexadecimal is important to computer programmers.  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=826</id>
		<title>Computer Number Systems</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=826"/>
		<updated>2020-09-01T23:32:48Z</updated>

		<summary type="html">&lt;p&gt;Marc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All digital computers, from supercomputers to your smartphone, are electronic devices and ultimately can do one thing: detect whether an electrical signal is on or off. That basic information, called a &amp;#039;&amp;#039;bit&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;bi&amp;#039;&amp;#039;&amp;#039;nary digi&amp;#039;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;#039;), has two values: a 1 (or &amp;#039;&amp;#039;true&amp;#039;&amp;#039;) when the signal is on, and a 0 (of &amp;#039;&amp;#039;false&amp;#039;&amp;#039;) when the signal is off. &lt;br /&gt;
&lt;br /&gt;
Larger values can be stored by a group of bits. For example, there are 4 different values stored by 2 bits (00, 01, 10, and 11), 8 values for 3 bits (000, 001, 010, 011, 100, 101, 110, and 111), 16 values for 4 bits (0000, 0001, ..., 1111), and so on. In general, $n$ bits can store $2^n$ different values. Large numbers, using 0s and 1s only, is quite unwieldy for human. For example, a computer would need 19 bits to store the numbers up to 500,000! &lt;br /&gt;
&lt;br /&gt;
Fortunately, we can make use of different number systems to work with large binary strings that are represent numbers within computers.&lt;br /&gt;
&lt;br /&gt;
== Different Number Systems ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;number system&amp;#039;&amp;#039; is the way we name and represent numbers. The number system we use in our daily life is known as &amp;#039;&amp;#039;&amp;#039;decimal number system&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;base 10&amp;#039;&amp;#039;&amp;#039; because it is based on 10 different digits: 0, 1, 2, ..., 8, and 9. The base of number is written as subscript to a number. For example, the decimal number &amp;quot;twelve thousand three hundred and forty-five&amp;quot; is written as $12345_{10}$. Without a base, it&amp;#039;s assumed that a number is in base 10. &lt;br /&gt;
&lt;br /&gt;
In computer science, apart from the decimal system, three additional number systems are used: &amp;#039;&amp;#039;&amp;#039;binary&amp;#039;&amp;#039;&amp;#039; (base-2), &amp;#039;&amp;#039;&amp;#039;octal&amp;#039;&amp;#039;&amp;#039; (base-8), and &amp;#039;&amp;#039;&amp;#039;hexadecimal&amp;#039;&amp;#039;&amp;#039; or just &amp;#039;&amp;#039;&amp;#039;hex&amp;#039;&amp;#039;&amp;#039; (base-16). The table below compares the number systems: &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Number System&lt;br /&gt;
!Base&lt;br /&gt;
!Digits Used&lt;br /&gt;
!Sample Numbers&lt;br /&gt;
|-&lt;br /&gt;
|Binary&lt;br /&gt;
|2&lt;br /&gt;
|0,1&lt;br /&gt;
|$10110_{2}$, $10110011_{2}$&lt;br /&gt;
|-&lt;br /&gt;
|Octal&lt;br /&gt;
|8&lt;br /&gt;
|0,1,2,3,4,5,6,7&lt;br /&gt;
|$75021_{8}$, $231_{8}$, and $60012_{8}$&lt;br /&gt;
|-&lt;br /&gt;
|Decimal&lt;br /&gt;
|10&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9&lt;br /&gt;
|$97425_{10}$ or simply 97425&lt;br /&gt;
|-&lt;br /&gt;
|Hexadecimal&lt;br /&gt;
|16&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F&lt;br /&gt;
|$54A2DD0F_{16}$&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Octal and hexadecimal are used to represent binary numbers is a user-friendly way. Each octal symbol represents 3 binary bits and each hex digit represents 4 binary bits. Thus, the number 53201, stored as in the computer as the binary number 10000001111000101100, is represented by the octal number 2017054, and the hex number 81E2C.&lt;br /&gt;
&lt;br /&gt;
In general, $N$ bits have $2^N$ different values. The computers aboard the Apollo spacecraft had 8-bit words of memory. Each word of memory could store 256 different values, and the contents were displayed using 2 hex characters.&lt;br /&gt;
&lt;br /&gt;
The following table shows the first 20 numbers in decimal, binary, octal, and hexadecimal:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
!Decimal&lt;br /&gt;
!Binary&lt;br /&gt;
!Octal&lt;br /&gt;
!Hexadecimal&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0 &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1 &lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|10&lt;br /&gt;
|2&lt;br /&gt;
|2 &lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|11&lt;br /&gt;
|3&lt;br /&gt;
|3 &lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|100&lt;br /&gt;
|4&lt;br /&gt;
|4 &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|101&lt;br /&gt;
|5&lt;br /&gt;
|5 &lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|110&lt;br /&gt;
|6&lt;br /&gt;
|6 &lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|111&lt;br /&gt;
|7&lt;br /&gt;
|7 &lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|1000&lt;br /&gt;
|10&lt;br /&gt;
|8&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|1001&lt;br /&gt;
|11&lt;br /&gt;
|9&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|1010&lt;br /&gt;
|12&lt;br /&gt;
|A&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|1011&lt;br /&gt;
|13&lt;br /&gt;
|B&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|1100&lt;br /&gt;
|14&lt;br /&gt;
|C &lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|1101&lt;br /&gt;
|15&lt;br /&gt;
|D &lt;br /&gt;
|-&lt;br /&gt;
|14&lt;br /&gt;
|1110&lt;br /&gt;
|16&lt;br /&gt;
|E &lt;br /&gt;
|-&lt;br /&gt;
|15&lt;br /&gt;
|1111&lt;br /&gt;
|17&lt;br /&gt;
|F &lt;br /&gt;
|-&lt;br /&gt;
|16&lt;br /&gt;
|10000&lt;br /&gt;
|20&lt;br /&gt;
|10 &lt;br /&gt;
|-&lt;br /&gt;
|17&lt;br /&gt;
|10001&lt;br /&gt;
|21&lt;br /&gt;
|11&lt;br /&gt;
|-&lt;br /&gt;
|18&lt;br /&gt;
|10010&lt;br /&gt;
|22&lt;br /&gt;
|12&lt;br /&gt;
|-&lt;br /&gt;
|19&lt;br /&gt;
|10011&lt;br /&gt;
|23&lt;br /&gt;
|13&lt;br /&gt;
|-&lt;br /&gt;
|20&lt;br /&gt;
|10100&lt;br /&gt;
|24&lt;br /&gt;
|14&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Formation of Numbers ==&lt;br /&gt;
&lt;br /&gt;
The formation of any number goes by the digit multiplied by its place value and adding them together. For example, we read and understand the number 12345 as twelve thousand three hundred and forty-five which has five digits: 1, 2, 3, 4, and 5. The number 12345 is completely different from the number 54321, which is also having the exact same 5 digits. This tells us that the digit with its place value give us the number. So, how to create/form a number in decimal system? Let&amp;#039;s see using these 2 example numbers:&lt;br /&gt;
:$12345 = 1×10000 + 2×1000 + 3×100 + 4×10 + 5×1 = 1×10^{4}+ 2×10^{3}+ 3×10^{2}+ 4×10^{1}+ 5×10{0}.$&lt;br /&gt;
:$54321 = 5×10000 + 4×1000 + 3×100 + 2×10 + 1×1 = 5×10^{4}+ 4×10^{3}+ 3×10^{2}+ 2×10^{1}+ 1×10{0}.$&lt;br /&gt;
&lt;br /&gt;
The expanded notation in the decimal number system above can represent different numbers by using powers of 10.&lt;br /&gt;
&lt;br /&gt;
All other bases work similarly:&lt;br /&gt;
&lt;br /&gt;
:$1101_{2}  = 1 × 2^3  + 1 × 2^2  + 0 × 2^1  + 1 × 2^0 = 8 + 4  + 0  + 1  = 13_{10}$ &lt;br /&gt;
:$175_{8}   = 1 × 8^2  + 7 × 8^1  + 5 × 8^0 = 1 × 64 + 7 × 8 + 5 × 1 = 64 + 56 + 5 = 125_{10}$. &lt;br /&gt;
:$A5E_{16}  = 10 × 16^2 + 5 × 16^1 + 14 × 16^0 = 10 × 256 + 5 × 16 + 14 × 1 = 2560 + 80 + 14 = 2654_{10}$. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Grouping Binary Digits for Octal and Hexadecimal Numbers&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
&lt;br /&gt;
To convert from octal to base 2 is simple: replace each octal digit by its corresponding 3 binary bits. For example:&lt;br /&gt;
:$375_{8} = \ \ 011\ \ \ 111\ \ \ 101_{2}$&lt;br /&gt;
To convert from hex to base is also simple: replace each hex digit by its corresponding 4 binary bits. For example:&lt;br /&gt;
:$FD_{16} = \ \ 1111\ \ \ 1101_{2}$&lt;br /&gt;
To convert from binary to either octal or hex is pretty simple as well: group the bit by 3s or 4s (starting at the right), and convert each group:&lt;br /&gt;
:$10000001111000101100 = 10\ 000\ 001\ 111\ 000\ 101 \ 100 = 2017054_8$&lt;br /&gt;
:$10000001111000101100 = 1000\ 0001\ 1110\ 0010\ 1100 = 81E2C_{16}$&lt;br /&gt;
It&amp;#039;s easy to see that you can convert between base 8 and 16 by expressing the number in base 2 (easy to do!) and then converting that number from base 2 (another easy operation)! This is shown below in Sample Problem #1.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using Hexadecimal Numbers to Represent Colors&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Computers use hexadecimal numbers to represent various colors in computer graphics because all computer screens use combinations of red, green, and blue light or RGB to represent thousands of different colors. Two digits are used for each so the hexadecimal number “#FF0000” represents the color red, “#00FF00” represents green, and “#0000FF” represents blue.  The color black is “#000000” and white is “#FFFFFF”. &lt;br /&gt;
 &lt;br /&gt;
The hash tag or number sign is used to denote a hexadecimal number.  $FF_{16} = F (15) × 16 + F (15) × 1 = 240 + 15 = 255_{10}$ so there are 0 to 255 or 256 different shades of each color or $256^{3} = 16,777,216$ different colors. &lt;br /&gt;
 &lt;br /&gt;
The following web site has nearly every color name, along with its hex code and decimal values:  &lt;br /&gt;
 &lt;br /&gt;
:https://www.rapidtables.com/web/color/RGB_Color.html &lt;br /&gt;
 &lt;br /&gt;
For example “salmon” is “#FA8072” which represents the decimal numbers 250 (hex FA), 128 (hex 80), and 114 (hex 72).&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
[https://ryanstutorials.net/ Ryan&amp;#039;s Tutorials] covers this topic beautifully. Rather than trying to duplicate that work, we&amp;#039;ll point you to the different sections:&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/ 1. Number Systems] - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-conversions.php 2. Binary Conversions] - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the [https://ryanstutorials.net/binary-tutorial/binary-conversions.php#activities &amp;#039;&amp;#039;Activities&amp;#039;&amp;#039;] section, you can practice converting numbers. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-arithmetic.php 3. Binary Arithmetic] - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-negative-numbers.php 4. Negative Numbers] - ACSL problems will not cover how negative numbers are represented in binary. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-floating-point.php 5. Binary Fractions and Floating Point] - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section [https://ryanstutorials.net/binary-tutorial/binary-floating-point.php#convertfraction Converting to a Binary Fraction], but keep in mind that ACSL problems may also cover octal and hexadecimal fractions.&lt;br /&gt;
&lt;br /&gt;
The  [https://coolconversion.com/math/binary-octal-hexa-decimal/ CoolConversion.com online calculator] is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion. &lt;br /&gt;
&lt;br /&gt;
The AskNumbers.com site has a nice description of the conversions between [https://www.asknumbers.com/hex-to-octal.aspx binary, octal, decimal and hexadecimal] numbers. &lt;br /&gt;
&lt;br /&gt;
== Format of ACSL Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.&lt;br /&gt;
&lt;br /&gt;
To be successful in this category, you must know the following facts cold:&lt;br /&gt;
&lt;br /&gt;
# The binary value of each octal digit 0, 1, ..., 7&lt;br /&gt;
# The binary value of each hex digit 0, 1, ..., 9, A, B, C, D, E, F&lt;br /&gt;
# The decimal value of each hex digit 0, 1, ..., F  &lt;br /&gt;
# Powers  of  2,  up  to 4096&lt;br /&gt;
# Powers  of  8,  up  to 4096&lt;br /&gt;
# Powers  of  16,  up  to  65,536&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ where $x_{16}=3676_8$.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.&lt;br /&gt;
&lt;br /&gt;
An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:&lt;br /&gt;
 &lt;br /&gt;
$$\begin{align}&lt;br /&gt;
3676_8 &amp;amp;= 011 ~  110 ~ 111 ~ 110_2  &amp;amp; \text{convert each octal digit into base 2}\hfill\cr &lt;br /&gt;
&amp;amp;= 0111 ~ 1011 ~ 1110_2  &amp;amp; \text{group by 4 bits, from right-to-left}\hfill\cr&lt;br /&gt;
&amp;amp;= 7 ~ \text{B} ~ \text{E}_{16}  &amp;amp; \text{convert each group of 4 bits into a hex digit}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ in the following hexadecimal equation: $ x= \text{F5AD}_{16} - \text{69EB}_{16}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, &lt;br /&gt;
working directly in base 16 isn&amp;#039;t too hard. &lt;br /&gt;
As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.  &lt;br /&gt;
&lt;br /&gt;
:The rightmost digit becomes 2, because D-B=2.  &lt;br /&gt;
:The next column is A-E. We need to &amp;#039;&amp;#039;borrow&amp;#039;&amp;#039; a one from the 5 column, and 1A-E=C &lt;br /&gt;
:In the next column, 4-9=B, again, borrowing a 1 from the next column.&lt;br /&gt;
:Finally, the leftmost column,  E-6=8&lt;br /&gt;
&lt;br /&gt;
Combining these results of each column, we get a final answer of $8BC2_{16}$.&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
How many numbers from 100 to 200 in base 10 consist of distinct&lt;br /&gt;
ascending digits and also have distinct ascending hex digits when&lt;br /&gt;
converted to base 16? &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; There are 13 numbers that have ascending digits in both bases from 100&lt;br /&gt;
to 200.  They are (in base 10):&lt;br /&gt;
123 (7B), 124, 125, 126, 127 (7F), 137 (89), 138, 139 (8B), 156 (9C), 157, 158, 159 (9F), 189 (BD)&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely, without too many ads:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aW3qCcH6Dao&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aW3qCcH6Dao &amp;#039;&amp;#039;Number Systems - Converting Decimal, Binary and Hexadecimal&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Joe James&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
An introduction to number systems, and how to convert between decimal, binary and hexadecimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m1JtWKuTLR0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m1JtWKuTLR0 &amp;#039;&amp;#039;Lesson 2.3 : Hexadecimal Tutorial&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carl Herold&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video focuses on hexadecimal numbers: their relationship to binary numbers and how to convert to decimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/WR67syBDzew&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/WR67syBDzew &amp;#039;&amp;#039;Hexes and the Magic of Base 16 - Vaidehi Joshi - May 2017&amp;#039; (&amp;#039;&amp;#039;&amp;#039;DonutJS&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A fun introduction to hexadecimal numbers, focusing a bit &lt;br /&gt;
on using hex numbers for specifying RGB colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jvx-NrILgpE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jvx-NrILgpE &amp;#039;&amp;#039;Collins Lab: Binary &amp;amp; Hex&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Adafruit Industries&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A professionally produced video that explains the number systems, how and why binary numbers are fundamental to computer science, and why hexadecimal is important to computer programmers.  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=825</id>
		<title>Computer Number Systems</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Computer_Number_Systems&amp;diff=825"/>
		<updated>2020-09-01T23:30:45Z</updated>

		<summary type="html">&lt;p&gt;Marc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All digital computers, from supercomputers to your smartphone, are electronic devices and ultimately can do one thing: detect whether an electrical signal is on or off. That basic information, called a &amp;#039;&amp;#039;bit&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;bi&amp;#039;&amp;#039;&amp;#039;nary digi&amp;#039;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;#039;), has two values: a 1 (or &amp;#039;&amp;#039;true&amp;#039;&amp;#039;) when the signal is on, and a 0 (of &amp;#039;&amp;#039;false&amp;#039;&amp;#039;) when the signal is off. &lt;br /&gt;
&lt;br /&gt;
Larger values can be stored by a group of bits. For example, there are 4 different values stored by 2 bits (00, 01, 10, and 11), 8 values for 3 bits (000, 001, 010, 011, 100, 101, 110, and 111), 16 values for 4 bits (0000, 0001, ..., 1111), and so on. In general, $n$ bits can store $2^n$ different values. Large numbers, using 0s and 1s only, is quite unwieldy for human. For example, a computer would need 19 bits to store the numbers up to 500,000! &lt;br /&gt;
&lt;br /&gt;
Fortunately, we can make use of different number systems to work with large binary strings that are represent numbers within computers.&lt;br /&gt;
&lt;br /&gt;
== Different Number Systems ==&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;number system&amp;#039;&amp;#039; is the way we name and represent numbers. The number system we use in our daily life is known as &amp;#039;&amp;#039;&amp;#039;decimal number system&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;base 10&amp;#039;&amp;#039;&amp;#039; because it is based on 10 different digits: 0, 1, 2, ..., 8, and 9. The base of number is written as subscript to a number. For example, the decimal number &amp;quot;twelve thousand three hundred and forty-five&amp;quot; is written as $12345_{10}$. Without a base, it&amp;#039;s assumed that a number is in base 10. &lt;br /&gt;
&lt;br /&gt;
In computer science, apart from the decimal system, three additional number systems are used: &amp;#039;&amp;#039;&amp;#039;binary&amp;#039;&amp;#039;&amp;#039; (base-2), &amp;#039;&amp;#039;&amp;#039;octal&amp;#039;&amp;#039;&amp;#039; (base-8), and &amp;#039;&amp;#039;&amp;#039;hexadecimal&amp;#039;&amp;#039;&amp;#039; or just &amp;#039;&amp;#039;&amp;#039;hex&amp;#039;&amp;#039;&amp;#039; (base-16). The table below compares the number systems: &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Number System&lt;br /&gt;
!Base&lt;br /&gt;
!Digits Used&lt;br /&gt;
!Sample Numbers&lt;br /&gt;
|-&lt;br /&gt;
|Binary&lt;br /&gt;
|2&lt;br /&gt;
|0,1&lt;br /&gt;
|$10110_{2}$, $10110011_{2}$&lt;br /&gt;
|-&lt;br /&gt;
|Octal&lt;br /&gt;
|8&lt;br /&gt;
|0,1,2,3,4,5,6,7&lt;br /&gt;
|$75021_{8}$, $231_{8}$, and $60012_{8}$&lt;br /&gt;
|-&lt;br /&gt;
|Decimal&lt;br /&gt;
|10&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9&lt;br /&gt;
|$97425_{10}$ or simply 97425&lt;br /&gt;
|-&lt;br /&gt;
|Hexadecimal&lt;br /&gt;
|16&lt;br /&gt;
|0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F&lt;br /&gt;
|$54A2DD0F_{16}$&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Octal and hexadecimal are used to represent binary numbers is a user-friendly way. Each octal symbol represents 3 binary bits and each hex digit represents 4 binary bits. Thus, the number 53201, stored as in the computer as the binary number 10000001111000101100, is represented by the octal number 2017054, and the hex number 81E2C.&lt;br /&gt;
&lt;br /&gt;
In general, $N$ bits have $2^N$ different values. The computers aboard the Apollo spacecraft had 8-bit words of memory. Each word of memory could store 256 different values, and the contents were displayed using 2 hex characters.&lt;br /&gt;
&lt;br /&gt;
The following table shows the first 20 numbers in decimal, binary, octal, and hexadecimal:&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
!Decimal&lt;br /&gt;
!Binary&lt;br /&gt;
!Octal&lt;br /&gt;
!Hexadecimal&lt;br /&gt;
|-&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0 &lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1 &lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|10&lt;br /&gt;
|2&lt;br /&gt;
|2 &lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|11&lt;br /&gt;
|3&lt;br /&gt;
|3 &lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|100&lt;br /&gt;
|4&lt;br /&gt;
|4 &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|101&lt;br /&gt;
|5&lt;br /&gt;
|5 &lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|110&lt;br /&gt;
|6&lt;br /&gt;
|6 &lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|111&lt;br /&gt;
|7&lt;br /&gt;
|7 &lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|1000&lt;br /&gt;
|10&lt;br /&gt;
|8&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|1001&lt;br /&gt;
|11&lt;br /&gt;
|9&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|1010&lt;br /&gt;
|12&lt;br /&gt;
|A&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|1011&lt;br /&gt;
|13&lt;br /&gt;
|B&lt;br /&gt;
|-&lt;br /&gt;
|12&lt;br /&gt;
|1100&lt;br /&gt;
|14&lt;br /&gt;
|C &lt;br /&gt;
|-&lt;br /&gt;
|13&lt;br /&gt;
|1101&lt;br /&gt;
|15&lt;br /&gt;
|D &lt;br /&gt;
|-&lt;br /&gt;
|14&lt;br /&gt;
|1110&lt;br /&gt;
|16&lt;br /&gt;
|E &lt;br /&gt;
|-&lt;br /&gt;
|15&lt;br /&gt;
|1111&lt;br /&gt;
|17&lt;br /&gt;
|F &lt;br /&gt;
|-&lt;br /&gt;
|16&lt;br /&gt;
|10000&lt;br /&gt;
|20&lt;br /&gt;
|10 &lt;br /&gt;
|-&lt;br /&gt;
|17&lt;br /&gt;
|10001&lt;br /&gt;
|21&lt;br /&gt;
|11&lt;br /&gt;
|-&lt;br /&gt;
|18&lt;br /&gt;
|10010&lt;br /&gt;
|22&lt;br /&gt;
|12&lt;br /&gt;
|-&lt;br /&gt;
|19&lt;br /&gt;
|10011&lt;br /&gt;
|23&lt;br /&gt;
|13&lt;br /&gt;
|-&lt;br /&gt;
|20&lt;br /&gt;
|10100&lt;br /&gt;
|24&lt;br /&gt;
|14&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Formation of Numbers ==&lt;br /&gt;
&lt;br /&gt;
The formation of any number goes by the digit multiplied by its place value and adding them together. For example, we read and understand the number 12345 as twelve thousand three hundred and forty-five which has five digits: 1, 2, 3, 4, and 5. The number 12345 is completely different from the number 54321, which is also having the exact same 5 digits. This tells us that the digit with its place value give us the number. So, how to create/form a number in decimal system? Let&amp;#039;s see using these 2 example numbers:&lt;br /&gt;
:$12345 = 1×10000 + 2×1000 + 3×100 + 4×10 + 5×1 = 1×10^{4}+ 2×10^{3}+ 3×10^{2}+ 4×10^{1}+ 5×10{0}.$&lt;br /&gt;
:$54321 = 5×10000 + 4×1000 + 3×100 + 2×10 + 1×1 = 5×10^{4}+ 4×10^{3}+ 3×10^{2}+ 2×10^{1}+ 1×10{0}.$&lt;br /&gt;
&lt;br /&gt;
The expanded notation in the decimal number system above can represent different numbers by using powers of 10.&lt;br /&gt;
&lt;br /&gt;
All other bases work similarly:&lt;br /&gt;
&lt;br /&gt;
:$1101_{2}  = 1 × 2^3  + 1 × 2^2  + 0 × 2^1  + 1 × 2^0 = 8 + 4  + 0  + 1  = 13_{10}$ &lt;br /&gt;
:$175_{8}   = 1 × 8^2  + 7 × 8^1  + 5 × 8^0 = 1 × 64 + 7 × 8 + 5 × 1 = 64 + 56 + 5 = 125_{10}$. &lt;br /&gt;
:$A5E_{16}  = 10 × 16^2 + 5 × 16^1 + 14 × 16^0 = 10 × 256 + 5 × 16 + 14 × 1 = 2560 + 80 + 14 = 2654_{10}$. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Grouping Binary Digits for Octal and Hexadecimal Numbers&amp;#039;&amp;#039;&amp;#039; &lt;br /&gt;
&lt;br /&gt;
To convert from octal to base 2 is simple: replace each octal digit by its corresponding 3 binary bits. For example:&lt;br /&gt;
:$375_{8} = \ \ 011\ \ \ 111\ \ \ 101_{2}$&lt;br /&gt;
To convert from hex to base is also simple: replace each hex digit by its corresponding 4 binary bits. For example:&lt;br /&gt;
:$FD_{16} = \ \ 1111\ \ \ 1101_{2}$&lt;br /&gt;
To convert from binary to either octal or hex is pretty simple as well: group the bit by 3s or 4s (starting at the right), and convert each group:&lt;br /&gt;
$10000001111000101100 = 10\ 000\ 001\ 111\ 000\ 101 \ 100 = 2017054_8$&lt;br /&gt;
$10000001111000101100 = 1000\ 0001\ 1110\ 0010\ 1100 = 81E2C_{16}$&lt;br /&gt;
It&amp;#039;s easy to see that you can convert between base 8 and 16 by expressing the number in base 2 (easy to do!) and then converting that number from base 2 (another easy operation)! This is shown below in Sample Problem #1.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Using Hexadecimal Numbers to Represent Colors&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Computers use hexadecimal numbers to represent various colors in computer graphics because all computer screens use combinations of red, green, and blue light or RGB to represent thousands of different colors. Two digits are used for each so the hexadecimal number “#FF0000” represents the color red, “#00FF00” represents green, and “#0000FF” represents blue.  The color black is “#000000” and white is “#FFFFFF”. &lt;br /&gt;
 &lt;br /&gt;
The hash tag or number sign is used to denote a hexadecimal number.  $FF_{16} = F (15) × 16 + F (15) × 1 = 240 + 15 = 255_{10}$ so there are 0 to 255 or 256 different shades of each color or $256^{3} = 16,777,216$ different colors. &lt;br /&gt;
 &lt;br /&gt;
The following web site has nearly every color name, along with its hex code and decimal values:  &lt;br /&gt;
 &lt;br /&gt;
:https://www.rapidtables.com/web/color/RGB_Color.html &lt;br /&gt;
 &lt;br /&gt;
For example “salmon” is “#FA8072” which represents the decimal numbers 250 (hex FA), 128 (hex 80), and 114 (hex 72).&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
[https://ryanstutorials.net/ Ryan&amp;#039;s Tutorials] covers this topic beautifully. Rather than trying to duplicate that work, we&amp;#039;ll point you to the different sections:&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/ 1. Number Systems] - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-conversions.php 2. Binary Conversions] - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the [https://ryanstutorials.net/binary-tutorial/binary-conversions.php#activities &amp;#039;&amp;#039;Activities&amp;#039;&amp;#039;] section, you can practice converting numbers. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-arithmetic.php 3. Binary Arithmetic] - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.&lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-negative-numbers.php 4. Negative Numbers] - ACSL problems will not cover how negative numbers are represented in binary. &lt;br /&gt;
&lt;br /&gt;
:[https://ryanstutorials.net/binary-tutorial/binary-floating-point.php 5. Binary Fractions and Floating Point] - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section [https://ryanstutorials.net/binary-tutorial/binary-floating-point.php#convertfraction Converting to a Binary Fraction], but keep in mind that ACSL problems may also cover octal and hexadecimal fractions.&lt;br /&gt;
&lt;br /&gt;
The  [https://coolconversion.com/math/binary-octal-hexa-decimal/ CoolConversion.com online calculator] is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion. &lt;br /&gt;
&lt;br /&gt;
The AskNumbers.com site has a nice description of the conversions between [https://www.asknumbers.com/hex-to-octal.aspx binary, octal, decimal and hexadecimal] numbers. &lt;br /&gt;
&lt;br /&gt;
== Format of ACSL Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.&lt;br /&gt;
&lt;br /&gt;
To be successful in this category, you must know the following facts cold:&lt;br /&gt;
&lt;br /&gt;
# The binary value of each octal digit 0, 1, ..., 7&lt;br /&gt;
# The binary value of each hex digit 0, 1, ..., 9, A, B, C, D, E, F&lt;br /&gt;
# The decimal value of each hex digit 0, 1, ..., F  &lt;br /&gt;
# Powers  of  2,  up  to 4096&lt;br /&gt;
# Powers  of  8,  up  to 4096&lt;br /&gt;
# Powers  of  16,  up  to  65,536&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 1 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ where $x_{16}=3676_8$.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.&lt;br /&gt;
&lt;br /&gt;
An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:&lt;br /&gt;
 &lt;br /&gt;
$$\begin{align}&lt;br /&gt;
3676_8 &amp;amp;= 011 ~  110 ~ 111 ~ 110_2  &amp;amp; \text{convert each octal digit into base 2}\hfill\cr &lt;br /&gt;
&amp;amp;= 0111 ~ 1011 ~ 1110_2  &amp;amp; \text{group by 4 bits, from right-to-left}\hfill\cr&lt;br /&gt;
&amp;amp;= 7 ~ \text{B} ~ \text{E}_{16}  &amp;amp; \text{convert each group of 4 bits into a hex digit}\cr&lt;br /&gt;
\end{align}$$&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 2 ===&lt;br /&gt;
&lt;br /&gt;
Solve for $x$ in the following hexadecimal equation: $ x= \text{F5AD}_{16} - \text{69EB}_{16}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, &lt;br /&gt;
working directly in base 16 isn&amp;#039;t too hard. &lt;br /&gt;
As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.  &lt;br /&gt;
&lt;br /&gt;
:The rightmost digit becomes 2, because D-B=2.  &lt;br /&gt;
:The next column is A-E. We need to &amp;#039;&amp;#039;borrow&amp;#039;&amp;#039; a one from the 5 column, and 1A-E=C &lt;br /&gt;
:In the next column, 4-9=B, again, borrowing a 1 from the next column.&lt;br /&gt;
:Finally, the leftmost column,  E-6=8&lt;br /&gt;
&lt;br /&gt;
Combining these results of each column, we get a final answer of $8BC2_{16}$.&lt;br /&gt;
&lt;br /&gt;
=== Sample Problem 3 ===&lt;br /&gt;
&lt;br /&gt;
How many numbers from 100 to 200 in base 10 consist of distinct&lt;br /&gt;
ascending digits and also have distinct ascending hex digits when&lt;br /&gt;
converted to base 16? &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039; There are 13 numbers that have ascending digits in both bases from 100&lt;br /&gt;
to 200.  They are (in base 10):&lt;br /&gt;
123 (7B), 124, 125, 126, 127 (7F), 137 (89), 138, 139 (8B), 156 (9C), 157, 158, 159 (9F), 189 (BD)&lt;br /&gt;
&lt;br /&gt;
== Video Resources ==&lt;br /&gt;
&lt;br /&gt;
There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely, without too many ads:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aW3qCcH6Dao&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aW3qCcH6Dao &amp;#039;&amp;#039;Number Systems - Converting Decimal, Binary and Hexadecimal&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Joe James&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
An introduction to number systems, and how to convert between decimal, binary and hexadecimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/m1JtWKuTLR0&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/m1JtWKuTLR0 &amp;#039;&amp;#039;Lesson 2.3 : Hexadecimal Tutorial&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Carl Herold&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The video focuses on hexadecimal numbers: their relationship to binary numbers and how to convert to decimal numbers. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/WR67syBDzew&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/WR67syBDzew &amp;#039;&amp;#039;Hexes and the Magic of Base 16 - Vaidehi Joshi - May 2017&amp;#039; (&amp;#039;&amp;#039;&amp;#039;DonutJS&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A fun introduction to hexadecimal numbers, focusing a bit &lt;br /&gt;
on using hex numbers for specifying RGB colors. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jvx-NrILgpE&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jvx-NrILgpE &amp;#039;&amp;#039;Collins Lab: Binary &amp;amp; Hex&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Adafruit Industries&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
A professionally produced video that explains the number systems, how and why binary numbers are fundamental to computer science, and why hexadecimal is important to computer programmers.  &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Boolean_Algebra&amp;diff=824</id>
		<title>Boolean Algebra</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Boolean_Algebra&amp;diff=824"/>
		<updated>2020-09-01T21:25:29Z</updated>

		<summary type="html">&lt;p&gt;Marc: /* Why is Boolean Algebra Important for ACSL Students? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;#039;&amp;#039;Boolean algebra&amp;#039;&amp;#039; is the branch of algebra in which the values of the variables and constants have exactly two values: &amp;#039;&amp;#039;true&amp;#039;&amp;#039; and &amp;#039;&amp;#039;false&amp;#039;&amp;#039;, usually denoted 1 and 0 respectively. &lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
&lt;br /&gt;
The basic operators in Boolean algebra are &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039;. The secondary operators are &amp;#039;&amp;#039;eXclusive OR&amp;#039;&amp;#039; (often called &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039;) and &amp;#039;&amp;#039;eXclusive NOR&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;XNOR&amp;#039;&amp;#039;&amp;#039;, sometimes called &amp;#039;&amp;#039;&amp;#039;equivalence&amp;#039;&amp;#039;&amp;#039;). They are secondary in the sense that they &lt;br /&gt;
can be composed from the basic operators.&lt;br /&gt;
&lt;br /&gt;
*The &amp;#039;&amp;#039;&amp;#039;AND&amp;#039;&amp;#039;&amp;#039; of two values is true only whenever both values are true. It is written as $xy$ or $x \cdot y$. The values of  &amp;#039;&amp;#039;and&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x  y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;OR&amp;#039;&amp;#039;&amp;#039; of two values is true whenever either or both values are true. It is written as $x+y$. The values of  &amp;#039;&amp;#039;or&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x + y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; of  a value is its opposite; that is, the &amp;#039;&amp;#039;not&amp;#039;&amp;#039; of a true value is false whereas the &amp;#039;&amp;#039;not&amp;#039;&amp;#039; of a false value is true. It is written as $\overline{x}$ or $\neg{x}$. The values of  &amp;#039;&amp;#039;not&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ \overline{x}\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
| 0 &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; of two values is true whenever the values are different.  It uses the $\oplus$ operator, and can be built from the basic operators: $x \oplus y = x \overline{y} + \overline{x} y$ The values of  &amp;#039;&amp;#039;xor&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x \oplus y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 0 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 0&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
*The &amp;#039;&amp;#039;&amp;#039;XNOR&amp;#039;&amp;#039;&amp;#039; of two values is true whenever the values are the same. It is the &amp;#039;&amp;#039;&amp;#039;NOT&amp;#039;&amp;#039;&amp;#039; of the &amp;#039;&amp;#039;&amp;#039;XOR&amp;#039;&amp;#039;&amp;#039; function. It uses the $\odot$ operator: $x \odot y = \overline{x \oplus y}$. The &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039; can be built from basic operators: $x \odot y = x  y + \overline{x}  \overline{y}$ The values of  &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039; for all possible inputs is shown in the following truth table:&lt;br /&gt;
::{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ x\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ \ \ \ y\ \ \ \ &amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\ x \odot y\ &amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
| 1 &lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
| 0&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
| 0&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
| 1&lt;br /&gt;
|} &lt;br /&gt;
 &lt;br /&gt;
Just as algebra has basic rules for simplifying and evaluating expressions, so does Boolean algebra.&lt;br /&gt;
&lt;br /&gt;
== Why is Boolean Algebra Important for ACSL Students? ==&lt;br /&gt;
&lt;br /&gt;
Boolean algebra is important to programmers, computer scientists, and the general population. &lt;br /&gt;
&lt;br /&gt;
*For programmers, Boolean expressions are used for conditionals and loops. For example, the following snippet of code sums the even numbers that are not also multiples of 3, stopping when the sum hits 100:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
s = 0&lt;br /&gt;
x = 1&lt;br /&gt;
while (s &amp;lt; 100):&lt;br /&gt;
    if (x % 2 == 0) and (x % 3 != 0)&lt;br /&gt;
        then s = s + x&lt;br /&gt;
    x = x + 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Both the conditional statement &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;s &amp;lt; 100&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
and the Boolean expression with 2 conditional statements  &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;(x % 2 == 0) and (x % 3 != 0)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
evaluate to &amp;#039;&amp;#039;true&amp;#039;&amp;#039; or &amp;#039;&amp;#039;false&amp;#039;&amp;#039;. &lt;br /&gt;
&amp;lt;/dd&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*For computer scientists, Boolean algebra is the basis for digital circuits that make up a computer&amp;#039;s hardware. The [[Digital Electronics]] category concerns a graphical representation of a circuit. That circuit is typically easiest to understand and evaluate by converting it to its Boolean algebra representation. &lt;br /&gt;
 &lt;br /&gt;
* The general population uses Boolean algebra, probably without knowing that they are doing so, when they enter search terms in Internet search engines. For example, the search expression &amp;#039;&amp;#039;jaguar speed -car&amp;#039;&amp;#039; is parsed by the search engine as the Boolean expression &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; inline&amp;gt;&amp;quot;jaguar&amp;quot; and &amp;quot;car&amp;quot; and not &amp;quot;speed&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;; it returns pages about the speed of the jaguar animal, not the Jaguar car.&lt;br /&gt;
&lt;br /&gt;
==Laws==&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;law&amp;#039;&amp;#039;&amp;#039; of Boolean algebra is an identity such as &amp;lt;math&amp;gt;x + (y + z) = (x + y) + z&amp;lt;/math&amp;gt;&lt;br /&gt;
between two Boolean terms, where a &amp;#039;&amp;#039;&amp;#039;Boolean term&amp;#039;&amp;#039;&amp;#039; is defined as an expression built up from variables,  the constants 0 and 1, and operations &amp;#039;&amp;#039;and&amp;#039;&amp;#039;, &amp;#039;&amp;#039;or&amp;#039;&amp;#039;, &amp;#039;&amp;#039;not&amp;#039;&amp;#039;, &amp;#039;&amp;#039;xor&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
Like ordinary algebra, parentheses are used to group terms. When a &amp;#039;&amp;#039;not&amp;#039;&amp;#039; is represented with an overhead horizontal line, there is an implicit grouping of the terms under the line. That is, $x \cdot \overline{y + z}$ is evaluated as if it were written $x \cdot \overline{(y + z)}.$&lt;br /&gt;
&lt;br /&gt;
=== Order of Precedence ===&lt;br /&gt;
&lt;br /&gt;
The order of operator precedence is &amp;#039;&amp;#039;not&amp;#039;&amp;#039;; then &amp;#039;&amp;#039;and&amp;#039;&amp;#039;; then &amp;#039;&amp;#039;xor&amp;#039;&amp;#039; and &amp;#039;&amp;#039;xnor&amp;#039;&amp;#039;; and finally &amp;#039;&amp;#039;or&amp;#039;&amp;#039;. Operators with the same level of precedence are evaluated from left-to-right. &lt;br /&gt;
 &lt;br /&gt;
=== Fundamental Identities ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Commutative Law – The order of application of two separate terms is not important. || $x+y = y+x$ || $x \cdot y = y \cdot x$ &lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Associative Law – Regrouping of the terms in an expression doesn&amp;#039;t change the value of the expression. ||$(x + y) + z$ = $x + (y + z)$ || $x \cdot (y \cdot z) = (x \cdot y) \cdot z$ &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Idempotent Law – A term that is &amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039;´ed or &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with itself is equal to that term. || $ x +x = x $ || $x \cdot x = x$&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Annihilator Law – A term that is &amp;#039;&amp;#039;or&amp;#039;&amp;#039;&amp;#039;´ed with 1 is 1; a term &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with 0 is 0. || $x + 1 = 1$ || $ x \cdot 0 = 0 $ &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Identity Law – A term &amp;#039;&amp;#039;or&amp;#039;&amp;#039;´ed 0 or  &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with a 1 will always equal that term. || $x + 0 = x$  || $x \cdot 1 = x$&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Complement Law – A term &amp;#039;&amp;#039;or&amp;#039;&amp;#039;´ed with its complement equals 1 and a term &amp;#039;&amp;#039;and&amp;#039;&amp;#039;´ed with its complement equals 0. || $x + \overline{x} = 1 $ || $x \cdot \overline{x} = 0$&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Absorptive Law – Complex expressions can be reduced to a simpler ones by absorbing like terms. ||colspan=2|&lt;br /&gt;
$x+x  y = x$&lt;br /&gt;
&lt;br /&gt;
$ x +\overline{x}y = x + y $&lt;br /&gt;
&lt;br /&gt;
$x  (x+y) = x$&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Distributive Law – It&amp;#039;s OK to multiply or factor-out an expression.||colspan=2|&lt;br /&gt;
&lt;br /&gt;
$x \cdot (y + z) = xy + xz$&lt;br /&gt;
&lt;br /&gt;
$(x+y) \cdot (p + q) = xp + xq +yp + yq$&lt;br /&gt;
&lt;br /&gt;
$(x+y)(x+z)=x + yz $&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | DeMorgan&amp;#039;s Law – An &amp;#039;&amp;#039;or&amp;#039;&amp;#039; (&amp;#039;&amp;#039;and&amp;#039;&amp;#039;) expression that is negated is equal to the &amp;#039;&amp;#039;and&amp;#039;&amp;#039; (&amp;#039;&amp;#039;or&amp;#039;&amp;#039;) of the negation of each term.|| $\overline{x+y} = \overline{x} \cdot \overline{y}$||$\overline{x \cdot y} = \overline{x} + \overline{y}$&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Double Negation – A term that is inverted twice is equal to the original term.||colspan=2| $\overline{\overline{x}} = x $ &lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;text-align: left&amp;quot; | Relationship between XOR and XNOR|| colspan=2 | $ x\odot y = \overline{x\oplus y} = x \oplus \overline{y} =\overline{x} \oplus {y}$ &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Sample Problems ==&lt;br /&gt;
&lt;br /&gt;
Problems in this category are typically of the form &amp;quot;Given a Boolean expression, simplify it as much as possible&amp;quot; or &amp;quot;Given a Boolean expression,&lt;br /&gt;
find the values of all possible inputs that make the expression &amp;#039;&amp;#039;true&amp;#039;&amp;#039;.&amp;quot;  Simplify means writing an equivalent expression using the fewest number of operators.&lt;br /&gt;
&lt;br /&gt;
=== Problem 1: Simplify the Expression ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Simplify the following expression as much as possible:&lt;br /&gt;
$ \overline{ \overline{A(A+B)} + B\overline{A}}$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The simplification proceeds as follows:&lt;br /&gt;
&lt;br /&gt;
:$\overline{ \overline{A(A+B)} + B\overline{A}}$&lt;br /&gt;
::{| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  &amp;lt;math&amp;gt;= \left(\overline{ \overline{A(A+B)}}\right) \cdot \left(\overline{ B\overline{A}}\right)&amp;lt;/math&amp;gt; ||&lt;br /&gt;
|  (DeMorgan&amp;#039;s Law)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;= \left(A(A+B)\right) \cdot \left( \overline{B}+\overline{\overline{A}}\right)&amp;lt;/math&amp;gt; ||&lt;br /&gt;
|  (Double Negation; DeMorgan&amp;#039;s Law)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;= A \cdot \left( \overline{B}+A\right)&amp;lt;/math&amp;gt; ||&lt;br /&gt;
|  (Absorption; Double Negation)&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;math&amp;gt;=A&amp;lt;/math&amp;gt;  || &lt;br /&gt;
| (Absorption)&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Problem 2: Find Solutions ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Problem:&amp;#039;&amp;#039;&amp;#039; Find all orderd pairs $(A,B)$ that make the following expression &amp;#039;&amp;#039;true&amp;#039;&amp;#039;:&lt;br /&gt;
$ \overline{ \overline{(A+B)} + \overline{A}B }$&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
There are typically two approaches to solving this type of problem. One approach is to simplify the expression as much as possible, until&lt;br /&gt;
it&amp;#039;s obvious what the solutions are. The other approach is to create a truth table of all possible inputs, with columns for each subexpression.&lt;br /&gt;
&lt;br /&gt;
The simplification approach is as following:&lt;br /&gt;
:$ \overline{\overline{(A+B)} + \overline{A}B}$&lt;br /&gt;
::$= \overline{\overline{A+B}} \cdot \overline{\overline{A}B}$ &lt;br /&gt;
::$= (A+B) \cdot (\overline{\overline{A}}+\overline{B} ) $ &lt;br /&gt;
::$= (A+B) \cdot (A+\overline{B}) $ &lt;br /&gt;
::$= AA + A\overline{B} + BA + B\overline{B} $ &lt;br /&gt;
::$= A + A(\overline{B} + B) + 0 $ &lt;br /&gt;
::$= A + A(1)$ &lt;br /&gt;
::$= A + A$ &lt;br /&gt;
::$=A$&lt;br /&gt;
This means that all inputs are valid whenever $A$ is &amp;#039;&amp;#039;true&amp;#039;&amp;#039;: $(1,0)$ and $(1,1)$&lt;br /&gt;
&lt;br /&gt;
The truth table approach is as following. Each column is the result of a basic operation on two other columns. &lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align: center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#1&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#2&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#3 &lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#4&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#5&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#6&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#7&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |#8&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff&amp;quot;|&lt;br /&gt;
|style=&amp;quot;background-color: #cceeff&amp;quot;|&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |OR of Col#1, Col#2&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |NOT of Col#3&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |NOT of Col#1&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |ADD of Col#1, Col#2&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |OR of Col#4, Col#6&lt;br /&gt;
!style=&amp;quot;background-color: #cceeff; font-size: x-small&amp;quot; |NOT of Col#7 &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;A+B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A+B}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A}&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A}B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{A+B} + \overline{A}B&amp;lt;/math&amp;gt;&lt;br /&gt;
!&amp;lt;math&amp;gt;\overline{\overline{A+B} + \overline{A}B}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!0&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
!0&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!0&lt;br /&gt;
!1&lt;br /&gt;
&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
|1&lt;br /&gt;
!0&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!0&lt;br /&gt;
&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
!1&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!1&lt;br /&gt;
!1&lt;br /&gt;
&lt;br /&gt;
|1&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
|0&lt;br /&gt;
!1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The rightmost column is the expression we are solving; it is &amp;#039;&amp;#039;true&amp;#039;&amp;#039; for the 3rd and 4th rows, where the inputs are $(1,0)$ and $(1,1)$.&lt;br /&gt;
&lt;br /&gt;
== Online Resources ==&lt;br /&gt;
&lt;br /&gt;
===Websites===&lt;br /&gt;
A great online tutorial on Boolean Algebra is part of [https://ryanstutorials.net/boolean-algebra-tutorial/ Ryan&amp;#039;s Tutorials].&lt;br /&gt;
&lt;br /&gt;
===Videos===&lt;br /&gt;
The following YouTube videos show ACSL students and advisors working out some previous problems. To access the YouTube page with the video, click on the title of the video in the icon. (You can also play the video directly by clicking on the arrow in the center of the image; however, you&amp;#039;ll &lt;br /&gt;
probably want to have a larger viewing of the video since it contains writing on a whiteboard.) Some of the videos contain ads; ACSL is not responsible for the ads and does not receive compensation in any form for those ads. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/1cwO-FtybNw&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/1cwO-FtybNw &amp;#039;&amp;#039;ACSL Prep - Mrs. Gupta - Boolean Algebra&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;MegaChristian5555&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Christian is a student participating in ACSL. This video shows how to solve a half-dozen or so Boolean Algebra problems that have appeared in ACSL contests in recent years in the Intermediate and Senior divisions.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/HJdhEjpVYsY&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/HJdhEjpVYsY &amp;#039;&amp;#039;ACSL Boolean Algebra Contest 2 Worksheet 1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Mr. Minich is an ACSL advisor. This video was one of two he created to help prepare his students for the ACSL Boolean algebra category. It shows solutions to 5 different problems that have&lt;br /&gt;
appeared in recent years. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/4io6xgz8Zwk&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/4io6xgz8Zwk &amp;#039;&amp;#039;ACSL Boolean Algebra Contest 2 Worksheet 2&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;misterminich&amp;#039;&amp;#039;&amp;#039;) ]&lt;br /&gt;
&lt;br /&gt;
Mr. Minich is an ACSL advisor. This video was one of two he created to help prepare his students for the ACSL Boolean algebra category. It shows solutions to 5 different problems that have&lt;br /&gt;
appeared in recent years. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/6vI1mO1XOjQ&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/6vI1mO1XOjQ &amp;#039;&amp;#039;ACSL 3 13-14 #1 - AM&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Gordon Campbell&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video walks through the solution to finding all ordered triples that make the following&lt;br /&gt;
Boolean expression &amp;#039;&amp;#039;true&amp;#039;&amp;#039;:&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
(AB+\overline{C})(\overline{A}+BC)(A+\overline{B}+C)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
This problem appeared in 2013-2014 in the Senior Division, Contest #3.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/KRKTbAZYlLM&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/KRKTbAZYlLM &amp;#039;&amp;#039;ACSL 3 #1 14-15 - AM&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Gordon Campbell&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video walks through the simplification of the expression:&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
\overline{(\overline{A}+B)}(B+C)\overline{(A+\overline{C})}(A\overline{B}+BC)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
This problem appeared in 2014-2015 in the Senior Division, Contest #3.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/jDnni-zm2g8&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/jDnni-zm2g8 &amp;#039;&amp;#039;A general tutorial on boolean algebra that can be used for American Computer Science League.&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;Tangerine Code&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
Walks through the simplification of the following Boolean expression:&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
\overline{ (\overline{A + \overline{B}})(AB)} +&lt;br /&gt;
\overline{ (A+B)(\overline{\overline{A}B})}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/aGJALO57X7o&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/aGJALO57X7o &amp;#039;&amp;#039;Boolean Algebra by Ravi Yeluru&amp;#039;&amp;#039; ]&lt;br /&gt;
&lt;br /&gt;
Walks through solving a handful of ACSL problems.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/-Iagy51n5bQ&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/-Iagy51n5bQ &amp;#039;&amp;#039;Boolean Algebra by Ravi Yeluru&amp;#039;&amp;#039; ]&lt;br /&gt;
&lt;br /&gt;
Walks through solving 4 ACSL problems.&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Main_Page&amp;diff=823</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Main_Page&amp;diff=823"/>
		<updated>2020-09-01T21:20:13Z</updated>

		<summary type="html">&lt;p&gt;Marc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the wiki describing the topics covered in the short programs section of the [//www.acsl.org ACSL] contests.&lt;br /&gt;
&lt;br /&gt;
If you&amp;#039;d like to contribute to this wiki - and we&amp;#039;d love to improve it - please shoot us an email requesting an account. Conversely, if we&amp;#039;ve linked to your material (especially YouTube videos) that you&amp;#039;d prefer that we do not reference, let us know and we will promptly remove those links.&lt;br /&gt;
&lt;br /&gt;
The categories covered during the regular season in the Classroom, Junior, Intermediate, and Senior Divisions are as follows:&lt;br /&gt;
&lt;br /&gt;
* [[Assembly Language Programming]]  &lt;br /&gt;
* [[Bit-String Flicking]] &lt;br /&gt;
* [[Boolean Algebra]]&lt;br /&gt;
* [[Computer Number Systems]]&lt;br /&gt;
* [[Data Structures]]&lt;br /&gt;
* [[Digital Electronics]] &lt;br /&gt;
* [[FSAs and Regular Expressions]] &lt;br /&gt;
* [[Graph Theory]]&lt;br /&gt;
* [[LISP]] &lt;br /&gt;
* [[Prefix/Infix/Postfix Notation]]&lt;br /&gt;
* [[Recursive Functions]]&lt;br /&gt;
* [[What Does This Program Do?]]&lt;br /&gt;
&lt;br /&gt;
The categories covered during the regular season in the Elementary Division are as follows:&lt;br /&gt;
&lt;br /&gt;
* [//www.acsl.org/categories/C1Elem-ComputerNumberSystems.pdf Elementary Division: Computer Number Systems (Contest 1)]&lt;br /&gt;
* [//www.acsl.org/categories/C2Elem-Prefix-Postfix-InfixNotation.pdf Elementary Division: Prefix-Postfix-Infix Notation (Contest 2)]]&lt;br /&gt;
* [//www.acsl.org/categories/C3Elem-BooleanAlgebra.pdf Elementary Division: Boolean Algebra (Contest 3)]&lt;br /&gt;
* [//www.acsl.org/categories/C4Elem-GraphTheory.pdf Elementary Division: Graph Theory (Contest 4)]&lt;br /&gt;
&lt;br /&gt;
The categories covered during the end-of-season invitational competition are as follows:&lt;br /&gt;
&lt;br /&gt;
* [[Advanced Regular Expressions]] &lt;br /&gt;
* [[Karnaugh Maps]] &lt;br /&gt;
&lt;br /&gt;
== Getting started ==&lt;br /&gt;
* [//meta.wikimedia.org/wiki/Help:Contents User&amp;#039;s Guide] for information on using the wiki software&lt;br /&gt;
* [//www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings Configuration settings list]&lt;br /&gt;
* [//www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]&lt;/div&gt;</summary>
		<author><name>Marc</name></author>
	</entry>
</feed>