Re: [algogeeks] C output... ???
#define SIZE 10 int main() { int arr[SIZE]; printf(size of array is:%d\n,sizeof(arr)); return 0; } when we call the function and pass the name of the ARRAY ,then PUSH the base Address of the ARRAY in the Stack of the Calling Function not PUSH the entire ARRAY ,SO Desire Out_Put is Only Size of Pointer Not Size of Entire ARRAY . OUTPUT IS 4. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] tricky C aps ques
main() { int a[5]={1,3,6,7,0}; int *b; b=a[2]; coutb[-1]; } the value of b[-1] is a.1 b.3 c.-6 d.none ANS will be 3. Because Compiler internally first converted in the form as *(b-1) , and get the one position back at the position 3. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] SUN Microsystem Question
Why Interpreting the program more costly them compilationexplain briefly.. Regards Shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] tricky C aps ques
A[i]=A+i; so 3. On Thu, Dec 16, 2010 at 5:25 PM, UMESH KUMAR kumar.umesh...@gmail.com wrote: main() { int a[5]={1,3,6,7,0}; int *b; b=a[2]; coutb[-1]; } the value of b[-1] is a.1 b.3 c.-6 d.none ANS will be 3. Because Compiler internally first converted in the form as *(b-1) , and get the one position back at the position 3. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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 post to this group, send email to algoge...@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] dear,Good day! hoykbbd!
dear friend how are you doing recently ? i found a very good site : www.yang-fangfang2.com I bought an Apple laptop a week ago from this site. Now, I have been received. This product quality is very good. and price also very cheap. They also sell mobile phones, television sets, motorcycles and so on. it is the best place for us to buy , or send gift to friends . If you feel interested , just do it .don't miss this chance. good luck awxdbr 16/12/2010 5:22:14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] Answer This
In an ancient village, there were some green-eyed and blue-eyed persons. One fine day, God instructed them, the day on which you come to know that you are a green-eyed, you should commit suicide ... He also assured them that there was at least one green-eyed among them. Well, all the villagers were very intelligent and strict followers of God. But, no one knew color of his own eyes! They didn't have mirrors. They couldn't even communicate with each other. All that they could do is to see color of other's eyes. It happened that on 20th day, all the green-eyed people committed suicide. So, how many green-eyed were there ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] help
problem:https://www.spoj.pl/problems/PARTY/ i m getting wrong answer for dis problem.can anyone help me in finding de mistake..thank u in advance #includeiostream //#includeconio.h #includevector #includealgorithm using namespace std; //int n; int item(int c[][501],int i,int wt,vectorint w,int ans) { //int ans; if(i==0 || wt==0) return 0; else { if(c[i][wt]==c[i-1][wt]) item(c,i-1,wt,w,ans); else if(c[i][wt]==c[i][wt-1]) item(c,i,wt-1,w,ans); else { ans=ans+w[i]; item(c,i-1,wt-w[i],w,ans); // coutw[i]endl; // ans+=w[i]; } } // return ans; } main() { int n,tw; while(cintwn n!=0 tw!=0){ int i,j,ans=0; //cinn; vectorint wt(n+1),v(n+1); v[0]=wt[0]=0; int c[501][501]; // cintw; for(i=1;i=n;i++) cinwt[i]v[i]; for(i=0;i=tw;i++) c[0][i]=0; for(i=1;i=n;i++) { c[i][0]=0; for(j=1;j=tw;j++) { if(wt[i]=j) { int ma=max(c[i-1][j],c[i][j-1]); if((v[i]+c[i-1][j-wt[i]])ma) c[i][j]=v[i]+c[i-1][j-wt[i]]; else c[i][j]=ma; } else c[i][j]=max(c[i-1][j],c[i][j-1]); } } // coutendl; item(c,n,tw,wt,ans); coutans c[n][tw]\n ; // coutmaximum possible value isc[n][tw]; } //getch(); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] help
machi use this.. Define *m*[*i*,*w*] to be the maximum value that can be attained with weight less than or equal to *w* using items up to *i*. We can define *m*[*i*,*w*] recursively as follows: - [image: m[0,\,w]=0] - [image: m[i,\,0]=0] - [image: m[i,\,w]=m[i-1,\,w]] if [image: w_iw\,\!] (the new item is more than the current weight limit) - [image: m[i,\,w]=\max(m[i-1,\,w],\,m[i-1,w-w_i]+v_i)] if [image: w_i \leqslant w]. return m[n,W] where W is the input On Fri, Dec 17, 2010 at 11:38 AM, kumar0746 kerth kumar0...@gmail.comwrote: problem:https://www.spoj.pl/problems/PARTY/ i m getting wrong answer for dis problem.can anyone help me in finding de mistake..thank u in advance #includeiostream //#includeconio.h #includevector #includealgorithm using namespace std; //int n; int item(int c[][501],int i,int wt,vectorint w,int ans) { //int ans; if(i==0 || wt==0) return 0; else { if(c[i][wt]==c[i-1][wt]) item(c,i-1,wt,w,ans); else if(c[i][wt]==c[i][wt-1]) item(c,i,wt-1,w,ans); else { ans=ans+w[i]; item(c,i-1,wt-w[i],w,ans); // coutw[i]endl; // ans+=w[i]; } } // return ans; } main() { int n,tw; while(cintwn n!=0 tw!=0){ int i,j,ans=0; //cinn; vectorint wt(n+1),v(n+1); v[0]=wt[0]=0; int c[501][501]; // cintw; for(i=1;i=n;i++) cinwt[i]v[i]; for(i=0;i=tw;i++) c[0][i]=0; for(i=1;i=n;i++) { c[i][0]=0; for(j=1;j=tw;j++) { if(wt[i]=j) { int ma=max(c[i-1][j],c[i][j-1]); if((v[i]+c[i-1][j-wt[i]])ma) c[i][j]=v[i]+c[i-1][j-wt[i]]; else c[i][j]=ma; } else c[i][j]=max(c[i-1][j],c[i][j-1]); } } // coutendl; item(c,n,tw,wt,ans); coutans c[n][tw]\n ; // coutmaximum possible value isc[n][tw]; } //getch(); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 post to this group, send email to algoge...@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] Answer This
20 green eys ppl .. At the end of first day person realize no body dies so he is the one with green eye's so he commit sucide ... Similarly on second day .. hence forth 20 people commit suicide in 20 days .. On Fri, Dec 17, 2010 at 11:05 AM, punnu punnu.gino...@gmail.com wrote: In an ancient village, there were some green-eyed and blue-eyed persons. One fine day, God instructed them, the day on which you come to know that you are a green-eyed, you should commit suicide ... He also assured them that there was at least one green-eyed among them. Well, all the villagers were very intelligent and strict followers of God. But, no one knew color of his own eyes! They didn't have mirrors. They couldn't even communicate with each other. All that they could do is to see color of other's eyes. It happened that on 20th day, all the green-eyed people committed suicide. So, how many green-eyed were there ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 post to this group, send email to algoge...@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] Answer This
Aditya, 1) Nobody dies on the first 19 days everyone dies on the 20th day. 2) Even if it wasnt the case, why should he die just because nobody else did? Is there any condition on THERE SHOULD BE ATLEAST ONE GREEN EYED GUY? On Fri, Dec 17, 2010 at 12:52 PM, Aditya Agrawal adit6...@gmail.com wrote: 20 green eys ppl .. At the end of first day person realize no body dies so he is the one with green eye's so he commit sucide ... Similarly on second day .. hence forth 20 people commit suicide in 20 days .. On Fri, Dec 17, 2010 at 11:05 AM, punnu punnu.gino...@gmail.com wrote: In an ancient village, there were some green-eyed and blue-eyed persons. One fine day, God instructed them, the day on which you come to know that you are a green-eyed, you should commit suicide ... He also assured them that there was at least one green-eyed among them. Well, all the villagers were very intelligent and strict followers of God. But, no one knew color of his own eyes! They didn't have mirrors. They couldn't even communicate with each other. All that they could do is to see color of other's eyes. It happened that on 20th day, all the green-eyed people committed suicide. So, how many green-eyed were there ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- I dare do all that may become a man; Who dares do more, is none - Macbeth, twelfh night! Regards Krishna -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] array
a[]={-3,2,4,-6,-8,10,11} create an array with cumulative sum: b[]={-3,-1,3,-3,-11,-1,10}. Now identify the maximum index distance same value. in this case distance b/w -3,-3 is maximum so subarray would be 2,4,-6,-8,10 On Wed, Dec 15, 2010 at 6:23 PM, Soumya Prasad Ukil ukil.sou...@gmail.comwrote: It's a subset-sum problem, I guess. On 15 December 2010 04:12, parth panchal parthpancha...@gmail.com wrote: HI HOW ARE YOU On Tue, Dec 14, 2010 at 7:45 PM, divya sweetdivya@gmail.com wrote: an array contain +ve and -ve element, find subarray whose sum =0; Lets take input array as a[]={-3,2,4,-6,-8,10,11} -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- regards, soumya prasad ukil -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 post to this group, send email to algoge...@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] Answer This
I think Aditya is correct, 1) it never says nobody dies on the first 19 days, just says by the 20th day all the green eyed commit suicide. 2) God said that, He also assured them that there was at least one green-eyed among them. Cheers. On Fri, Dec 17, 2010 at 1:30 PM, Krishna Narasimhan krishna.n...@gmail.comwrote: Aditya, 1) Nobody dies on the first 19 days everyone dies on the 20th day. 2) Even if it wasnt the case, why should he die just because nobody else did? Is there any condition on THERE SHOULD BE ATLEAST ONE GREEN EYED GUY? On Fri, Dec 17, 2010 at 12:52 PM, Aditya Agrawal adit6...@gmail.comwrote: 20 green eys ppl .. At the end of first day person realize no body dies so he is the one with green eye's so he commit sucide ... Similarly on second day .. hence forth 20 people commit suicide in 20 days .. On Fri, Dec 17, 2010 at 11:05 AM, punnu punnu.gino...@gmail.com wrote: In an ancient village, there were some green-eyed and blue-eyed persons. One fine day, God instructed them, the day on which you come to know that you are a green-eyed, you should commit suicide ... He also assured them that there was at least one green-eyed among them. Well, all the villagers were very intelligent and strict followers of God. But, no one knew color of his own eyes! They didn't have mirrors. They couldn't even communicate with each other. All that they could do is to see color of other's eyes. It happened that on 20th day, all the green-eyed people committed suicide. So, how many green-eyed were there ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- I dare do all that may become a man; Who dares do more, is none - Macbeth, twelfh night! Regards Krishna -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 post to this group, send email to algoge...@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: Max Heap + Binary Search Tree
To insert a node into a tree with such a property: First insert the node into the tree using the rules of Binary Search tree based on Value i . Now compare Node-j and Node-Parent-j. Depending upon the result of comparison perform left rotation or right rotation so that the Heap property is also maintained. Repeat this process until you fully restore the Heap property. On Wed, Dec 15, 2010 at 2:54 PM, Prims topcode...@gmail.com wrote: Lets assume that the tree node has two keys K1 and K2. K1 satisfies the BST property K2 satisfies the Max Heap Property. Our problem is to build a binary tree which satisfies both the properties. For a maximal heap the root node must be the maximum. So we find the node which has the K2 max. And make it as the root node. Among the remaining nodes, The nodes to the left of the tree will be those whose K1 value is less than that of the Root nodes K1. And rest will be on the right side of the root. Now again repeat the procedure for finding the next left node of root and right node of root using the same logic above On Dec 15, 2:07 pm, snehal jain learner@gmail.com wrote: A rooted binary tree with keys in its nodes has the binary search tree property (BST property) if, for every node, the keys in its left subtree are smaller than its own key, and the keys in its right subtree are larger than its own key. It has the heap property if, for every node, the keys of its children are all smaller than its own key. You are given a set of n binary tree nodes that each contain an integer i and an integer j. No two i values are equal and no two j values are equal. We must assemble the nodes into a single binary tree where the i values obey the BST property and the j values obey the heap property. If you pay attention only to the second key in each node, the tree looks like a heap, and if you pay attention only to the first key in each node, it looks like a binary search tree.Describe a recursive algorithm for assembling such a tree -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 post to this group, send email to algoge...@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] Re: coins
for i=1 to n for j=1 to n coins[i][j]=coins[i][j]+ max(coins[i-1][j],coins[i][j-1]); This is a bottom up DP. Time complexity O(n^2) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] Generic Linked list
How to implement a generic linked list?? ..this is one of the frequently asked interview question ..for this we have to use void pointers struct node { void *data; struct node *link; }; ..can anybody plz give more detailed explanation and complete implementation on this?? And what is its use?? thanks in advance... -- Regards, $iva -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] What can be done in c but not c++?
We can assign any type of pointer to void pointer without cast in c but not in c++. Declare variable names that are keywords in C++ but not C. ...if anybody knows more do update in this thread.:). -- Regards, $iva -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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] Answer This
Ans : Total 20 green-eyed people were there in the village. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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.