[algogeeks] Explain the output

2012-06-28 Thread Mad Coder
Please explain the output of following C code #includestdio.hchar *str = char *str = %c%s%c; main(){ printf(str, 34, str, 34);}; int main() { printf(str, 34, str, 34); return 0; } Output-- char *str = char *str = %c%s%c; main(){ printf(str, 34, str, 34);}; main(){ printf(str, 34, str,

Re: [algogeeks] Microsoft Interview Question

2012-06-14 Thread Mad Coder
As nothing is written about space complexity, I am assuming that we can take extra space. Take a temporary array of length n. 1. Maintain a counter for the length of temporary array filled till now. 2. Traverse the given array. If value contained is negative insert it in new array and update

Re: [algogeeks] [amazon]: dutch national flag algorithm

2012-06-12 Thread Mad Coder
Let array contains 3 types of elements R,G,B. Now, if we place all the R elements from the left and B elements from the right then G elements will automatically be between the two. Thus we only have to keep indexes for the R and B elements inserted till now and update their positions accordingly

Re: [algogeeks] Re: Differentiate the following declarations.

2012-06-12 Thread Mad Coder
*const char* a* is *equivalent* to *char const * a* A simple method which most people use in coding is that const is written after the value which needs to be constant. So, *char const *a* means a is a pointer that points to a character which is a constant i.e you can not change the value which a

[algogeeks] wrong output of C program

2012-06-07 Thread Mad Coder
The following is a simple C program which tries to multiply an integer by 5 using the bitwise operations. But it doesn't do so. Explain the reason for the wrong behavior of the program. #include stdio.h #define PrintInt(expr) printf(%s : %d\n,#expr,(expr)) *int* FiveTimes(*int* a) {

Re: [algogeeks] Tree/Graph implementation

2012-05-31 Thread Mad Coder
@Gene: Can you tell some other ways of graph representation in case of sparse matrix as till now I consider adjacency list as the best method for the same. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: difference b/w static global variables and global variables

2012-02-29 Thread Mad Coder
then how static can be an extern? Extern means that this variable can be used in other files also, whereas static means this variable is initialized only once and its scope is static with respect to its scope which can be either a function or file. So we cant declare a variable static and extern

Re: [algogeeks] Re: Longest Path in A Graph

2012-02-29 Thread Mad Coder
We can find the longest path in a graph by applying 2 bfs. 1st BFS is from our start node. The node which appear in last will be the one farthest from the start node.Let this node be end1. Now again apply bfs from end1 and the last node which appears will be the another end. Here I have made

[algogeeks] Binary Index Tree

2012-01-14 Thread Mad Coder
Hi all, I was going through Binary Index Tree (BIT) tutorial through topcoder , although the concept is clear to me, I want to do some more practice questions. So it will be helpful if you provide me link of some questions of BIT in spoj. -- You received this message because you are subscribed

Re: [algogeeks] Re: Modular arithmetic

2011-10-22 Thread Mad Coder
Can anyone explain why ((n%p)*(m%p))%p will give wrong answer ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to