Jekyll2019-05-03T20:25:08+00:00http://www.sidhantbansal.com/feed.xmlSidhant BansalComputer Science enthusiastCS5330 - Randomized Algorithm Review/Summary2019-04-10T00:00:00+00:002019-04-10T00:00:00+00:00http://www.sidhantbansal.com/CS5330-Randomized-Algorithm-Review<p>So I took <a href="https://www.comp.nus.edu.sg/~gilbert/CS5330/">CS5330</a> a randomized algorithms course this semester in NUS taught by Prof. Seth Gilbert.
The course content in itself is nothing short of beautiful.</p>
<p><a href="/"><img src="https://imgs.xkcd.com/comics/psychic.png" alt="xkcd comic" style="width: 400px;" /></a></p>
<p>I will be describing the broad things I could take away from the course.
All the material + my notes for the course can be found <a href="https://www.dropbox.com/sh/lbvlrll6l7squ6l/AAArkDreW_DpKn4Lmj4PxUYua?dl=0">here</a></p>
<p>Note - I was one of the average students in the course, so don’t consider these as the only possible learnings from this course. In case you are already acquainted with this stuff just read up this <a href="https://www.scottaaronson.com/blog/?p=3712">blog post</a> recommended by our prof. It is the tl;dr version.</p>
<ol>
<li>Inequalities:
<ul>
<li>We are taught a LOT of inequalities, this image consists of all those that were taught and useful.<br />
<a href="/"><img src="/images/cs5330-inequalities.png" alt="Inequalities used in the course" style="width: 400px;" /></a></li>
<li>We have probabilities inequalities in this course like Union Bound, Markov, Chebyshev and Chernoff. These are taught and applied aggressively throughout the course. One imp. thing to note is that if you are bad at a Probability course like MA2216 because you aren’t good with pdf/join distributions/proofs for continuous distributions like Gaussian, Poisson, etc. then it shouldn’t affect your performance in this course, since here the R.Vs are generally Bernoulli or binomial in most cases AND often we are not trying to get a precise answer for a probabilistic event, instead we are always trying to bound it. Getting a hang of where to add/drop stuff when trying to bound things algebraically is a skill that one picks up during this course and which is quite hard to become good at.</li>
<li>We also exploit this kind of algebraic structure a lot in the course: <script type="math/tex">(1 - \frac{1}{n})^{n * c \log{n}} \leq e^{c * \log{n}} \leq \frac{1}{n^c}</script>, where c is a small positive integer.</li>
</ul>
</li>
<li>Min-Cut Kargers: An elegant algorithm to do min-cut. Key Insights were <script type="math/tex">\rightarrow</script>
<ul>
<li>If a problem of size <script type="math/tex">N</script> (in this case finding min-cut of a graph of size <script type="math/tex">N</script>) can be shrunk to a problem smaller in size (in this case to the size of <script type="math/tex">\frac{N}{\sqrt{2}}</script> with a decent success probability (here it is <script type="math/tex">0.5</script>), then instead of decomposing the problem like a straight chain, i.e to go from <script type="math/tex">N \rightarrow \frac{N}{\sqrt{2}} \rightarrow \frac{N}{2} \rightarrow \ldots</script>, and keep on reducing the success probability from <script type="math/tex">\frac{1}{2} \rightarrow \frac{1}{4} \rightarrow \frac{1}{8} \rightarrow \ldots</script> (almost 0). We can instead do branching :)</li>
<li>Branching here refers to this: Let us define <script type="math/tex">f(N)</script> to be the solve function for the problem of size <script type="math/tex">N</script> which returns the min-cut. Then instead of the chain method where we go from <script type="math/tex">f(N) \rightarrow f(\frac{N}{\sqrt{2}})</script>, now we will do something like this <script type="math/tex">\rightarrow</script></li>
<li><script type="math/tex">f(N) = \min(f(\frac{N}{\sqrt{2}}), f(\frac{N}{\sqrt{2}}))</script>, i.e call two instances of smaller size and take the better answer. (Note - both of them initially work on the same graph of size <script type="math/tex">N</script>, but because of randomness they will be contracting edges randomly, i.e the two instances of size <script type="math/tex">\frac{N}{\sqrt{2}}</script> being called, won’t be clones of one another)</li>
<li>Now analyzing this branching process you can realize that it has <script type="math/tex">2*\log{N}</script> layers in the recursion tree and each layer has doubled the nodes of the previous layer. The analysis is similar to a merge-sort algo and slightly slower than the chaining method. BUT the benefit in this approach comes from the fact that the probability of correctness is amplified hugely. Effectively now the success probability of the algorithm = probability that there is at least one path from the root to leaf in the recursion tree that has all success edges, where you can traverse an edge downwards successfully with a probability of <script type="math/tex">\frac{1}{2}</script>. This gets lower bounded by <script type="math/tex">\geq \frac{1}{depth} \geq \frac{1}{\log{N}}</script> (using a non-trivial tree analysis argument), which is MUCH better than earlier success odds of <script type="math/tex">\frac{1}{2^{2\log{N}}} = \frac{1}{N^2}</script>.</li>
<li>A nice argument is also shown that there can at most be <script type="math/tex">N^2</script> distinct min-cuts because success probability of Karger’s algo for a specific min-cut is at least <script type="math/tex">\frac{1}{N^2}</script>, so if you add it up for all distinct min-cuts it shouldn’t exceed <script type="math/tex">1</script>, therefore #distinct min-cuts <script type="math/tex">\leq N^2</script>.</li>
</ul>
</li>
<li>QuickSort Analysis:
<ul>
<li>Two ways to analyze the expected complexity. An interesting thing to learn was that JUST commenting on Expected Time Complexity of an algorithm is NOT enough to say it is a good/fast algorithm. Think about plotting Time taken (y-axis) vs Probability (x-axis) graph, it can happen that the tail doesn’t fall rapidly in this graph, so although mean is low, but there is enough variance that often your algo runs super slowly.</li>
<li>I tried to think of an algorithm with this kind of slowness, but I think it is hard to formalize such a case.<br />
<a href="/"><img src="/images/cs5330-distribution.jpg" alt="Faulty distribution?" style="width: 400px;" /></a></li>
<li>Because if this happens then <script type="math/tex">E[X]</script>, no longer remains in <script type="math/tex">O(N)</script> and instead goes up, since <script type="math/tex">constant * \Omega{(N)}</script> also contributes to <script type="math/tex">E[X]</script></li>
<li>Therefore we also analyze with what probability is the time complexity far away from the mean and try to show that this is very low. Aka <script type="math/tex">\Pr(X \geq c*N\log{N}) \leq \frac{1}{N^c}</script>.</li>
<li>The insight was, that just like in statistics, the mean of a distribution is NOT an idle way to boil down all the information about the distribution, similarly here just boiling down all the information to <script type="math/tex">E[X]</script> and commenting about it is NOT enough to be confident about the algorithm.</li>
<li>Additional References: <a href="http://www.johnmyleswhite.com/notebook/2013/03/22/modes-medians-and-means-an-unifying-perspective/?fbclid=IwAR0KLvaXqaPYgar02PM7_yrkwMt1Q_yOEI2-N80cHIHjYCUVN8mBViijg-U">Must read, about a unifying way to view mean, median, mode of a given statistic</a></li>
</ul>
</li>
<li>Stable Matching:
<ul>
<li>Not a big topic. We were primarily introduced to deferred decision making and stochastic domination. The problem in itself was put forward as a Balls and Bins problem.</li>
<li>Stochastic Domination although a simple concept, turns out to be very powerful when analyzing something. It basically comments that instead of analyzing a complicated probabilistic event we upper bound that event by a simpler one and analyze the simpler one.</li>
<li>Example: Algorithm <script type="math/tex">A</script> is successful with probability <script type="math/tex">\frac{x}{N}</script>, where <script type="math/tex">x</script> is some complicated function of <script type="math/tex">N</script>. But you know <script type="math/tex">x \geq \frac{N}{2}</script>. Then just say let us be pessimistic and say that it is successful with probability <script type="math/tex">\frac{1}{2}</script> exactly. Then if for this simpler algorithm we realize that it runs in <script type="math/tex">N\log{N}</script> with high probability, then we CAN SAY that Algorithm <script type="math/tex">A</script> definitely runs in at most <script type="math/tex">N\log{N}</script> with same high probability.</li>
<li>Additional References: <a href="https://en.wikipedia.org/wiki/Stochastic_ordering#Usual_stochastic_order">Wiki link for stochastic domination</a></li>
</ul>
</li>
<li>Hashing:
<ul>
<li>Open chaining is reduced to a balls and bins problem and analyzed using that.</li>
<li>Linear Probing has a somewhat hard analysis to grasp. The intuition of making a binary tree to define clusters is still not super clear to me.</li>
<li>I guess one of the key points is <script type="math/tex">E[COST] \leq \sum_{k = 1}^{N}k * \Pr(\text{an elt. is in a cluster of size }K)\\ \leq \sum_{l = 0}^{\log{N}}2^{l + 1} * \Pr(\text{an elt. is in a cluster of size }[2^l, 2^{l + 1}])</script></li>
<li>Now we show <script type="math/tex">\Pr(\text{an elt. is in a cluster of size }[2^l, 2^{l + 1}])</script> is small, that is exponentially decreasing with <script type="math/tex">l</script>. To show this we need 4th-moment inequalities and a non-trivial/magical idea involving a “binary tree” and “crowded contiguous segment definition”. I am still unclear as to why we need all these components for the proof to go through and still in the process of trying to understand this portion.</li>
</ul>
</li>
<li>Flajolet Martin:
<ul>
<li>Perhaps the MOST insane algorithm I have ever seen. The algorithm is like super short and has just 3 - 4 steps mainly. But as a competitive programmer, the magical thing is it enables you to “COUNT NUMBER OF DISTINCT ELEMENTS IN A STREAM/ARRAY USING A MIN FUNCTION AGGREGATION”. Obviously, it has two parameters for controlling the algorithm. Firstly, to improves its closeness to optimal answer in terms of delta and secondly the error probability with which it does not fall into the delta range. From a practical competitive programming standpoint, the algorithm is slightly redundant since it requires a lot of runs to reduces both these errors to enable it to pass on online judges. But still, its idea is super fascinating.</li>
<li>We discuss the FM algorithm, then FM+ which takes the average of a lot of instances of the FM algorithm.</li>
<li>This averaging of a lot of results is USEFUL in reducing the variance of the algorthm and thus making delta smaller. (This concept is somewhat more general in CS and equivalent to why people use random forests over decision trees in ML-algorithms to reduce variance in their results)</li>
<li>Then we make FM++ algorithm, which runs a lot of instances of FM+ and sort all the answers and returns the median. This is done because for the median to go bad (i.e lie in error region), at least more than HALF of the FM+ runs need to go bad. Since in FM+ we control the bad probability by some constant (ex. in lecture we used <script type="math/tex">\frac{1}{4}</script>). Now effectively the FM++ will fail only if more than half of the runs give a bad result. This we can see intuitively, decreases exponentially with the number of runs of FM+ we do. It is kind of like saying you have a coin which with probability $\frac{1}{4}$ gives HEAD and with remaining gives TAILS. Then what is the probability that more than 50% of the times in a run of <script type="math/tex">K</script> tosses it gives HEADS. This can be seen to decrease exponentially with <script type="math/tex">K</script> using Chernoff Bound.</li>
<li>The prof also told us that this “FIRST MEAN, THEN MEDIAN” technique is more of a general technique in randomized algos and also tested this in the midterm examination.</li>
<li>Additional References: <a href="https://en.wikipedia.org/wiki/Approximate_counting_algorithm">Increment counter algorithm, with a similar idea, tested for midterm</a></li>
</ul>
</li>
<li>Min Set Cover:
<ul>
<li>Model the problem as ILP (Integer Linear Programming) Problem. Then hand wave and say ILP is ALMOST Like LP. Use LP solver as a black-box. But wait…now the solutions are real numbers and not integers, so you use ROUNDING to get the results. Here rounding the number naively might not be good and the way you round your results is problem specific. In the case of Set Cover the prof showed us a specific rounding method which worked. Using that rounding method he showed that the algorithm gives a valid answer with probability <script type="math/tex">1-\frac{1}{e}</script>, which is although reasonably high, but constant. NOTE - This is NOT the probability of being OPTIMAL, but instead of just giving a VALID SET COVER.</li>
<li>Now the interesting issue is that if you think we might be able to do something like Karger branching / FM++ and combine multiple runs of this algo to increase this probability then you are correct, HOWEVER, there is no method to merge the answers which keep the answer small. So what you do is RUN this instance <script type="math/tex">\log{N}</script> times and take the union of all the sets found, which increases the VALID SET COVER probability exponentially, thus making the algorithm work w.h.p (with high probability), however, the answer NO LONGER REMAINS CLOSE TO OPTIMAL. Instead, the union of <script type="math/tex">\log{N}</script> instances effectively makes the size of the set cover = <script type="math/tex">\log{N}</script> * (size of the optimal set cover).</li>
<li>An interesting thing to note here is that this shows you don’t get a linear approximation of min set cover (optimization version is in NP-Hard) by using Randomized Algorithms. You can get a logarithmic factor approximation of this problem with very high probability.</li>
</ul>
</li>
<li>Random Walks and Expert Learning:
<ul>
<li>All these techniques are fairly advanced as compared to the topics discussed above and the fact that we did not have problem sets on these (all these topics are post week7-week8) highlight the fact that some technicalities in these lectures were hand-waved OR not meant to be understood completely by an average Joe like me. So I don’t think I am in a spot to give any insights on these topics.</li>
</ul>
</li>
<li>Probabilistic Methods:
<ul>
<li>This semester the prof did not go through this topic, however, if you search on the internet it is a somewhat standard topic in many randomized algorithm courses. The problem that the probabilistic method tries to tackle is to comment on the existence / bound of a certain deterministic thingy using probability argument.</li>
<li>Example: Just above at point 1. We see that Karger’s algorithm shows us a side-result that the number of distinct min-cuts is bounded by <script type="math/tex">N^{2}</script>, this is an example of a probabilistic method use case.</li>
<li>Another example that one can try out is to show that a 3-SAT problem with <script type="math/tex">k</script> clauses will have at least one solution instance which satisfies <script type="math/tex">\geq \frac{7}{8}k</script> clauses.</li>
<li>Additional References: <a href="http://web.cs.iastate.edu/~cs511/handout08/Approx_Max3SAT.pdf">MAX-3SAT Notes from another uni</a></li>
</ul>
</li>
</ol>
<p>Conclusion: The course structure is amazing and they teach a lot of good stuff. Prof. Seth Gilbert explains these algorithms very intuitively and you understand the feel of how the inequalities and math should work out after a few of his lectures. As for the grading component this semester, the module primarily consisted of Problem Sets, Midterm, Experimental Project and an Explanatory Paper on a randomized algorithm related research topic. The module does not have a final exam, so…the Random Walks and Expert Learning portion is NOT really graded anywhere.</p>So I took CS5330 a randomized algorithms course this semester in NUS taught by Prof. Seth Gilbert. The course content in itself is nothing short of beautiful.The Journey - Part 12019-02-09T00:00:00+00:002019-02-09T00:00:00+00:00http://www.sidhantbansal.com/The-Journey-Part-1<p>Hey, so I initially wrote this draft regarding my journey in CP, to be posted by Codechef in one of their blogs, but that never took place. It was a while back that happened, so now I have polished that draft and added some more details to make it more complete.
This post has some Q/A at the end which was supposed to be there for that Codechef blog, I will leave the crux of the content untouched since I think it is my honest opinion and might help some people. Although do note the content of this post was written around a year back.</p>
<p>I started CP (Competitive Programming) somewhere around 8-9th grade, with the aid of one of the seniors in my school. I still remember the day when one of my senior (Yash Tewari) told me to first do the first 25 Project Euler questions and only then he would guide me ahead. It took me around a month to get through those first 25 questions. After getting through those first 25 questions, Yash helped me out to learn newer algorithms and data structures. It was a fun experience to be able to get help from and discuss questions with a senior. Later on, he helped me, to move to more proper judges such as Codechef, Codeforces, WCIPEG. He also introduced me to the book of Dr. Steven Halim, Competitive Programming 3. In retrospect, I think he was the only person who truly mentored me and I now realize how much patience he had when dealing with all my silly doubts. And yes, after volunteering and helping out some of my own juniors I can very well say that I have never been as patient with my juniors as he was with me. (<em>RESPECT</em>)</p>
<p><strong>9th grade</strong> - I took my first attempt at ZIO and was fortunate enough to be able to clear it but in the INOI, I couldn’t really solve anything and ended with a 10/200 score. I would say this was not a big surprise for me since I did not expect a very good result in the first place because I was not yet good at Dynamic Programming questions or Graph theory questions. On the other hand, Yash did make the cut and went to IOI-TC (<em>RESPECT</em>)</p>
<p><strong>10th grade</strong> - I had made good friends with Daksh, Rajat, Anubhav and Aditya (all from DPS-Dwarka) who were also prepping for INOI. We had a facebook messenger thread where we used to discuss a lot of problems and used to regularly participate in inter-school coding competitions as well as online random competitions. I think the internal competition among us was the primary thing that drove us all and made us grow as good competitive programmers.
Fortunately, most of us were able to crack INOI this time through in 2015. So, we went to IOI-TC 2015. This IOI-TC was not really a competition for us DPS-Dwarka students (since the top scorers were miles ahead of us), but more of like an eye-opener which made us realize that people at the camp are very good and we need to put in more work for future years, to get into the team of top 4. This was the first time I met the gifted people in the circuit like Malvika, Mriganka, Kushagra, etc (It has been 4 years since that time, and I have forgotten some names).</p>
<p><strong>Lesson</strong> - Still a long way to go, since I was nowhere near to crack to the top-4. Secured rank-13 but couldn’t solve any problem completely, so there was a good enough gap between me and the top students.</p>
<p>Do note up-till this point, i.e from 8th to 10th grade I did CP as a hobby. I could devote a lot of time to this since there was no expectation nor reason for me to put a lot of effort in regular academics, so these days were stress-free in general because of chill academics.</p>
<p><strong>11th grade</strong> - I would say this was the toughest year for me in school since on one side you have the pressure of normal academics and JEE. Unfortunately, I was enrolled in FIITJEE and during the first half of the 11th was in a bit of middle ground as to whether I should try to prepare for JEE or not. By the middle of 11th I had decided to mostly drop out of my FIITJEE classes and decided that I wasn’t cut out to prepare for JEE, mainly because it required being good in Physics and Chemistry along with Math and also because I found much more joy in practicing on Codeforces or some other judge than solve package modules. I am no way saying that this was a good decision in the long term thought of getting into a college since it could have backfired had I not been able to represent at IOI/not get selected at future IOI-TCs. But yes, this was one of the turning point decisions I made.</p>
<p><em>(Note - I believe that some students currently in 10th/11th/12th grade might see the thing done above as a kind of motivation to stop preparing for JEE or something. Do realise that this is just my experience where the end results went on to be good despite dropping out of FIITJEE and not taking JEE seriously, I do know people where it did not go ahead the way they wanted, so don’t take this as some kind of advice or anything, it just a narration of an experience not a suggestion of any sort.)</em></p>
<p>During the IOI-TC 2016, I had a bit of hard luck since I was able to stay in top-4 until the second day of the exam at the camp and was performing reasonably well. But on the third day, I wasn’t able to solve one of the doable questions and lost my spot on the team since my rank slid to rank-7. This year, fortunately, Rajat from our school did make it to the team and ended up securing a Silver Medal at the Olympiad (<em>RESPECT</em>). Also this year Sampriti made it to the top-4 in his first time at INOI as well as IOI-TC, it was pretty inspiring to see him succeed in a single attempt at IOI-TC (<em>RESPECT</em>).</p>
<p><strong>12th grade</strong> - I would say that the hardest part for me in the entire journey was to go to the IOI-TC next year knowing fully well, that if luck isn’t on my side this year I will flunk and then I would have practically never been able to represent at IOI despite being at IOI-TC thrice. Just the fear of failing this year was crazy enough to give me the feels what JEE aspirants must face when they write their exam :P
This time around at IOI-TC 2017, I got typhoid just before the training camp started. The entire process of diagnosing that I had typhoid and then starting my treatment at home took roughly 3-4 days and therefore I skipped most of the training camp except the last 3 days on which the exam is conducted. I was somewhat better when I landed in Chennai to give the exam for IOI-TC. My parents came along with me for this exam and I stayed with them in a nearby hotel from CMI, since my condition was still fragile. I didn’t really have high hopes since I knew that I was not in my best physical condition. But damn, I hate to brag, but yes magically I did fairly well on day 1 of the exam and ended up being 2nd on the rank-table. Day 1 was enough to boost my self-confidence and make me believe that I can very well maintain my position for the remaining two days and end up in the top 4 finally. And yes, I did end up in top-4. It was one hell of a ride.</p>
<p><strong>Lesson</strong> - You need to have a good amount of self-confidence no matter how much prepared/unprepared you are.</p>
<p>After the IOI-TC selection test, I went for a roughly 20 days camp at CMI, to be trained by Rajat. I went there along with Nalin, we didn’t really prep a lot and mostly had good food, but we had a good time.</p>
<p><em>Do note until this point I had attended a few camps conducted by Codechef which are as follows-</em></p>
<p><em>1. Gandhinagar Camp - Immediately before IOI 2017. Best camp I attended during my high school period. Since the teachers were pretty good (Kevin Sogo + Errichto / Kamil Debowski)</em></p>
<p><em>2. Snackdown Camp - Attended sometime when I was in 11th grade, conducted by Codechef, teachers mainly were (Arjun Arul + Kevin Sogo). Quite math based content and since I was still in 11th grade and not really an ICPC candidate, therefore I found most of the content not that much relevant to IOI-TC/IOI. But overall good high-quality camp.</em></p>
<p><em>3. Amrita Camp - Attended sometime when I was in 10th grade. Okayish in terms of quality. The accommodation was not that good, however, we were taught by quite good Indian college students (Arjun Arul + Surya Kiran + Ajay Krishna).</em></p>
<p><em>(Note - By this time I had attended some inter-school coding competitions, college coding competitions, SEARCC, Codechef Snackdown, etc. But all these competitions were just good competitions to practice at. They were never the goal themselves so I won’t be covering their experiences here. Obviously, I think all these competitions are quite good, it is just that I never really prepared separately for them.)</em></p>
<p>Cracking to the team for India more or less generally means that you are good enough/have a quite high probability to secure bronze at the IOI. After coming from the 20-day thing at CMI, we went to IOI-2017. It was a good event and I had a good performance on day 1, but a bad one on day 2. I ended up securing a bronze medal with a rank of somewhere around 87th. Although the second day did not go as I expected since I couldn’t get partials on the 2nd and 3rd problem, but still I was more or less content with my performance. Being at IOI you get to meet truly gifted students. One of the closest encounters, for me, would be Srijon. Since the IOI-TC is only 8 days long with 20 students, so you don’t really spend enough time interacting with all the students. It was during the IOI that I interacted with him my first time and boy I envy that he is so smart. I think IOI is a good reference point in making almost anyone realize that you can never be good enough and that someone is always there better than you. I think going to IOI made me a humbler person in general.</p>
<p>Now an interesting turn of events took place. Initially, after IOI-TC 2017, I had given an interview at IIIT-H and got admission into the 5year course through Olympiad quota. I won’t explain the exact details of the process here, you can google it up if you want. I had also applied to NUS during the summer but received a rejection somewhere around June/July.
The Olympiad itself was in August, and there Dr. Steven Halim, the coach of Singapore contingent (and faculty at NUS, and author of Competitive Programming 3) met me after the results were out and by sheer magic got my decision for NUS flipped to an acceptance. Damn, I was lucky. Perhaps the luckiest I have ever been. Since the session had already started at NUS, so I had to decide on whether to go or not within a short span of 3-4 days. After some discussion, me and my parents ended up deciding to opt for NUS over IIIT-H, primarily because we thought that the education and the opportunities I will be able to get at NUS would be more as compared to IIIT-H. Now, after being at NUS for roughly 2 years, I can say, we took the correct call and I was damn lucky to have interacted with Dr. Halim and will always be thankful to him :)</p>
<p><strong>Conclusion</strong> - Although competitive programming stands for doing programming as a sport and competitively but it was at IOI-TC and IOI that I understood that a part of competitive programming was about appreciating what others have achieved in terms of skills through their hard work, intellect, and passion. At places like these you get to meet smart people, really smart people and if you simply envy them for what they are, you will probably end up being salty, enraged and pissed of. It would be much wiser to just genuinely appreciate them.
The journey of high school CP ended here for me, I was more or less content with the eventual results. One bronze medal as a witness to 4 years of hard work from 9th grade to 12th grade. Not a bad deal, I would say. Although the next part of it is still due. Since now preparing for a completely different ball game (aka ACM-ICPC) started when I entered NUS. This blog post would become a pain to read if I included that also, so I will just make another blog post after the end of this semester titled, <strong>The Journey - Part 2</strong> for that.</p>
<p><em>(Note - In the entire blog post I didn’t really cover any technical things as to where did I used to practice, what were the portions in CP I was strong/weak at. I did not do this mainly because I am still evolving and do not have a concise answer. One of the things I can say right off the bat is that for practice I have mainly done Codeforce, Codechef, WCIPEG, Past IOI-TC questions, up-till my 12th grade)</em></p>
<hr />
<p>FAQs -</p>
<p>Take all the suggestions below with a pinch of salt, since neither I am the best person to advise nor should you put faith in a guy whom you came across online :)</p>
<p>Q) Is DPS Dwarka a good place for someone interested in CP?</p>
<p>A) I do not endorse my school in the above post and I think that the faculty and principal were not particularly helpful/supportive to students who did CP. The main benefit I had in my school, was the presence of the Computers Club (C.O.R.E) where we were able to interact with other students interested in the same field and the fact that we are able to participate in the Delhi based inter-school programming events. But apart from that my school hasn’t yet started recognizing students (supporting them in terms of leave of absence for preparation for the Olympiad/funding travel for inter-school events which are in other states) pursuing Olympiad preparation despite having more than 6 - 7 IOI-TC students and 2 medallists. I still believe it is a good school if one wants to prepare and excel in Boards / JEE, but I have found that a lot of students doing CP have this illusion that DPS Dwarka has some classes or something to train students in CP, since we had a good trend of IOI-TC students in the past 2 - 3 years. So I am clarifying what I think about my school so that someone making the decision to come to DPS Dwarka for this very purpose makes a more aware decision.</p>
<p>Q) Do I have any suggestions for people who wish to improve in CP(Originally written for the Codechef blog)?</p>
<p>A)</p>
<ol>
<li>Spending time thinking about problems is MORE VALUABLE than coding out the solutions.</li>
<li>A good strong mathematical background helps a LOT. (Example - Proficiency in permutation and combination, Induction, Probability, etc.)</li>
<li>In India, we sometimes focus a lot on data structure as compared to the reduction portion/problem-solving in our problems. I would suggest students give more weight to the problem-solving aspect as compared to strengthening their data structures. Since I believe that in the final rounds of IOI - TC / IOI the trend is that they generally don’t test advanced data structures as frequently as strong problem-solving skills. For this, if you are free you might even go to the extent of practicing for RMO/INMO in case you think that helps.</li>
<li>I think proving your solution/algorithm is underrated in CP. Going by your intuition for a given question is a good strategy in a contest time, but during practice, I believe that trying to prove your approach is essential. It strengthens the concept and will hopefully help to crack a harder problem in the future because of the insights gained during the attempt of proving.</li>
<li>If you are Delhi / Kolkata / …., region then you can find a good number of inter-school programming competitions happening around your locality. I would suggest people be involved in these events to gauge how they perform in pressure and against their peers. Still don’t consider these events as the best metric for your performance, since sometimes inter-school programming events don’t have good quality problems.</li>
<li>Make a group of good close friends with whom you can discuss problems at lengths. I have found this method very productive for my growth since it helps to know about interesting problems which my friends find. Also when you discuss, the discussion is not about the code it is about finding the approach and why is it correct. This discussion is often much more valuable than practicing more problems in my opinion.</li>
<li>Start early. I think that starting something like CP during your 10-11th grade can sometimes be hard on the student. Because he/she might face the dilemma of splitting their time for Academics (PCM / JEE / Boards) and CP. Starting out in 8-9th grade gave me an edge over others, because of 2 reasons. Firstly, experience. I gained a lot of experience in onsite contests because I have appeared in so many. Secondly, strengthening of the concept. When you read about a certain concept on blogs/editorials, the time it takes to digest it can vary from person to person. But if you start out early, you are not on a clock to do stuff hurriedly, you can take a lot of time for things you find difficult</li>
<li>Please don’t make fake accounts. In India, amongst the school level CP student groups, since the last 2 - 3 years there has been a trend of students making fake accounts for practicing on online judges. Example - Let us say that I make an account named “ xyz” on Codechef and start doing problems from this account now. People do this because of the competitive environment. The reason behind doing this is so that others do not get to know what problems they are doing. But I think it is morally incorrect if one person has a fake account and another doesn’t. Why? Label the person using the fake account as A and the one with a normal account as B. Here A has the advantage to see what B is doing in practice, but B is deprived of this. Secondly, during live contests as well A can see how B performs but B is unaware if A participated or not. This is a typical example of a prisoner dilemma. Also, if all the students make up their mind to use fake accounts, then another problem comes up which is that then technically no one knows what other people are doing. In a case like this, let us say that A becomes a good CP competitor and now his juniors look at his account to see what kind of problems should they attempt or practice. They would not have a clue as to what to do since from his original account A would not have made any submissions. This basically takes us a step back in making the CP community good in our locality/country. I have seen people doing this first-hand and I personally hate this practice and think it is quite unethical.</li>
</ol>
<p>Q) Has doing CP helped you in your career/academic pursuits (Originally written for the Codechef blog)?</p>
<p>A) Yes, I think CP has helped me a lot in my career/academic pursuits. As for academics, I think it improved my problem-solving skill in math. And now being in college, I am not hesitant in taking good algorithms related courses, in fact, it is going to end up being my specialization area in my undergrad. Apart from that, it helped me get into a college since I did not really prepare for JEE nor did I have a strong profile for abroad US universities. One thing I would like to mention however is, that if you want to CP then do it for the fun, do it for the glory, do it for the prestige of IOI. Yes, it will help you in college admissions in India (CMI and IIIT-H recognize it up to a certain extent) and abroad, but if that is your sole aim, then I don’t think you would have a strong enough drive to actually crack through the entire process. Because you will fail somewhere when you have 4 rounds of screening, ZIO / ZCO then INOI, then IOITC and finally IOI. I believe that the motivation rooting from the passion for the subject and from the prestige of IOI is far greater than the (greed/fear) of (getting/not getting) into a good (Indian/abroad) university.
I think the most prominent example following this would be Rajat. One of the best things about his work ethic was that he did the Olympiad because of the love/obsession he had towards problem-solving. If you have ever interacted with him, you will realize how little did it matter to him about how doing CP would be a profit/loss statement for him in terms of career/academic prospects.
So I would conclude, that yes it does help you in your academic pursuits, but see it as a byproduct of doing the hard work and not as the goal. Because if seen as the goal, then I believe we will slowly transform the Olympiad into a JEE of some kind, where people do it to get into a good college. And frankly, I think one JEE exam in India is enough, we don’t need another.</p>Hey, so I initially wrote this draft regarding my journey in CP, to be posted by Codechef in one of their blogs, but that never took place. It was a while back that happened, so now I have polished that draft and added some more details to make it more complete. This post has some Q/A at the end which was supposed to be there for that Codechef blog, I will leave the crux of the content untouched since I think it is my honest opinion and might help some people. Although do note the content of this post was written around a year back.FFT - The tough made simple2018-07-29T00:00:00+00:002018-07-29T00:00:00+00:00http://www.sidhantbansal.com/FFT<p>This is a 2-post article explaining what is FFT (Fast Fourier Transform) and how FFT & NTT work.</p>
<p>This was originally written by me 2 years ago on CodeForces platform.</p>
<p>Since I intend to seriously start blogging, therefore I am attaching the PDFs and sharing the original links of this previous article.
I am not porting the original blog because it was written in HTML + Latex whereas this website as of now supports Markdown + Latex only, so editing the entire article would turn out to be an unnecessary and time - consuming task.</p>
<p>Any kind of feedback would be appreciated :)</p>
<p><a href="/pdfs/fft1.pdf">FFT 1 - PDF</a></p>
<p><a href="https://codeforces.com/blog/entry/43499">FFT 1 - Codeforces</a></p>
<p><a href="/pdfs/fft2.pdf">FFT 2 - PDF</a></p>
<p><a href="https://codeforces.com/blog/entry/48798">FFT 2 - Codeforces</a></p>This is a 2-post article explaining what is FFT (Fast Fourier Transform) and how FFT & NTT work.