<?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=Raj+Joshi</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=Raj+Joshi"/>
	<link rel="alternate" type="text/html" href="http://www.categories.acsl.org/wiki/index.php?title=Special:Contributions/Raj_Joshi"/>
	<updated>2026-04-21T11:31:15Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Assembly_Language_Programming&amp;diff=744</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=744"/>
		<updated>2020-08-29T17:27:30Z</updated>

		<summary type="html">&lt;p&gt;Raj Joshi: /* 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;
x&lt;/div&gt;</summary>
		<author><name>Raj Joshi</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Graph_Theory&amp;diff=654</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=654"/>
		<updated>2020-08-09T16:42:15Z</updated>

		<summary type="html">&lt;p&gt;Raj Joshi: /* ACSL 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;
To be precise, the graph above is an &amp;#039;&amp;#039;undirected graph&amp;#039;&amp;#039;; the edge from x to y is the same as from y to x.&lt;br /&gt;
&lt;br /&gt;
== Terminology ==&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&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; (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;
== Trees ==&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 on N vertices contains exactly N-1 edges.  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.  Minimal spanning trees can be found for weighted graphs (i.e. each edge has a cost or distance associated with it) in order to minimize the cost or distance across an entire network.  A group of disconnected trees is called a &amp;#039;&amp;#039;forest.&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;
== Adjacency Matrices ==&lt;br /&gt;
&lt;br /&gt;
It is frequently convenient to represent a graph by a matrix, as shown in the second sample problem below.  If we consider vertex A as 1, B as 2, etc., then a “one” in M at row &amp;#039;&amp;#039;i&amp;#039;&amp;#039; and column &amp;#039;&amp;#039;j&amp;#039;&amp;#039; indicates that there is an edge from vertex &amp;#039;&amp;#039;i&amp;#039;&amp;#039; to &amp;#039;&amp;#039;j&amp;#039;&amp;#039;., whereas a &amp;quot;zero&amp;quot; indicates there is not an edge. If we raise M to the &amp;#039;&amp;#039;pth&amp;#039;&amp;#039; power, the resulting matrix indicates which paths of length &amp;#039;&amp;#039;p&amp;#039;&amp;#039; exist in the graph.  The value in $M^p(i,j)$ is the number of paths from vertex &amp;#039;&amp;#039;i&amp;#039;&amp;#039; to vertex &amp;#039;&amp;#039;j&amp;#039;&amp;#039;.&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$) &lt;br /&gt;
and 3 paths of length 4 (cell [1,3] in $M^4$).&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;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/44sQJK4BycY&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/44sQJK4BycY &amp;#039;&amp;#039;CS 106B Lecture: Graphs: basic concepts&amp;#039;&amp;#039;]&lt;br /&gt;
&lt;br /&gt;
This lecture from Stanford University is s wonderful introduction to graph theory. The lecture starts out with many examples of real world problems that are modeled by graphs, and then moves on to review basic terminology relating to graph theory. &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>Raj Joshi</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=What_Does_This_Program_Do%3F&amp;diff=653</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=653"/>
		<updated>2020-08-08T18:34:56Z</updated>

		<summary type="html">&lt;p&gt;Raj Joshi: &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[5:] = “WDTPD” (take the last 5 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; strings will be used in contest 3; and arrays 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>Raj Joshi</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Bit-String_Flicking&amp;diff=648</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=648"/>
		<updated>2020-07-21T13:25:20Z</updated>

		<summary type="html">&lt;p&gt;Raj Joshi: /* 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, 1011011 xor 011001 = 110010. 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&lt;br /&gt;
the same length. If the operands are not the same&lt;br /&gt;
length, the shorter one is padded with 0&amp;#039;s on the left as needed. For &lt;br /&gt;
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;
:(0101110 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;
:(0101110 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.  (RCIRC-3 x) is cdeab which, when ANDed with 11011 gives cd0ab.  This is XORed to 10110 to yield Cd1Ab (the capital letter is the NOT of its lower case).&lt;br /&gt;
Now, (LSHIFT-1 Cd1Ab) = d1Ab0 which has a value of 01100, 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”.  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>Raj Joshi</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Recursive_Functions&amp;diff=647</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=647"/>
		<updated>2020-07-21T13:23:06Z</updated>

		<summary type="html">&lt;p&gt;Raj Joshi: /* 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;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/BGCGlpm7Cow&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/BGCGlpm7Cow &amp;#039;&amp;#039;ACSL Recursive Functions Part -1 by Ravi Yeluru&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;mesra&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
The first of 4 videos capturing Ravi Yeluru solving a handful of ACSL Recursive Function problems. Other videos are [[https://youtu.be/n5otUyH1j6A Part 2]], [[https://youtu.be/xHaHwNHlMj4 Part 3]], and [[https://youtu.be/vj2pvAL8tQQ Part 4]].&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>Raj Joshi</name></author>
	</entry>
	<entry>
		<id>http://www.categories.acsl.org/wiki/index.php?title=Prefix/Infix/Postfix_Notation&amp;diff=646</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=646"/>
		<updated>2020-07-21T11:10:14Z</updated>

		<summary type="html">&lt;p&gt;Raj Joshi: /* 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;
| &amp;lt;youtube width=&amp;quot;300&amp;quot; height=&amp;quot;180&amp;quot;&amp;gt;https://youtu.be/9UO5aDyHZ84&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/9UO5aDyHZ84 &amp;quot;ACSL Math: Prefix/Infix/Postfix Notation&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/Lj91oRv3EIY&amp;lt;/youtube&amp;gt;&lt;br /&gt;
| [https://youtu.be/Lj91oRv3EIY &amp;#039;&amp;#039;ACSL Prep - Mrs. Gupta - Prefix Infix Postfix&amp;#039;&amp;#039; (&amp;#039;&amp;#039;&amp;#039;MegaChristian5555&amp;#039;&amp;#039;&amp;#039;)]&lt;br /&gt;
&lt;br /&gt;
This video starts with a nice introduction to the category, and then solves a handful of practice 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/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>Raj Joshi</name></author>
	</entry>
</feed>