recursion internally uses one stack for maintaining the return addresses.....which all we need... :-) On Friday, June 22, 2012 11:38:39 AM UTC+5:30, joker wrote: > > @ALL this shud work :-) > > #include<iostream> > #include<queue> > using namespace std; > queue<int> Q; > void rev() > { if(!Q.empty()) > { int x=Q.front(); Q.pop(); > rev(); > Q.push(x); > } > > } > main() > { for(int i=1;i<12;i++) Q.push(i); > rev(); > while(!Q.empty()) > { int x=Q.front(); Q.pop(); > printf("%d ",x); > } > system("pause"); > } > > > On Thu, Jun 21, 2012 at 12:14 PM, sanjay pandey > <sanjaypandey...@gmail.com> wrote: > > it seems @hassan sol is correct....can nybody knw d flaw in 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 > > algogeeks+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/algogeeks?hl=en. >
On Friday, June 22, 2012 11:38:39 AM UTC+5:30, joker wrote: > > @ALL this shud work :-) > > #include<iostream> > #include<queue> > using namespace std; > queue<int> Q; > void rev() > { if(!Q.empty()) > { int x=Q.front(); Q.pop(); > rev(); > Q.push(x); > } > > } > main() > { for(int i=1;i<12;i++) Q.push(i); > rev(); > while(!Q.empty()) > { int x=Q.front(); Q.pop(); > printf("%d ",x); > } > system("pause"); > } > > > On Thu, Jun 21, 2012 at 12:14 PM, sanjay pandey > <sanjaypandey...@gmail.com> wrote: > > it seems @hassan sol is correct....can nybody knw d flaw in 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 > > algogeeks+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/algogeeks?hl=en. > On Friday, June 22, 2012 11:38:39 AM UTC+5:30, joker wrote: > > @ALL this shud work :-) > > #include<iostream> > #include<queue> > using namespace std; > queue<int> Q; > void rev() > { if(!Q.empty()) > { int x=Q.front(); Q.pop(); > rev(); > Q.push(x); > } > > } > main() > { for(int i=1;i<12;i++) Q.push(i); > rev(); > while(!Q.empty()) > { int x=Q.front(); Q.pop(); > printf("%d ",x); > } > system("pause"); > } > > > On Thu, Jun 21, 2012 at 12:14 PM, sanjay pandey > <sanjaypandey...@gmail.com> wrote: > > it seems @hassan sol is correct....can nybody knw d flaw in 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 > > algogeeks+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/algogeeks?hl=en. > On Friday, June 22, 2012 11:38:39 AM UTC+5:30, joker wrote: > > @ALL this shud work :-) > > #include<iostream> > #include<queue> > using namespace std; > queue<int> Q; > void rev() > { if(!Q.empty()) > { int x=Q.front(); Q.pop(); > rev(); > Q.push(x); > } > > } > main() > { for(int i=1;i<12;i++) Q.push(i); > rev(); > while(!Q.empty()) > { int x=Q.front(); Q.pop(); > printf("%d ",x); > } > system("pause"); > } > > > On Thu, Jun 21, 2012 at 12:14 PM, sanjay pandey > <sanjaypandey...@gmail.com> wrote: > > it seems @hassan sol is correct....can nybody knw d flaw in 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 > > algogeeks+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/rKd4pNXXxLoJ. 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.