Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Intro bundle. #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bundles/01-intro/01-intro.pdf
Binary file not shown.
8 changes: 2 additions & 6 deletions bundles/01-intro/README.md
Original file line number Diff line number Diff line change
@@ -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
* https://algoleague.com/contest/algorithm-program-intro-contest
38 changes: 29 additions & 9 deletions bundles/01-intro/latex/01-intro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}



Expand Down Expand Up @@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this sentences is verry complex, it can be simplified

$$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.
Expand Down Expand Up @@ -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.



Expand Down Expand Up @@ -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}
Expand All @@ -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}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
\subsection{Priority Queues}
\subsection{Priority Queues & Heaps}

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 <queue>}, not \lstinline{<priority_queue>}. 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 <queue>}, not \lstinline{<priority_queue>}. 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 <iostream>
#include <queue>
using namespace std;

int main(){
priority_queue<int> pq;

for(int i = 0 ; i < 5 ; i ++){
pq.push(i);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like stack implementation, not PQ implementation. You should put more complex code in here,
instead of 0 to 5. putting random values, works better.
https://www.geeksforgeeks.org/efficient-way-to-initialize-a-priority-queue/

}

while(!pq.empty()){
cout << pq.top() << " ";
pq.pop();
}
// 4 3 2 1 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 4 3 2 1 0
// Output: 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}
Expand Down