\documentclass[10pt,envcountsect]{beamer}

\mode<presentation> {
  \usetheme{Warsaw}
}

\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{pstricks}
\usepackage{multicol}
\usepackage{pstricks,pstricks-add,pst-math,pst-xkey}
\usepackage[vlined]{algorithm2e}
% 
% \newcommand{\IncMargin}{\IncMargin}
% \newcommand{\DecMargin}{\DecMargin}
% \newcommand{}{\SetAlgoLined}


\begin{document}
%pour afficher le plan au début de chaque section
\AtBeginSection[]
{
  \begin{frame}<beamer>
    \frametitle{Plan}
    \tableofcontents[currentsection,currentsubsection]
  \end{frame}
}

%pour afficher le plan au début de chaque sous-section
\AtBeginSubsection[]
{
  \begin{frame}<beamer>
    \frametitle{Plan}
    \tableofcontents[currentsection,currentsubsection]
  \end{frame}
}


\title{Episode 01\\ Algorithms}
\author{European section, season 1}
\date{}


\begin{frame}
  \titlepage
\end{frame}

\large
\section{What's an algorithm}
\begin{frame}{What's an algorithm}
An algorithm is a list of well-defined instructions for completing a task.
 \pause
It's generally made of three parts : \pause
\begin{enumerate}
 \item the input, where data are entered ; \pause
 \item the process itself made of well-defined operations ; \pause
 \item the output, where the result of the algorithm is displayed.
\end{enumerate}
\end{frame}

\begin{frame}{Input}
The input can be \pause
\begin{itemize}
 \item numbers ; \pause
 \item words ; \pause
 \item geometrical objects ;  \pause
 \item almost anything. \pause
\end{itemize}
Variables are often used in algorithms, notably to store and manipulate the input. They are named with a letter or a
sequence of letters and digits, such as : $A$, $n$, $input$, $input1$, \dots \\ \pause
\end{frame}

\begin{frame}{Changing the value of a variable}
One of the key instructions in algorithms is changing the value of a variable. This can be done in different ways,
using English or a symbolic language. \pause
 \begin{itemize}
  \item Assign value $10$ to variable $A$ : $10\rightarrow A$.\pause
  \item Add $1$ to the value of $n$ :  $n+1\rightarrow n$.\pause
  \item Add the variables $x$ and $y$ and store the result in $x$ : $x+y\rightarrow x$.\pause
 \end{itemize}\pause

We will use the notation $A\rightarrow10$, as the use of $=$ can be misleading.

\end{frame}



\section{Example 1}
\begin{frame}{Example 1}

\begin{center}
\begin{minipage}{5cm}
\IncMargin{1em}
\begin{algorithm}[H]

%\KwData{$A$, $B$, real numbers}
\Begin{$1\rightarrow A$ \;
$A+1\rightarrow B$ \;
$3\rightarrow A$ \;}
\end{algorithm}
\DecMargin{1em}
\end{minipage}
\pause
\begin{minipage}{5cm}
Values of the variables :
\begin{center}\begin{tabular}{c|c|c|}\cline{2-3}
  & $A$ & $B$ \\ \cline{2-3} \pause
Step \#1 & 1 &  \\  \cline{2-3}\pause
Step \#2 & 1 & 2 \\ \cline{2-3}\pause
Step \#3 & 3 & 2 \\ \cline{2-3}
\end{tabular}\end{center} \pause
\end{minipage}
\end{center}
\end{frame}



\section{Example 2}
\begin{frame}{Example 2}

\begin{center}
\begin{minipage}{10cm}
\IncMargin{1em}
\begin{algorithm}[H]

%\KwData{$C$, whole number}

\Begin{\KwIn{$C$, a whole number \;}
\eIf{$C=1745$}{\KwOut{``Correct code.'' \;}}{\KwOut{``Wrong code. Try again.'' \;}} 
  }
\end{algorithm}
\DecMargin{1em}
\end{minipage}
\pause
\end{center}
\end{frame}

\end{document}
