[algogeeks] Explain the output
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, 34);} -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Microsoft Interview Question
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 counter. After complete traversal all negative values will be in the temporary array. 3. Traverse again the given array. Repeat step 2 but this time for positive numbers. Finally temporary array contains the required answer. If required copy it into original array. As this approach takes max. 3 traversals so its complexity is O(n). -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] [amazon]: dutch national flag algorithm
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 to the current array element we are accessing. -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Differentiate the following declarations.
*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 points to, however you can change values for a i.e different addresses can be applied to a. and *char *const a* means a is a constant pointer to character i.e you can change the values pointed by a, however you can not change the values i a i.e once a is assigned an address, a can not be changed. -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] wrong output of C program
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) { *int* t; t *=* a**2 *+* a; *return* t; } *int* main() { *int* a *=* 1, b *=* 2,c *=* 3; PrintInt(FiveTimes(a)); PrintInt(FiveTimes(b)); PrintInt(FiveTimes(c)); *return* 0; } -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Tree/Graph implementation
@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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: difference b/w static global variables and global variables
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 at the same time. -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Longest Path in A Graph
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 assumptions that graph is undirected and by this algorithm i can tell the length of longest path, but to find actual path I am still thinking. Correct me if i am wrong. -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Binary Index Tree
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 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Modular arithmetic
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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.