Tips and Tricks for Competitive Programmers | Set 2 (language to be used for competitive programming)

Python Methods and Functions | Regular Expressions

C

  • C++ speed comparable to C: many C programs are also valid C++ programs — and such C programs run at the same speed when compiled
  • C++ does not force object-oriented programming: the language C++ contains some language extensions that facilitate object-oriented programming, and C++ doesn't force object-oriented design anywhere — it just allows it.
  • Parameterized types The template keyword allows the programmer to write generic (type independent) algorithm implementations. Where in C, you can write an implementation of a generic list with an element like:
     struct element_t {struct element_t * next, * prev; void * element; }; 

    C++ allows you to write something like:

     template & lt; typename T & gt; struct element_t {element_t & lt; T & gt; * next, * prev; T element; }; 
  • Large Standard Library: C++ makes full use of the C Standard Library, and C++ includes its own libraries, including Standard Template Library . The STL contains a number of useful templates, such as the sorting procedure above. It includes useful general data structures such as lists, maps, sets, and so on. Like the sort routine, other STL routines and data structures are "tailored" to the specific needs of the programmer — all the programmer has to do is fill in the types. 
    For example, if we need to implement binary search for a problem, we need to write our own function, whereas in C++ the procedure STL binary search is defined as
     binary_search (startaddress, endaddress, valuetofind) 

C++ vs. Java

  • Java codes are longer Programmer should write more when programming in Java

  • Java is verbose : In C++, I / O is easier just by writing scanf / printf. In Java, you need the BufferedReader class, which again is tedious.
  • C++ STL versus Java containers. Most programmers find it easier use STL.

  • C++ is more popular: whether it's release year or usability, but C + + surpasses Java in the number of users using the language.

  • C++ saves time: Java is slower than C++. We usually need to compile and run programs many times to test them. It takes relatively much less time in C++. Therefore, in time-limited contests, our time can be saved.

To summarize, C++ is still the most preferred language for which Java follows when it comes to programming competitions, but you should always choose the language you are comfortable with. Being confident in any language is most important. Never choose a language you “just learned” as it will be difficult for you to express yourself in that language.

For topics, start with simple questions and then go to specific questions and then consider the standard mathematical algorithms are an important part of superior concurrent programming.





Get Solution for free from DataCamp guru