I disclaim thee, o’ liability
Generating Power Set
Iterating over all possible subsets of a set is a problem that can arise not only in competitive programming but also in day-to-day programming. While the total number of possible subsets is quite huge (2^n where n is the cardinality of the input set), often we want an algorithm that systematically considers all subsets for small values of n.
A power set is a set of all subsets of a given input set. Often we may want to simply iterate over all members of the power set, but sometimes (if we have enough memory) we may need the power set itself. In the following post, I have attempted to present some algorithms (with C++11 implementations) that solve both kinds of problems (simple iteration and complete power set construction).
…Implementing Service Oriented Architecture using Http is a horrible idea
Service Oriented Architecture is a commonly used design pattern in distributed and enterprise applications. It involves the creation and use of independent services that work together to produce the desired result. The most important benefits, of course, are separation of concerns and the ability to scale each service independent of others, leading to a clean, modular design.
A common problem faced during the design of a SOA system is the choice of communication protocol. Ideally we want our services to communicate with each other with minimum communication overhead. This involves:
…The toughest interview question
What is the output of the following C code snippet?
1int n = 1;
2printf("%d %d %d\n", n++, ++n, n++ + ++n);
This is a tricky question. Any attempt to answer this question requires either a deep understanding of your compiler’s parser or a complete ignorance of C. Even if you fall under the first category and know the ins and outs of your favorite compiler, how do you know which is your interviewer’s favorite compiler?
…