diff --git a/bundles/01-intro/01-intro.pdf b/bundles/01-intro/01-intro.pdf index 12afaae..d8ceec2 100644 Binary files a/bundles/01-intro/01-intro.pdf and b/bundles/01-intro/01-intro.pdf differ diff --git a/bundles/01-intro/README.md b/bundles/01-intro/README.md index 72a991c..6a3bcab 100644 --- a/bundles/01-intro/README.md +++ b/bundles/01-intro/README.md @@ -1,7 +1,3 @@ -Onsite Contest +Contest -------------- -* https://www.hackerrank.com/inzva-01-intro-onsite-2018 - -Online Contest --------------- -* https://www.hackerrank.com/inzva-01-intro-online-2018 \ No newline at end of file +* https://algoleague.com/contest/algorithm-program-intro-contest \ No newline at end of file diff --git a/bundles/01-intro/onsite-contest-codes/Buraks_Prime_Number.py b/bundles/01-intro/algoleague-contest-codes/Buraks_Prime_Number.py similarity index 100% rename from bundles/01-intro/onsite-contest-codes/Buraks_Prime_Number.py rename to bundles/01-intro/algoleague-contest-codes/Buraks_Prime_Number.py diff --git a/bundles/01-intro/onsite-contest-codes/Buraks_Sequence.py b/bundles/01-intro/algoleague-contest-codes/Buraks_Sequence.py similarity index 100% rename from bundles/01-intro/onsite-contest-codes/Buraks_Sequence.py rename to bundles/01-intro/algoleague-contest-codes/Buraks_Sequence.py diff --git a/bundles/01-intro/onsite-contest-codes/Lights.py b/bundles/01-intro/algoleague-contest-codes/Lights.py similarity index 100% rename from bundles/01-intro/onsite-contest-codes/Lights.py rename to bundles/01-intro/algoleague-contest-codes/Lights.py diff --git a/bundles/01-intro/online-contest-codes/algo_team.cpp b/bundles/01-intro/algoleague-contest-codes/algo_team.cpp similarity index 100% rename from bundles/01-intro/online-contest-codes/algo_team.cpp rename to bundles/01-intro/algoleague-contest-codes/algo_team.cpp diff --git a/bundles/01-intro/online-contest-codes/array_triplets.cpp b/bundles/01-intro/algoleague-contest-codes/array_triplets.cpp similarity index 100% rename from bundles/01-intro/online-contest-codes/array_triplets.cpp rename to bundles/01-intro/algoleague-contest-codes/array_triplets.cpp diff --git a/bundles/01-intro/online-contest-codes/arrow.py b/bundles/01-intro/algoleague-contest-codes/arrow.py similarity index 100% rename from bundles/01-intro/online-contest-codes/arrow.py rename to bundles/01-intro/algoleague-contest-codes/arrow.py diff --git a/bundles/01-intro/latex/01-intro.tex b/bundles/01-intro/latex/01-intro.tex index 52cc2e5..f1a751a 100644 --- a/bundles/01-intro/latex/01-intro.tex +++ b/bundles/01-intro/latex/01-intro.tex @@ -43,9 +43,9 @@ \section*{Appendix} -\newcommand{\mytitle}{\textbf{inzva Algorithm Programme 2018-2019\\ \ \\Bundle 1 \\ \ \\ Intro}} +\newcommand{\mytitle}{\textbf{inzva Algorithm Program\\ \ \\Bundle 1 \\ \ \\ Intro}} \title{\vspace{-2em}\mytitle\vspace{-0.3em}} -\author{\textbf{Editor}\\Muhammed Burak Bu\u{g}rul\\ \ \\ \textbf{Reviewers} \\ Kadir Emre Oto\\Yusuf Hakan Kalayc{\i}} +\author{\textbf{Editor}\\Muhammed Burak Bu\u{g}rul\\ \ \\ \textbf{Reviewers} \\ Kadir Emre Oto\\Yusuf Hakan Kalayc{\i} \\ Emin Ers{ΓΌ}s} @@ -320,11 +320,11 @@ \subsection{The Arrow Operator(C++)} \section{Big O Notation} When dealing with algorithms or coming up with a solution, we need to calculate how fast our algorithm or solution is. We can calculate this in terms of number of operations. Big O notation moves in exactly at this point. Big O notation gives an upper limit to these number of operations. The formal definition of Big O is\cite{bigo}:\\ \ \\ -Let f be a real or complex valued function and g a real valued function, both defined on some unbounded subset of the real positive numbers, such that g(x) is strictly positive for all large enough values of x. One writes:\\ +Let $f$ be a real or complex valued function and $g$ a real valued function, both defined on some unbounded subset of the real positive numbers, such that g(x) is strictly positive for all large enough values of $x$. One writes:\\ $$f(x) = O(g(x)) \ as\ x -> \infty$$ \\ \ \\ -If and only if for all sufficiently large values of x, the absolute value of f(x) is at most a positive constant multiple of g(x). That is, f(x) = O(g(x)) if and only if there exists a positive real number M and a real number $x_0$ such that: \\ +If and only if for all sufficiently large values of x, the absolute value of $f(x)$ is at most a positive constant multiple of $g(x)$. That is, $f(x)$ = $O(g(x))$ if and only if there exists a positive real number M and a real number $x_0$ such that: \\ $$|f(x)| \leq Mg(x)\ for \ all\ x\ such\ that\ x_0 \leq x$$ -In many contexts, the assumption that we are interested in the growth rate as the variable x goes to infinity is left unstated, and one writes more simply that: +In many contexts, the assumption that we are interested in the growth rate as the variable $x$ goes to infinity is left unstated, and one writes more simply that: $$f(x) = O(g(x))$$ Almost every case for competitive programming, basic understanding of Big O notation is enough to decide whether to implement a solution or not. @@ -428,7 +428,7 @@ \subsection{Time Complexity} % Insert recursion tree png here -f() function called more than one for some values of n. Actually in every level, number of function calls doubles. So time complexity of the recursive implementation is $O(2^n)$. It is far away worse than the iterative one. Recursive one can be optimized by techniques like memoization, but it is another topic to learn in further weeks. +fibonacci() function called more than one for some values of n. Actually in every level, number of function calls doubles. So time complexity of the recursive implementation is $O(2^n)$. It is far away worse than the iterative one. Recursive one can be optimized by techniques like memoization, but it is another topic to learn in further weeks. @@ -620,7 +620,6 @@ \subsection{Vectors} } \end{minted} -\cleardoublepage \textbf{Python:} Python lists already behave like vectors: \begin{minted}[frame=lines,linenos,fontsize=\footnotesize]{python} @@ -635,14 +634,35 @@ \subsection{Vectors} \subsection{Stacks, Queues, and Deques} \textbf{C++:} They are no different than stack, queue and deque we already know. It provides the implementation, you can simply include the libraries and use them. See \href{http://www.cplusplus.com/reference/queue/queue/}{queue}, \href{http://www.cplusplus.com/reference/stack/stack/}{stack}, \href{http://www.cplusplus.com/reference/deque/deque/}{deque} - \subsection{Priority Queues} It is basically a built-in heap structure. You can add an element in $O(logN)$ time, get the first item in $O(logN)$ time. The first item will be decided according to your choice of priority. This priority can be magnitude of value, enterence time etc. -\textbf{C++: } The different thing for priority queue is you should add \lstinline{#include }, not \lstinline{}. You can find samples \href{http://www.cplusplus.com/reference/queue/priority_queue/}{here}. Again, you can define a priority queue with any type you want. +\textbf{C++: }The different thing for priority queue is you should add \lstinline{#include }, not \lstinline{}. You can find samples \href{http://www.cplusplus.com/reference/queue/priority_queue/}{here}. Again, you can define a priority queue with any type you want. \textbf{Note:} Default \lstinline{priority_queue} prioritizes elements by highest value first. \href{https://en.cppreference.com/w/cpp/container/priority_queue}{Here} is three ways of defining priority. +\begin{minted}[frame=lines,linenos,fontsize=\footnotesize]{c++} +#include +#include +using namespace std; + +int main(){ + priority_queue pq; + + for(int i = 0 ; i < 5 ; i ++){ + pq.push(i); + } + + while(!pq.empty()){ + cout << pq.top() << " "; + pq.pop(); + } + // 4 3 2 1 0 + return 0; +} + +\end{minted} + \textbf{Python: } You can use \href{https://docs.python.org/2/library/heapq.html}{heapq} in python \subsection{Sets and Maps} diff --git a/bundles/01-intro/onsite-contest-codes/It_is_Brute_Force.py b/bundles/01-intro/old-contest-codes/It_is_Brute_Force.py similarity index 100% rename from bundles/01-intro/onsite-contest-codes/It_is_Brute_Force.py rename to bundles/01-intro/old-contest-codes/It_is_Brute_Force.py diff --git a/bundles/01-intro/onsite-contest-codes/Two_Strings.py b/bundles/01-intro/old-contest-codes/Two_Strings.py similarity index 100% rename from bundles/01-intro/onsite-contest-codes/Two_Strings.py rename to bundles/01-intro/old-contest-codes/Two_Strings.py diff --git a/bundles/01-intro/online-contest-codes/almost_sorted.py b/bundles/01-intro/old-contest-codes/almost_sorted.py similarity index 100% rename from bundles/01-intro/online-contest-codes/almost_sorted.py rename to bundles/01-intro/old-contest-codes/almost_sorted.py diff --git a/bundles/01-intro/online-contest-codes/classes_and_objects.cpp b/bundles/01-intro/old-contest-codes/classes_and_objects.cpp similarity index 100% rename from bundles/01-intro/online-contest-codes/classes_and_objects.cpp rename to bundles/01-intro/old-contest-codes/classes_and_objects.cpp diff --git a/bundles/01-intro/online-contest-codes/drawing_book.py b/bundles/01-intro/old-contest-codes/drawing_book.py similarity index 100% rename from bundles/01-intro/online-contest-codes/drawing_book.py rename to bundles/01-intro/old-contest-codes/drawing_book.py diff --git a/bundles/01-intro/online-contest-codes/matrix_layer_rotation.py b/bundles/01-intro/old-contest-codes/matrix_layer_rotation.py similarity index 100% rename from bundles/01-intro/online-contest-codes/matrix_layer_rotation.py rename to bundles/01-intro/old-contest-codes/matrix_layer_rotation.py diff --git a/bundles/01-intro/online-contest-codes/the_bomberman_game.py b/bundles/01-intro/old-contest-codes/the_bomberman_game.py similarity index 100% rename from bundles/01-intro/online-contest-codes/the_bomberman_game.py rename to bundles/01-intro/old-contest-codes/the_bomberman_game.py