body, html { width: 100%; height: 100%; } body{ padding-top:100px; } body, h1, h2, h3, h4, h5, h6 { font-family: "Lato","Helvetica Neue",Helvetica,Arial,sans-serif; font-weight: 700; } #content{ min-height: 600px; } #banner_image { padding-bottom: 50px; text-align: center; color: #f8f8f8; background: url(../img/intro-bg_1.jpg) no-repeat center center; background-size: cover; } #banner_content { position: relative; padding-top: 6%; padding-bottom: 6%; margin-top: 12%; margin-bottom: 12%; background-color: rgba(0, 0, 0, 0.7); max-width: 660px; } #item_list { padding-top: 50px; } /*This code ensures that when we navigate to a particular section of a page, the section does not get lost behind the header*/ #cameras:before, #watches:before, #shirts:before{ display: block; content: " "; margin-top: -85px; height: 85px; visibility: hidden; } #login-panel .panel-footer{ font-weight:normal; } footer { padding: 10px 0; background-color: #101010; color:#9d9d9d; bottom: 0; width: 100%; } .red{ color:red; } #settings-container{ margin-bottom:10px; } .navbar-brand{ font-size:20px; } @media(max-width:768px) { #banner_content { padding-bottom: 15%; } footer{ text-align:left; } } .remove_item_link{ color:#0000ff; }

What is Cryptography?

Look at this picture
Can you identify who it is ?
I think not!!!                          right ?
This is cryptography...
Where actual information is getting hided behind other means of data, so un-authorized user unable to identify what actually the message is
So there are several techniques/approaches followed across the organizations to hide the actual message
Cryptography is the study of keeping information hidden. Problems in cryptography generally address how to send information across some channel without other people seeing it? In the old days, this was much easier since you'd have a personal messenger, and as long as this person wasn't intercepted, your message was safe. Nowadays, messages are transmitted electronically through space, which means anyone could potentially eavesdrop. Modern cryptography studies how messages can be "encrypted" so that only the intended recipient can decipher the message.

This is used all the time, for example, when you log into your email. How does the email service verify that you entered the correct password for your username, without actually keeping a database of all username/password pairs? This is an example of a cryptography problem.

In simple words Cryptography is a combination of mathematics and security engineering. It offers a great tools which are used in all the modern security protocols. You can say, it is kind of a technology which enables the protection of distributed systems, and still it’s one of the thing which is somewhat hard to do it in a right manner.
Cryptography is quite related to two disciplines cryptology & cryptanalysis. Cryptography comes with some of the techniques like microdots, merging of words with images and other methods to hide information in a storage devices. Though in today's date, you can say that cryptography is like scrambling of plain text into cipher-text that no one can read it unless it's decrypted in order to keep the information hidden from the unauthorized person.
Today's cryptography comes with the following 4 objectives:
Confidentiality: Means the information can only be understood by the person for whom the information is.
Integrity: The information cannot be changed or intercepted between sender and receiver without the detection of the change is happening.
Non-Repudiation: The creator or sender of the data cannot say ‘No’ later on like this information is not transferred from their side.
Authentication: The sender or receiver can make confirmation of each other's identity & the origin from the information is sent or received.
This word Cryptography is derived from the Greek kryptos, means hidden. The main originality of cryptography is from about 2000 BC, during the time when hieroglyphics were practiced by Egyptian.
In today's date, cryptography plays a big role in the realms of mathematicians and computer scientists. The ability to securely transfer and store the critical information has played a big role in success of war as well business.
Cryptography has been in focus to several restrictions in different countries, as governments don't want their certain entities in and out of country to have access to certain confidential information’s that it could become a threat to national interests.
Though internet has adopted this mechanism in order to provide powerful programs safely to everyone, so this techniques of cryptography is mostly used for public domains.

What are some cool C++ tricks to use in a programming contest?

Using auto to declare dataypes can save lot of time during programming contests.

When a variable is defined as auto, compiler determines its type during compile-time. For example,
  1. auto a = 1; // a will become 'int'
  2. auto b = 1LL; // b will become 'long long'
  3. auto c = 1.0; // c will become 'double'
  4. auto d = "variable"; // d will become 'string'

This is extremely useful when dealing with iterators. For iterating over map<int,vector<int>> Map, instead of writing this,
  1. for(map<int,vector<int>>:: iterator it = Map.begin(); it != Map.end(); it++ ){}

it is possible to write this.
  1. for(auto it = Map.begin(); it != Map.end(); it++ ){}

There is an even shorter way to write it.
  1. for(auto &it : Map){}
These type of loops are called range based loops, previously which was supported by java only. Note that, it is not an iterator in range based loops. So for accessing elements, it. should be used instead of it->.
  • Loop in C-string:
  1. char s[100];
  2. for (int i = 0; s[i]; ++i) { ... }
This is extremely useful (also avoids the strlen usage, that you could forget is O(n) and put on for condition).
  • Testing if not negative 1:
  1. if (~x) { ... }
In competitive programming we tend to write as little as possible, só a simple x ! = -1 can be shortened to 2 characters.
This works because negative numbers use two’s complement, so -1 is represented as all ones in binary. The tilde (~) operation inverts all bits of the variable, so the -1 turns into a zero, and any other number turns into something not zero. The if condition is valid if it’s not zero, so ~x is valid for any value different than zero.
  • Least significant 1 bit
  1. int lsb = x&-x;
This is a very useful operation than returns the LSB (EDIT: the least significant bit with value 1) of a number. If you’re used to Fenwick Tree (aka Binary Indexed Tree, or just BIT) then you know how useful it is.
This also works because of two’s complement. If you AND any number and it’s negative you obtain the LSB. Very simple and fast.
  • More than one operation per line
  1. if (dist[v] > dist[u] + w)
  2. dist[v] = dist[u] + w, q.push(v);
Many people don’t know this, but you can have statements split by commas. This I tend to use in every problem I solve, it reduces the code and avoids the use of semicolons.
The only down side is that you can’t use with breakcontinue or return (not statements :/). So when I have to use any of these I have to add braces and semicolons.
  • Scanf on array
  1. int a[100];
  2. for (int i = 0; i < n; ++i) scanf("%d", a+i);
This I don’t like very much because it doesn’t work for arrays with higher dimensions, but since most problems have at most 1D input it’s quite useful too (although I tend to use the &a[i], but my teammates use this trick).
  • Order array without losing original order
  1. int a[100], p[100];
  2. // receive input
  3. for (int i = 0; i < n; ++i) scanf("%d", &a[i]), p[i] = i;
  5. sort(p, p+n, [=](int i, int j) { return a[i] < a[j]; });
This is extremely useful!
First you don’t lose the original order (for offline algorithms this can be necessary).
Second you can do the same for how many dimensions you have (for 2D points: x[] and y[]; or 3D: x[], y[] and z[]; or any number of arrays..) and you don’t have to create structures (lot’s of lines saved) or use tuple or pairs (these are annoying in competitive programming. Using pair of pair you have something like: x.first.second + x.second.second and you line goes extra large and hard to read).
  • Infinite
  1. const int INF = 0x3f3f3f3f;
This infinite constant is very useful too. I used to do something like x = 2e9; but I had to take care about not adding infinites (because of integer overflow) and stuff like this. This constant can be doubled without overflowing and also can be set very easily this way:
  1. int dist[1000];
  2. memset(dist, 63, sizeof(dist)); // 0x3f == 63
For shortest path algorithms I always use this (I used to tend -1 version, but I had to do additional checks to verify if dist == -1 and if not..) and in CP BFS and SSSP are very common problems.
I think that’s all for now. If I remember any other trick I’ll edit this post, but that’s all I can remember for now!

How were Programming Language invented and Why ?

The hardware of a computer only understands 0 and 1: electricity or no electricity.
First problem: different hardware needs different 0’s an 1’s. Cue “computer architecture”, a structure that allows the processor to convert a simple instruction set (assembly or assembler) to the 0’s and 1’s that fit your hardware. For most computers this is x86, 32 or 64 bit.
Second problem: it’s pretty inconvenient to type whole programs in assembly language, since it supports only the most basic commands (add, multiply, loop). So programmers write in “higher programming languages”, which offer more complex structures and commands (classes, interfaces, …). Then the compiler converts all this to assembly matching the hardware. The high level program remains the same for all hardware!
Lastly there’s a big variation in high level programming languages. The differences here are because someone wants specific features for a certain niche. Java for example has its own mini-architecture “java virtual machine”, making it even easier to use on different hardware. PHP has smooth web-database interactions, C++ is made for OOP, … New languages arise when someone says “hmm I wish there was a language that combines x and y features”

What is Computer Programming

Programming a computer to solve a problem always requires defining data to represent the things in your problem; this is called modeling. It also requires explaining unambiguously what process to follow in order to solve the problem. This process of explaining is where different paradigms of programming come in:
  • In imperative programming, we tell the computer what to do to the data. The computer starts out with its memory containing stuff, we tell it how to change that stuff, and it makes those changes.
  • In functional programming, we tell the computer how to build output data from input data. We use functions, which are rules that say how to combine or transform things; they consume inputs and produce outputs.
  • In logic programming, we specify a set of constraints -- rules that say how things are related -- and then ask a question; the computer runs a program that examines all those constraints and finds all valid answers to the question.
For decades, imperative programming was the dominant (or even the only) option, because at its heart, a digital computer is a bunch of switches and rules for how to switch them on and off. Functional and logic programming existed, more or less, only as language spoken by mathematicians. By now, though, programmers have written a vast menagerie of interpreters and compilers -- programs that run or translate other programs, respectively -- that allow us to communicate in whatever kind of language seems most suitable to the problem we're solving. We even have domain-specific languages that are fine-tuned for specific classes of problems: statistics, physical simulations, music, and typesetting are just a few that come to mind.

And why does all this matter? Because, again, the aim of programming is to explain solutions. Sure, computing the solution automatically is great -- after all, without that ability computers would be useless -- but good programs are meant for other people to read and understand, not just for them to use.

Programming is about :
  • Evaluation and substitution. These are the basic algebra skills that programs are built on, and that programmers mentally fall back on when trying to figure out why a program isn't behaving as expected.
  • Modeling. Information is complex; solving problems with the computer (or with math) always somehow involves defining and using data to represent information from the problem.
  • Managing complexity: Breaking problems and solutions down into chunks that can be understood easily. Abstraction (as Tikhon Jelvis mentioned) is the main tool for this.
  • Communication. In at least two ways, this is important: (1) Determining what your clients want, so you are solving the right problems. (2) Organizing and documenting your work so that you (or the next programmer to touch it) will be able to understand it, months or years later.
  • Patience and perseveration. When things aren't working right, there's usually something you haven't noticed. Learning what that something is often requires mentally retracing your steps, and manually re-running code on different inputs, until you see what you've been missing. This may take a while.
  • Discipline. Writing tests and specifying what work must be done are both decidedly unsexy tasks, but they both make your work easier and give you confidence that you've done your work correctly.

Why C and C++ runs faster than Python, Perl and Ruby

This answer has the potential to get overly complex, so I'll try and keep it simple and concentrate on the “big picture”.
It basically boils down. To the difference between a statically typed (like C/C++) vs dynamically typed languages (like Python, Perl and Ruby).
In a static language like C/C++ the software being developed uses a closed system of types. The compiler has complete knowledge of the types it is required to support and can therefore perform extensive optimizations without any risk of the code not working.
As a quick example suppose we are adding 2 unsigned 32 bit ints. The c compiler can inline this into a couple of machine instructions, totally avoiding the need to generate a jump instruction and also eliminating the need to protect the register state on the stack.
Python can't do that kind of optimization. Since a function in Python is free to return literally any type imaginable or nothing at all
The return type of my two functions are unknowable when the byte codes are compiled. So Python and any similarly dynamic language needs to call both functions before it can evaluate which of multiple possible +operators is most appropriate for the types involved. When it finally resolves the address of the + operators, it makes a function call incurring the typical stack overhead.
In a dynamically typed language like Python the compiled bytecodes are run inside the python interpretter. The “compiling” is more a translation from text to binary this reduces the amout of i/o and eliminates the repeated parsing of Python sources so the code can load faster.
Now suppose I take my wonderful C++ function that adds 2 ints together and package as a library and distribute it. Then someone tries to use the library but they need to add 64 bit doubles. How does my code handle that? It doesn't it, doesn't have to. The errant user will immediately get a compiler error because the c++ compiler is very pedantic about types matching.
But lets say the errant user is very determined and they decided to edit the prototype in the header file I provided thinking they've found the loophole what happens next is they are able to compile but they get a linker error so they are still thwarted.
Why did I mention all that stuff about compilers, linkers and libraries? To point out that c++ (and static languages in general) forgo some convenience for the end user. Instead of making it work the way the user needed we throw up roadblocks to prevent incorrect usage.
But by limiting the scope of what the code is required to handle amazing performance gains are possible. Essentially with C++ you get the advantages of high level languages but with the speed of “bare metal” machine coding without the portability issues.
Depending on the application and the programmers attitude this tradeoff of convenience vs performance may or may not make sense. Also there really is such a thing as throwaway code, and in that case getting something done quickly in Python is a clear win over trying to do the same thing in C++.
It really boils down to knowing your tools, and selecting the right tool for the right job.
There are also ways to improve Python performance but these typically involve goving up some flexibility. For more in this google Cython.

Tower of Hanoi in C

Tower Of Hanoi is a classic problem of Recursion. So this problem really gives you the insights of Recursion and how well it works in these problems.
Recursion is applied to problems that have the Optimal substructure property.
And the Tower of Hanoi problem also follows this property.

For Example,
Moving n disks from A to C using B can be easily solved by Moving n-1 disks from A to B using C + Moving 1 disk from A to C + Moving n-1 disks from B to C using A.

Here you can see we are able to reduce the problem from n to n-1,then n-1 will be reduce to n-2 and so on till we reach a case that is trivial for us to answer i.e. n=0.
This trivial case is often called base case in recursion.
There are many applications of Recursion such as in Linked Lists,Trees,Graphs etc.

How to move n discs from Tower1 to Tower2 ?
1. Move n-1 discs from Tower1 to Tower 3
2. Move nth disc from Tower1 to Tower2
3. Move n-1 discs from Tower3 to Tower1

This is the recursion concept behind tower of hanoi.
In C, we may write (just printing the steps)

#include <stdio.h>
void towerofhanoi(int n,char src[],char dst[],char ext[]){
      towerofhanoi(n-1,src,ext,dst); \\moving n-1 discs from source to spare  
      towerofhanoi(n-1,ext,dst,src); \\moving n-1 discs back from spare to destination
void move(int n,char src[],char dst[]){
    static int count = 0;
    printf("%d: move %d from %s to %s\n",count,n,src,dst);
int main(){
  int discs;
  printf("\t\tTower of Hanoi\n\n");
  printf("Enter the number of Discs: ");
  return 0;

Applications of C and C++ Programming Languages

The big companies like Microsoft, Google & Facebook uses C++.

1) Facebook also uses C++ extensively in its backends. Read this HipHop for PHP.

2) Bjarne Stroustrup also maintains C++ applications on his site: C++ Applications

3) Quora also uses C++. Quora's autocomplete feature is developed in C++.  Performance critical backend server side code of quora is written in C++ as said by Adam D'Angelo (The founder of quora) in his answer here: Why did Quora choose Python for its development? What technological challenges did the founders face before they decided to go with Python rather than PHP?

4) VLC media player is also developed in C & C++. (See here: VLC media player)

5) KGB archiver is also written in C++. (See here: KGB Archiver)

6) Unix is developed in C. Read also What programming languages are operating systems written in? 

7) C & C++ also used in embedded systems.

8) C is also used in database engines development.

9) C++ is still used extensively in engineering applications, such as high-end CAD/CAM systems.

10) Device driver development

11) C++ is also widely used in game development. 

12) List of all famous software written in C++ :

Operating Systems

Most of the operating systems are written in C and C++ language. These include Windows 95, 98, 2000, XP, Vista, Windows 7, Windows 8, Apple Mac OS X, Symbian OS and Be-OS, Google Chrome OS, RIM BlackBerry OS 4.x, Apple iPhone iPod Touch and iPad OS etc.

Web Browsers

  1. Microsoft Internet Explorer
  2. Google Chrome (based on chromium web browser)
  3. Mozilla Firefox
  4. Safari
  5. Netscape Navigator
  6. Opera and Opera Mini

Office Products

  1. Microsoft Office (Word, Excel, Access, PowerPoint, Outlook, FrontPage)
  2. Apache OpenOffice
  3. Corel Office/WordPerfect Office

E-Mail Clients

  1. Microsoft Outlook
  2. IBM Lotus Notes
  3. Mozilla Thunderbird

Web Sites

  1. Facebook - Several high-performance and high-reliability components are developed in C++.
  2. YouTube
  3. Amazon
  4. Paypal

Multimedia Players

  1. Winamp
  2. Microsoft Windows Media Player
  3. Apple iPod software
  4. VLC media player

Database systems

All the major RDBMS are developed in c++.
  1. Oracle database
  2. MySQL
  3. IBM DB2
  4. Microsoft SQL Server
  5. IBM Informix
  6. SAP DB/MaxDB
  7. MongoDB: An open-source database, widely used as the back end store for web applications, as well as in large enterprises like Viacom and Disney.

Graphical Layers

Graphical layers are nothing but the Graphical User Interface provided by various operating systems in order to make the human-computer interaction user friendly.
  1. Microsoft Windows UI
  2. Apple MacOS UI (Aqua)
  3. KDE

Compilers and Virtual Machines for programming languages

It is amazing to notice that various compilers and run-time environments for other programming languages are written in C++. This means without C++, it would not be possible to execute .Net and Java applications.
  1. Microsoft Visual C++ Compiler
  2. Microsoft Visual Basic Compiler
  3. Microsoft Visual C# Compiler
  4. Microsoft .Net CLR
  5. Java Virtual Machine (JVM)


Majority of computer games and game engines are developed in C++. It is difficult to provide list of all games here but some of them are Doom III engine, Counter Strike, Sierra On-line: Birthright, Hellfire, Football Pro, Bullrider I & II, Trophy Bear, Kings Quest, Antara, Hoyle Card games suite, SWAT, Blizzard: StarCraft, StarCraft: Brood War, Diablo I, Diablo II: Lord of Destruction, Warcraft III, World of Warcraft, Starfleet Command, Invictus, PBS's Heritage: Civilization and the Jews, Master of Orion III, CS-XII, MapleStory etc.

Electronic Art's video game engine is coded in c++. All Microsoft's games are written in c++.

Amazing Facts about Programming

Amazing Facts about programming  The first programmer was a lady named Ada Lovelac . She was a writer and gifted mathematician...

Popular Tutorials