Thursday, October 15, 2020

Tips for C++ programmers


 Competitive Programming is a sport like all other sports so you know that in every sport there is a time limit that is there and CP also has these constraints. So you need to keep this thing in your mind that time could create big trouble in your competition, here are some tips for you


  1. Create your own snippet.
  2. Use snippets in your competitive environment.
  3. Use the STL library as much as you can but you also know the working.
  4. Use VS -Code extensions like Competitive Companion, Codeforces extension.
I think it will help you, for more competitive programming related things check my other blogs.

Tuesday, October 13, 2020

Top 10 Algorithms and Data Structures for Competitive Programming

 


Topics :

  1. Graph algorithms
  2. Dynamic programming
  3. Searching and Sorting:
  4. Number theory and Other Mathematical
  5. Geometrical and Network Flow Algorithms
  6. Data Structures

Graph:

  1. Breadth First Search (BFS)
  2. Depth First Search (DFS)
  3. Shortest Path from source to all vertices **Dijkstra**
  4. Shortest Path from every vertex to every other vertex **Floyd Warshall**
  5. Minimum Spanning tree **Prim**
  6. Minimum Spanning tree **Kruskal**
  7. Topological Sort
  8. Johnson’s algorithm
  9. Articulation Points (or Cut Vertices) in a Graph
  10. Bridges in a graph

Dynamic Programming

  1. Longest Common Subsequence
  2. Longest Increasing Subsequence
  3. Edit Distance
  4. Minimum Partition
  5. Ways to Cover a Distance
  6. Longest Path In Matrix
  7. Subset Sum Problem
  8. Optimal Strategy for a Game
  9. 0-1 Knapsack Problem
  10. Assembly Line Scheduling

Searching And Sorting

  1. Binary Search
  2. Quick Sort
  3. Merge Sort
  4. Order Statistics
  5. KMP algorithm
  6. Rabin karp
  7. Z’s algorithm
  8. Aho Corasick String Matching
  9. Counting Sort

Number theory and Other Mathematical

Prime Numbers and Prime Factorization

  1. Primality Test | Set 1 (Introduction and School Method)
  2. Primality Test | Set 2 (Fermat Method)
  3. Primality Test | Set 3 (Miller–Rabin)
  4. Sieve of Eratosthenes
  5. Segmented Sieve
  6. Wilson’s Theorem
  7. Prime Factorisation
  8. Pollard’s rho algorithm

 Geometrical and Network Flow Algorithms

  1. Convex Hull
  2. Graham Scan
  3. Line Intersection
  4. Interval Tree
  5. Matrix Exponentiation
  6. Maxflow Ford Furkerson Algo and Edmond Karp Implementation
  7. Min cut
  8. Stable Marriage Problem
  9. Hopcroft–Karp Algorithm for Maximum Matching
  10. Dinic’s algo and e-maxx

Monday, October 12, 2020

What's the best way for a beginner to practice coding?

 The best way to learn is to learn by doing. You have to work on problem-solving skills by finding or creating problems and creating a solution that can be solved programmatically. You’ll also want to consider the kinds of problems you want to solve, or are best at solving, as the field of computer programming is quite broad.

Learn all the basic data structures and their algorithms in a particular programming language, ideally in C++ or Java or Python.


Once you know the implementation of all the data structures and their operations in that language, start solving problems modeled on each of these data structures & Algorithms (problem solving techniques).

Once you have solved some 50 problems in each category ( see the coding practice section of anyone of the competitive programming sites like GeeksforGeeks, HackerEarth, etc) you may assume that you have sufficient knowledge to start building simple softwares.

Go on doing more and more projects in a domain of interest. Soon you will be a master programmer and software developer.

Saturday, October 10, 2020

Programming realated suggestions for 1st year students ?

 Once you join your college you should start doing programming immediately,lots of students do this mistake by start doing coding in later 3rd or 4th year when companies start visiting campus ,but at that time you have lots of other things to do along with coding like you need to prepare your CS fundamentals(Operating System,DBMS,networking),so you dont give your full potential at that time.It should better if you start as early as you can.



Lets talk about what we should do first.

  • Start it by choosing a Programming Language C++,java or python.
  • Start Learning  their basics ,oops concept.
  • After that Start learning basic Data structures like Array,Linked List,Stack,Queue,Graph,Tree etc.
  • Start solving Competitive Problems from hackerrank,hackerearth,codechef etc.
Along with coding you should give your focus on CS fundamentals subject also,it will help you to crack interviews without any extra preparation.

So yes,These some tips for 1st year students,i hope it will help you,and Best of Luck for you future.

Thursday, October 8, 2020

How should i get started in Competitive Programming?

 Pick a language

Language is the most crucial thing for communicating ideas. An ideal language should be the one that can help you pass the time and space constraints. Python may not be the ideal solution here. Sure it involves a lot of built-in functions but one cannot deny it increases your time of execution putting an impact on CPU memory since it uses an interpreter for line by line execution.

So what to choose? As you can see below is a clear comparison between codes written in .py and .cpp. Surely it depends on the programmer’s ability to shorten code but not too much to create such a big difference.

2 of the best programming languages known for competitive programming are C and C++. We would recommend C++ here. Both of them take less time of execution than Python but one cannot deny how C++ STL makes your life easier.

Start with Basic Problems

Start your journey by solving basic problems like how to find a prime number, the number of factors of a number, factorial of a number, find greatest/lowest among array, insert an integer into an array, string operations using ASCII values, the sum of the digits of a number, etc. You can find a bunch of such problems on SPOJ.

You might not realize the worth of solving these problems but practicing these more frequently could help you shorten the code than earlier which you used to right and help you save time. Additionally, you will learn how to write error-free code.

Learn Data Structures and Algorithms

Data Structures and Algorithms are going to be your biggest friends if you choose to make them! Not only in your Competitive Programming journey but also in your Placement Interviews.

And it’s super fun to learn them. Once you dive into it, you’ll enjoy the essence. You’ll be amazed at the scope of DSA usage from Google’s fastest search to quickest commute in Uber, DSA plays a role everywhere!

Hey, wait! Are you practicing?

Tried HackerRank,CodeChef,HackerEarth Practice is highly important to understand the types of problems. Also, practice improves your question reading skills which can help you save time. Mathematics is super fun and you’ll be amazed to know how mathematical functions can be used to find solutions to such complex scenario problems.

As you finish the warm-up problems move on to implementations, strings, sorting, search, recursions, debugging and several other sections that’ll help you master the art of solving problems.

The best part about these platforms is they not only help you prepare but also enhances the spirit of competition, the spirit of winning. One just cannot express the feeling of satisfaction when you get solving problems. The feeling which you get achieving the Gold badge is amazing! Nobody can take it from you, it’s yours!

Why not involve your friends?

In today’s era, nobody can complain of being not aware of current technology trends. If you’re ignoring this, you’re missing out on a lot my friend!

Practice Competitive with a group of friends or a community. Most colleges now have IEEE, CodeChef Chapters in their universities which are non-profit organizations that help increase technical awareness among young students. Even though these opportunities are present in almost all colleges people usually prefer to procrastinate on this. Some students often tell - “I’ll join them next semester” or “I think maybe I can do it much better sitting in my hostel room” and later you find these guys watching Naruto in their hostel rooms. Make sure it’s not you!

Are we practicing?

Practice must never stop! Practice! Practice! Practice!

Even if you don’t get time, make it to just 5 - 7 problems a day. Learn about more algorithms like Greedy, Dynamic Programming, Backtracking, etc. And don’t forget to revise Data Structures and Algorithms regularly.

Competitions Define Us

Take it a positive way. Competitions. Yes, they do help us know where we stand. Even while you began practicing Problem Solving on HackerRank there would have already been over a million people and you’ve practiced daily to get to your favorite badge. True?

The same is with Competitions. Don’t get stressed. You may not want to directly target ICPC. But you can at least get started involved with regular challenges on platforms like CodeChef. There are many competitions that take place in colleges too, keep your eyes open to all. Don’t miss out on any opportunity.

Dedication

Yes, dedication is important because you’re investing a large part of your time here! You have to get serious about your Competitive routine. You have to constantly analyze the problems which you couldn’t solve earlier or the ones which were taking a long time. Don’t get disheartened if you’re not getting a solution. Look out for help. Again solve until you become perfect. Soon you’ll realize it doesn’t take long enough to get to a Star Ranking on CodeChef.

Wait! Don’t get complacent! Solve tougher problems. Remember during Engineering Exam preparation, some of us used to solve I.E Irodov problems in Physics. Why? Simple because we could differentiate ourselves from others and hence adopt the same here!

There are a lot of prestigious competitions and tournaments like ACM ICPC, Google’s Kickstart, HashCode, etc. Many of them are sponsored by big tech giants and there are absolutely big prizes!


    All the best!

    Tuesday, October 6, 2020

    Myths and reality of competitive programming:



    MythsReality
    It's too late to start competitive programmingThere is no fixed age for this best to start earlier in your programming career.
    It is an excellent way to get a software programming jobNo, it is not true as it is a sport which may benefits. However, it doesn't offer a job guarantee.
    You need to solve lots of computing programs before starting competitive programming.You can learn theory, but you solving computing challenges will not help as every competition is unique with its unique challenges.
    You need to an expert in algorithmYou need to be able to solve the problems
    Competitive programmers are all experienced programmers.No, it is for everyone even beginner code can participate
    It is just a hobby or a gameCompetitive programming, in contrast, covers some of the same skills taught in the computer science curriculum, but at a much deeper level. So, you can't call it a game.

    Sunday, October 4, 2020

    Fundamentals of competitive programming?

     

    svg viewer

    C++ refresher

    C++ is by far the most popular programming language for competitive programmers. It offers a library called STL (Standard Template Library). STL is a collection of C++ template classes that provides common data structures and functions.

    C++ is followed by other languages like Java, an Object Oriented Programming language. Java offers extensive libraries for data structures called Collections. Still, it’s a bit slower than C++, which is a downside.

    Another popular language in competition programming is Python because of its user-friendly functionality, as the code is significantly shorter and more concise than other programming languages. The downside to using Python is that it is quite slow compared to C/C++ and Java.

    Complexity analysis

    Before you dive into data structures and algorithms, it’s important that we cover complexity analysis, which is a way to describe an algorithm’s performance and efficiency as the input grows larger. It’s important that you analyze your algorithm’s runtime complexity to determine whether your solution is going to meet the time limit.

    There are three cases to consider:

    • Best case
    • Average case
    • Worst case

    When you are participating in a competition, you want to focus on the worst-case analysis. Typically, the inputs will force your solution to its worst-case performance.

    Big O notation is an asymptotic analysis that describes how long an algorithm takes to perform. In other words, it’s used to talk about how efficient or complex an algorithm is.

    Friday, October 2, 2020

    Which language is best for competitive programming?

    • C++:

     C++ is the most preferred language for competitive programming mainly because of its STL. Short for Standard Template Library, the STL is a collection of C++ templates to help programmers quickly tackle basic data structures and functions such as lists, stacks, arrays, etc. It is a library of container classes, algorithms, and iterators.

    STL is what ensure speed while coding in C++. Providing the basic data structures and functions as templates, STL cuts down a lot of your coding time. The power of C++ is undebatable because not only is it built on top of C (the mother of all programming languages) but also because it provides support for OOPS along with other features helpful during coding contests. Other than that, the verbosity of C++ codes is comparatively lesser than Java which makes it easier to code in.

     




    • Java:

    Java is another classic programming language that’s extensively used for competitive programming. The fans of Java swear by the BigInteger class which is used for performing mathematical computations on large integers quickly. It comes in extremely handy during The exception handling is again something that Java is universally applauded for. It’s challenging to find segmentation faults in C++, but it’s easy to notice the ArrayIndexOutOfBound exception.

    Although Java lacks STL, it has containers which perform pretty much the same function. Although the containers in Java are not as extensive as STL in C++, there are a few situations where STL doesn’t have a direct solution. For example, in case of priority_queue in STL, it doesn’t support decrease-key operation which is required for implementations of essential algorithms like Prim’s and Dijkstra’s. Java also has extensive support for geometrical problems. Its jawa.awt.geom package includes stuff like line-line/segment-segment intersection and polygon segment intersection. It comes in extremely helpful during some of the complicated problems of competitive programming that require you to deal with geometrical shapes and figures.



     

    • Python:

    Over the years, Python has seen tremendous growth in the number of the people who use it. This can mainly be attributed to the fact that it takes very little time to come to grips with the (barely existent) syntax of Python – which is not the case with the other two languages we mentioned. One more reason that programmers are switching to Python is the REPL support. REPL, or Read-Eval-Print-Loop, lets you test your ideas under time constraints. Something that can come in quite handy during programming contests. Just like Java, Python too has a BigInteger class helpful for working with large integers.

    However, if we talk about compilation speed, Python stands third in the list. Many times you might get a TLE (time limit exceeded) error for an algorithm in Python, but the same might get cleared if you code it in C++.   
    To conclude, let’s reiterate that there’s no absolute best programming language. Each has a set of pros and cons and to be expert at competitive programming; you’ll need to have an extremely logical approach irrespective of the language you choose.

    Tips for C++ programmers

     Competitive Programming is a sport like all other sports so you know that in every sport there is a time limit that is there and CP also ha...