Re: [algogeeks] problem with increment operator

2012-05-30 Thread Prateek Jain
yups...it is compiler dependent...but a logic is necessary to get it... -- 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

Re: [algogeeks] amazon

2012-05-30 Thread Amol Sharma
here is a nice explanation for the problem http://stackoverflow.com/questions/5131497/given-a-string-and-permutation-of-the-string-find-the-index-of-this-permuted-st -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad http://gplus.to/amolsharma99

[algogeeks] 567 of UVA - WA

2012-05-30 Thread Blackwizard
hi... I've used BFS algorithm to solve 567 of UVA... but it takes WA... here's my solution in c++: #include iostream #include queue #include cstring #include stdio.h using namespace std; int mat[21][21]; int mark[21]; int tc = 0; int n, m, t; int a, b; void bfs () { queue int q; q.push

[algogeeks] Re: problem with increment operator

2012-05-30 Thread holmes
It's output will be compiler dependent. So on Turbo C, compiler will perform all pre-increment operation first then will start adding. like in your problem all ++a operation will go first. then addition will happen. so 6+6+6=18. on gcc, first two variables will it take, performs pre-increment

RE: [algogeeks] Re: problem with increment operator

2012-05-30 Thread Ashot Madatyan
The order of evaluation of sub-expressions is not defined since there is no sequence point in the sub-expression. So, the behavior is not defined, and one cannot rely on a specific compiler implementation - gcc, MSVC, or any other. As a general rule of thumb, you should avoid this type of complex

Re: [algogeeks] amazon

2012-05-30 Thread Piyush Khandelwal
nice explanation.. On 30 May 2012 06:05, Amol Sharma amolsharm...@gmail.com wrote: here is a nice explanation for the problem http://stackoverflow.com/questions/5131497/given-a-string-and-permutation-of-the-string-find-the-index-of-this-permuted-st -- Amol Sharma Third Year Student

Re: [algogeeks] problem with increment operator

2012-05-30 Thread vIGNESH v
Hai i tried the same in TC compiler. i got the output as 17. I guess the output should be 17 as explained by Prateek Jain On 30 May 2012 02:26, rahul ranjan rahul.ranjan...@gmail.com wrote: it first calculates from right to left and then performs addition so after a++ its still 4(with

[algogeeks] The following problem is a variation of Tower of hanoi problem...Plz suggest on how to approach the following problem...

2012-05-30 Thread g4ur4v
There are K pegs. Each peg can hold discs in decreasing order of radius when looked from bottom to top of the peg. There are N discs which have radius 1 to N; Given the initial configuration of the pegs and the final configuration of the pegs, output the moves required to transform from the

Re: [algogeeks] Re: # of paths betweek two nodes in a DAG

2012-05-30 Thread Lucifer
@Amol I think the solution given above is fine except that i missed to initialize A[src] =1. Thats the reason why u end up getting 0's for all A[i]'s. Modification to the third step: 3) Scan the linearized list from left to right initialize all the corresponding values in array A to 0. Set

Re: [algogeeks] problem with increment operator

2012-05-30 Thread Prateek Jain
okk -- 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

Re: [algogeeks] The following problem is a variation of Tower of hanoi problem...Plz suggest on how to approach the following problem...

2012-05-30 Thread Prateek Jain
built a tree (not binary) where the root node is the initial configuration of pegs. For each possibility of movement of the initial configuration of disks, a child node is created. Thus, for each child node created, I check if the current configuration is the final configuration. If yes, problem

[algogeeks] Re: The following problem is a variation of Tower of hanoi problem...Plz suggest on how to approach the following problem...

2012-05-30 Thread Gene
Since the number of moves must be optimal, this seems to be a search problem. A-Star is the right search algorithm. This is an algorithm that's somewhere between depth first and breadth first. It expands the tree according to a heuristic that you choose, which can shrink the run time enormously.

Re: [algogeeks] problem with increment operator

2012-05-30 Thread Navin Kumar
Hey answer will be 18 as follows. First ++a(5)+ ++a(6) + a++(6)=17 + one post increment= 18. On Thu, May 31, 2012 at 3:13 AM, Prateek Jain prateek10011...@gmail.comwrote: okk -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

[algogeeks] Linked list using void pointer

2012-05-30 Thread mahendra sengar
how to implement generioc linked list..using void pointer...i havent used void pointer much so, m not able to use it properly in linked list..please help asap !!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] Amazon : exponentiation(x,n)

2012-05-30 Thread Ashish Goel
This algo is log(n) algo for finding power. However, this also has a problem of overflow. How do we control this. int power(int x, int n) { int expo =1; int even=x; while (n0) { while (n 0x1==0) { n=1; /*divide by 2*/ even*=even; } expo = expo*even;