Skip to main content

Posts

Basics of Combinatorics

Counting the objects that satisfy some criteria is a very common task in both Programming and in real-life situations. The myriad ways of counting the number of elements in a set is one of the main tasks in combinatorics, and I’ll try to describe some basic aspects of it in this blog. Combinatorics is all about number of ways of choosing some objects out of a collection and/or number of ways of their arrangement. For example suppose there are five members in a club, let's say there names are A, B, C, D, and E, and one of them is to be chosen as the coordinator. Clearly any one out of them can be chosen so there are 5 ways. Now suppose two members are to be chosen for the position of coordinator and co-coordinator. Now, we can choose A as coordinator and one out of the rest 4 as co-coordinator. Similarly we can choose B as coordinator and one of out the remaining 4 as co-coordinator, and similarly with C, D and E. So there will be total 20 possible ways. Combinatorial primitives ...
Recent posts

Mathematics For Competitive Programming

  I have seen a number of competitors complain that they are unfairly disadvantaged because many competitive programming platform problems are too mathematical. Personally, I love mathematics and thus I am biased in this issue. Nevertheless, I strongly believe that problems should contain at least some math, because mathematics and computer science often go hand in hand. It is hard to imagine a world where these two fields could exist without any interaction with each other. These days, a great deal of applied mathematics is performed on computers such as solving large systems of equations and approximating solutions to differential equations for which no closed formula exists. Mathematics is widely used in computer science research, as well as being heavily applied to graph algorithms and areas of computer vision. In this blog we will see theory and practical application to some of the more common mathematical constructs. The topics covered are: primes, GCD, Quadratic Equations, P...

Finding all Primes Up-to N using Sieve of Atkin

                                                                                                   -By: Sambhav Sieve of Atkin For Finding all Primes Up-to N. Hello Friends, Welcome to my other blog on competitive programming. Today, I am going to continue one advance mathematical concept that already we started in previous blog .As you might have already figured out that today’s we are going to discuss Sieve of primes using the Atkin’s approach. So, without wasting much time, let’s get started. The Sieve of Atkin is a modern algorithm for finding all prime numbers up to a specified integer. Compared with the ancient sieve of Eratosthenes , which marks off multiple of squares of primes, thus achieving a better theoretica...

Finding all Primes Up-to N using Sieve of Eratosthenes

                                                                                                   -By: Sambhav Sieve of Eratosthenes For Finding all Primes Up-to N. Hello Friends, Welcome to my first blog on competitive programming. Today, I am going to illuminate one fascinating mathematical concept that can give you an edge over others in coding contest. As you might have already figured out that today’s topic of discussion is about Sieve of primes using the Eratosthenes’s approach. So, without wasting much time, let’s get started. /* Before I tell you the Statement of the problem. Let us see what are prime numbers and how we can figure out whether a number is prime or not. */ A prime number is a whole number greater th...