Re: [algogeeks] Nagarro Coding Round Ques......

2011-07-26 Thread Anika Jain
int palin(char *p) { int x=0; while(*p) { x^=1(*p-'a'); p++; } int i=0,count=0; while(i26) { count+=(1i x)i; i++; } if(count1) return 0; else return 1; } -- You received this message because you are

[algogeeks] Facebook Interview question at NIT Warangal

2011-07-26 Thread sumit
Given an array of size n, print all the possible subset of array of size k. eg:- input: a[]={1,2,3,4}, k = 2 output: 1,2 1,3 1,4 2,3 2,4 3,4 -- 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] Poison River

2011-07-26 Thread sachin sharma
@Someshwar Chandrasekaran yea I think you are right. because to cross river, in the last we must have one person new and other person who came back from other end. this happens only in case of three. Solution is possible up two three persons. when you have four person in the last move you are

[algogeeks] Graph Based Problems

2011-07-26 Thread Navneet Gupta
Hello folks, I have seen some of the best possible string/array/tree based problems being discussed on this thread but somehow i feel this group has been little partial towards Graph problems. Though, in most cases, interviewers don't ask Graph algorithms, but we, as algo lovers, should give due

Re: [algogeeks] C output

2011-07-26 Thread Anika Jain
a is a pointer to somewhere where string is written.. p is a pointer to somewhere where new sring is written. temp is made to point at same location to which a is currently pointing that is at string by malloc some new memory is alloted and a is made to point to thast memory.. temp remains to

[algogeeks] Re: Poison River

2011-07-26 Thread subashree sridhar
i think this problem can be solved easily for any no of ppl if they are crossin the river using one shoe at a time :D :P On Jul 26, 10:38 am, sunny agrawal sunny816.i...@gmail.com wrote: For N=3, if the people are named A,B, and C: A wears the shoes and carries B across the river. is there

Re: [algogeeks] Facebook Interview question at NIT Warangal

2011-07-26 Thread Ankur Garg
Hi Dont u think the subsets will also be {2,1} {3,1} {3,2} {4,1} {4,2} {4,3} On Tue, Jul 26, 2011 at 11:59 AM, sumit sumitispar...@gmail.com wrote: Given an array of size n, print all the possible subset of array of size k. eg:- input: a[]={1,2,3,4}, k = 2 output: 1,2 1,3 1,4 2,3

Re: [algogeeks] MS Written Test

2011-07-26 Thread $hr! k@nth
Nybody got shortlisted in MS written test which happened on 23rd july??? On Sun, Jul 24, 2011 at 7:32 PM, Bhanu Pratap Singh bp.mn...@gmail.comwrote: We can also use, c++ map... for implementing this! -- *with regards ... Bhanu P Singh (B!||-I~) B.Tech Final Year Computer Science And

Re: [algogeeks] Facebook Interview question at NIT Warangal

2011-07-26 Thread Vishal Thanki
@ankur, i think 1,2 and 2,1 would be same as set theory.. CMMIW. following is the code.. #include stdio.h #include stdlib.h void print_comb(int *a, int len) { int tlen = len; int i, j, k; for (i=0;i5;i++) { for (j=i+1; j4;j++) {

Re: [algogeeks] Facebook Interview question at NIT Warangal

2011-07-26 Thread Vishal Thanki
anyway, the code i posted is buggy.. doesn't work for k=3.. don't use it :) On Tue, Jul 26, 2011 at 1:02 PM, Vishal Thanki vishaltha...@gmail.com wrote: @ankur, i think 1,2 and 2,1 would be same as set theory.. CMMIW. following is the code.. #include stdio.h #include stdlib.h void

Re: [algogeeks] Facebook Interview question at NIT Warangal

2011-07-26 Thread Shreyas VA
#include bitset #include iostream #include math.h #include vector int main() { using namespace std; int arr[] = {1,2,3,4}; int k = 2; int n = sizeof(arr)/sizeof(int); vectorint v(arr, arr+n); int l = pow(2.0, n); for (int i = 0; i l; ++i) { bitset32 b(i); if (b.count() != k) continue; for (int j

Re: [algogeeks] Unsubscribe my group

2011-07-26 Thread AASHISH SUMAN
WHY SO.. PLZ DONT DO THIS. *WITH BEST REGARDS : AASHISH SUMAN MCA FINAL YEAR * *NIT DURGAPUR* *+91-9547969906* -- 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

[algogeeks] Closest as Possible

2011-07-26 Thread rShetty
Problem statement goes as : Consider square root of integers form 1 to 100. Now partition the square roots of integers as being from 1 to 50 and 51 to 100. Now find the sum in the two partitions which is as close as possible or minimum? Give the algorithm ?? and das structures to be used?? --

[algogeeks] Re: MS Written Test

2011-07-26 Thread Ankuj Gupta
Has the results come ? On Jul 26, 12:32 pm, $hr! k@nth srithb...@gmail.com wrote: Nybody got shortlisted in MS written test which happened on 23rd july??? On Sun, Jul 24, 2011 at 7:32 PM, Bhanu Pratap Singh bp.mn...@gmail.comwrote: We can also use, c++ map... for implementing this!

Re: [algogeeks] Unsubscribe my group

2011-07-26 Thread shady
why are you spamming ? On Tue, Jul 26, 2011 at 1:23 PM, wilson alexander aaalex0...@gmail.comwrote: Hi, Kindly unsubscribe my group algogeeks. *...Regards,* *A.Alex* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] problem tree minimum sum in binary

2011-07-26 Thread Charlotte Swazki
Hi, I want to implement an algorithm to determine the shortest path from the top to down. like: int py_path_shoretest(int size, int **map);  // return the shortest path value. size is the height. int main(void) {  int map =  {               {1},               {2, 3},    

Re: [algogeeks] problem tree minimum sum in binary

2011-07-26 Thread sunny agrawal
It dont look like a tree its more like a triangle and if the values are stored in the matrix can be simply done using a Dynamic Programming bottom up approach On Tue, Jul 26, 2011 at 2:27 PM, Charlotte Swazki charlotteswa...@yahoo.frwrote: Hi, I want to implement an algorithm to determine

Re: [algogeeks] problem tree minimum sum in binary

2011-07-26 Thread Ravinder Kumar
Do inorder traversal and maintain a bit vector equal to height of tree also keep an current shortest path bit vector in last print path using shortest path bit vector. keep updating shortest path bit vector when path shorter than current shortest path is found. On Tue, Jul 26, 2011 at 9:57 AM,

[algogeeks] C output.

2011-07-26 Thread Ankur Khurana
#includeiostream #includestring.h using namespace std; #define N(e) e#e int main() { int i=1,j=2,k=3; int m = i++ || j++ k++; couti j k m; } output :-2 2 3 1 http://www.ideone.com/0sKBr can anybody explain ? why are ++j and ++k are not evaluating even though operator should be evaluated

Re: [algogeeks] C output.

2011-07-26 Thread rajeev bharshetty
Replace || by and then j and k will get evaluated. The thing is that i think when the compiler sees a || operator ,if the first operand is true than it wont check for the second.Thus j and k are not getting evaluated. On Tue, Jul 26, 2011 at 2:46 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

Re: [algogeeks] Re: MS Written Test

2011-07-26 Thread $hr! k@nth
Donno..thats y am asking whether ny of u guyz shortlisted. On Tue, Jul 26, 2011 at 1:50 PM, Ankuj Gupta ankuj2...@gmail.com wrote: Has the results come ? On Jul 26, 12:32 pm, $hr! k@nth srithb...@gmail.com wrote: Nybody got shortlisted in MS written test which happened on 23rd july???

Re: [algogeeks] C output.

2011-07-26 Thread Nitish Garg
This will be evaluated as i++ || (j++ k++) as gets the priority, so i will get incremented to 2. As the left hand side of || is true, the result is true and so the right hand side won't get evaluated. -- You received this message because you are subscribed to the Google Groups Algorithm

[algogeeks] How to staore

2011-07-26 Thread sagar pareek
how can u save this value in a int type variable...without using abstract data type. 112223355569990 -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- You received this message because you are

Re: [algogeeks] Graph Based Problems

2011-07-26 Thread Dipankar Patro
Love your idea Navneet, but I have seen in general that Graph algos are difficult to convert into code (at least for me!) May be that's the reason why people are not discussing it here. But like you pointed out we could at least point the scenarios where graph algos can be applied. Looking

Re: [algogeeks] How to staore

2011-07-26 Thread SkRiPt KiDdIe
We can store their freq. as in run-length encoding, each dig freq. would require 1/2 byte storage .10 digits would require 5 bytes = 2 integer type variables or LL int .Digit seq. don't need to be stored coz they appear one after another beginning from 1. -- You received this message because you

Re: [algogeeks] Nagarro Coding Round Ques......

2011-07-26 Thread Rajeev Kumar
check this link and let me know if anything wrong: http://rajeevprasanna.blogspot.com/2011/07/is-given-characters-of-string-form.html On Tue, Jul 26, 2011 at 11:37 AM, Anika Jain anika.jai...@gmail.com wrote: int palin(char *p) { int x=0; while(*p) { x^=1(*p-'a');

Re: [algogeeks] How to staore

2011-07-26 Thread Jnana Sagar
awesome answer..yeah it works.. On 7/26/11, SkRiPt KiDdIe anuragmsi...@gmail.com wrote: We can store their freq. as in run-length encoding, each dig freq. would require 1/2 byte storage .10 digits would require 5 bytes = 2 integer type variables or LL int .Digit seq. don't need to be stored

Re: [algogeeks] problem tree minimum sum in binary

2011-07-26 Thread SkRiPt KiDdIe
for(i=sz-2;i=0;i--) for(j=0;j=i;j++) ar[i][j]+=min(ar[i+1][j],ar[i+1][j+1]); coutar[0][0]; is this fine.? -- 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

Re: [algogeeks] C output.

2011-07-26 Thread Jnana Sagar
exactly what nithish has stated is the reason..as all the programming languages uses short circuit method of evaluation for the relational statements..as the right side expression of the 'or' is true..it doesn't evaluate the left side expression, because now the left side expression doesn't affect

Re: [algogeeks] need the book google resume and algorithms for interviews

2011-07-26 Thread coder dumca
@ Raghvendra thanks dude On Mon, Jul 25, 2011 at 7:20 PM, raghavendhra rahul rahulraghavend...@gmail.com wrote: hi , i think this s the link for algorithm for interviews ebook http://code.google.com/p/interview/downloads/detail?name=Algorithms%2Bfor%2BInterviews%2B%28scan%2Bocr%29.pdf

Re: [algogeeks] Graph Based Problems

2011-07-26 Thread aditya kumar
all graph problem need not use tree . most of them can be implemented using array . On Tue, Jul 26, 2011 at 3:11 PM, Dipankar Patro dip10c...@gmail.com wrote: Love your idea Navneet, but I have seen in general that Graph algos are difficult to convert into code (at least for me!) May be that's

[algogeeks] Re: Facebook Interview question at NIT Warangal

2011-07-26 Thread Mukul Gupta
You can take a string with k no. of 1's at the end and generate all possible permutations of the string thus formed.Doing this way you can generate all possible strings and corresponding to each 1 in string write the number in array(corresponding to that position) and thus you can generate all

Re: [algogeeks] need the book google resume and algorithms for interviews

2011-07-26 Thread Bhanu Pratap Singh
what is the password for the above mentioned book its not opening! ;'( -- 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] Facebook Interview question at NIT Warangal

2011-07-26 Thread praneethn
int main() { buildsubsets(0,0,); } void buildsubsets(int i,int j,String subset) { if(j==k) { coutsubset+ ; return ; } for(;in;++i) buildsubsets(i+1,j+1,subset+arr[i]); } assume that given arr[] is a character array i.e.

Re: [algogeeks] need the book google resume and algorithms for interviews

2011-07-26 Thread Vivek Srivastava
Hi Bhanu, I downloaded the book but it does not ask any password.Why is it asking password on your machine? On Tue, Jul 26, 2011 at 4:31 PM, Bhanu Pratap Singh bp.mn...@gmail.comwrote: what is the password for the above mentioned book its not opening! ;'( -- You received this message

[algogeeks] Re: Nagarro Coding Round Ques......

2011-07-26 Thread sachet
please explainthe code #includestring using namespace std; int main() { int x=0; string str; cinstr;//only lowercase for(int i=0;istr.size();i++) x^=(1(str[i]-97)); if(str.size()1) { if(!(x(x-1)))coutPalindrome\n; else coutNot palindrome\n; } else {if(!x)coutPalindrome\n;

Re: [algogeeks] C output.

2011-07-26 Thread Ankur Khurana
but in precedence order || . Checked the same in dennis ricthie. On Tue, Jul 26, 2011 at 2:53 PM, rajeev bharshetty rajeevr...@gmail.comwrote: Replace || by and then j and k will get evaluated. The thing is that i think when the compiler sees a || operator ,if the first operand is true

Re: [algogeeks] C output.

2011-07-26 Thread Someshwar Chandrasekaran
On Tue, Jul 26, 2011 at 2:56 PM, Ankur Khurana ankur.kkhur...@gmail.com wrote: but in precedence order || . Checked the same in dennis ricthie. and || both have the same precedence. There is a shorthand pattern of evaluation for the expressions. learning that will help Regards, B.C.Someshwar

Re: [algogeeks] MS Written Test

2011-07-26 Thread Mukul Gupta
Well here is one good tutorial on Topcoder http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=usingTries.May be this can help you. On Sun, Jul 24, 2011 at 3:51 AM, Akash Mukherjee akash...@gmail.com wrote: sorry if it seems to be off the topic, but any good resources for trie for a

Re: [algogeeks] MS Written Test

2011-07-26 Thread Mukul Gupta
here is one good tutorial on topcoder http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=usingTries May be this can help you. On Sun, Jul 24, 2011 at 3:51 AM, Akash Mukherjee akash...@gmail.com wrote: sorry if it seems to be off the topic, but any good resources for trie for a newbie??

Re: [algogeeks] need the book google resume and algorithms for interviews

2011-07-26 Thread Bhanu Pratap Singh
Hi vivek... i don't know !! Can u please mail me your copy of the book Vivek!! I shall be obliged!! -- 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

[algogeeks] Re: problem tree minimum sum in binary

2011-07-26 Thread WgpShashank
Guys this problem generated lot of discussion in computer science as ist Euler Problem as it involves maths stuff rather then considering tree (it wont work check below link for detail ) or applying computer science . Also problem is already famous (Euler problem ) as we have to find the

Re: [algogeeks] Facebook Interview question at NIT Warangal

2011-07-26 Thread praneethn
check this link: *http://www.stefan-pochmann.info/spots/tutorials/sets_subsets/* On Tue, Jul 26, 2011 at 11:59 AM, sumit sumitispar...@gmail.com wrote: Given an array of size n, print all the possible subset of array of size k. eg:- input: a[]={1,2,3,4}, k = 2 output: 1,2 1,3 1,4 2,3

[algogeeks] Array question

2011-07-26 Thread Shikhar
Given an array of integers, for each element of the array, print the first number on the right side of the element which is smaller than it. print -1 is there is no such element. eg: 3,4,2,18,19,1,10 Ans: 2,2,1,10,10,-1,-1 O(n^2) solution is trivial. One solution could be: Insert the elements

[algogeeks] Re: Graph Based Problems

2011-07-26 Thread WgpShashank
if geeks are Really Interested in Application of Graph then why not start from Now :) 1. if you click on any orkut member's name you will notice the relationship for both of you indicating through whom you are interconnected or in certain cases you won't get this path. if you have to propose

Re: [algogeeks] Array question

2011-07-26 Thread Piyush Sinha
Use stack On Tue, Jul 26, 2011 at 5:22 PM, Shikhar shikharko...@gmail.com wrote: Given an array of integers, for each element of the array, print the first number on the right side of the element which is smaller than it. print -1 is there is no such element. eg: 3,4,2,18,19,1,10 Ans:

Re: [algogeeks] Array question

2011-07-26 Thread Piyush Sinha
Sorry for the above mistakeits not O(n) On Tue, Jul 26, 2011 at 5:29 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: Use stack On Tue, Jul 26, 2011 at 5:22 PM, Shikhar shikharko...@gmail.com wrote: Given an array of integers, for each element of the array, print the first number on

[algogeeks] Re: Array question

2011-07-26 Thread Shikhar
@piyush: Just curious, how exactly can a stack be used in this problem? On Jul 26, 5:00 pm, Piyush Sinha ecstasy.piy...@gmail.com wrote: Sorry for the above mistakeits not O(n) On Tue, Jul 26, 2011 at 5:29 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: Use stack On Tue, Jul

Re: [algogeeks] Array question

2011-07-26 Thread ankit sambyal
The O/P of ur example should be 2,2,1,1,1,-1,-1 or am I getting it 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] Re: Array question

2011-07-26 Thread Shikhar
@ankit: you are right...sorry about the error On Jul 26, 5:11 pm, ankit sambyal ankitsamb...@gmail.com wrote: The O/P of ur example should be 2,2,1,1,1,-1,-1 or am I getting it wrong ?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

Re: [algogeeks] Re: Array question

2011-07-26 Thread Akshata Sharma
@Piyush, using stack i guess it can be done in O(n) On Tue, Jul 26, 2011 at 5:42 PM, Shikhar shikharko...@gmail.com wrote: @ankit: you are right...sorry about the error On Jul 26, 5:11 pm, ankit sambyal ankitsamb...@gmail.com wrote: The O/P of ur example should be 2,2,1,1,1,-1,-1 or am I

Re: [algogeeks] Re: Array question

2011-07-26 Thread Akshata Sharma
a crude algo, for(i=end to start) { while(!stk.empty()) { if(arr[i]arr[stk.top]) pop(); else break; } if(!stk.empty()) l = arr.length-1; else l = stk.top; output[i]=l-i-1; stk.puch(i); } This will be O(n). Correct me I am wrong anywhere.. On Tue, Jul 26, 2011 at 5:49 PM,

[algogeeks] size of self referential structure

2011-07-26 Thread Puneet Gautam
#includestdio.h #includestddef.h struct node{ int a; char *b[5]; struct node *link; }; main() { int a; a=sizeof(struct node); printf(%d,a); getchar(); return 0; } Whats the output..? -- You received this message because you are

Re: [algogeeks] size of self referential structure

2011-07-26 Thread Neeraj Gupta
28.? int a- 4 Five array of pointer to char 20( each pointer of 4 bytes) struct node * 4 bytes. On Tue, Jul 26, 2011 at 6:10 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: #includestdio.h #includestddef.h struct node{ int a; char *b[5]; struct node *link; };

Re: [algogeeks] size of self referential structure

2011-07-26 Thread sunny agrawal
4+20+4 = 28 bytes it should be i think On Tue, Jul 26, 2011 at 6:10 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: #includestdio.h #includestddef.h struct node{ int a; char *b[5]; struct node *link; }; main() { int a; a=sizeof(struct node);

Re: [algogeeks] Re: Array question

2011-07-26 Thread ankit sambyal
@Akshata : Plz explain ur algo... Its not clear. Like in the first iteration, else l = stk.top; is getting executed. but stack is empty, so how r u assigning value to l -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

[algogeeks] Hashing with strings

2011-07-26 Thread syl
can anyone please tell me how to do hashing with strings..just wanna confirm...and most importantly what is the use of it...i have never used it -- 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: Array question

2011-07-26 Thread Akshata Sharma
sorry for the typo ankit, its if(stk.empty()) l = arr.length-1; else l = stk.top; On Tue, Jul 26, 2011 at 6:19 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Akshata : Plz explain ur algo... Its not clear. Like in the first iteration, else l = stk.top; is getting executed. but

Re: [algogeeks] Re: Array question

2011-07-26 Thread Piyush Sinha
@Shikhar 1) Push the first element to stack. 2) for i = 1 to n-1 a) temp =a[i] b) while(stack not empty) int x = pop(stack) if(xtemp) print(temp); else push(x,stack) break; c) push(temp,stack) 3) After the

[algogeeks] Re: Graph Based Problems

2011-07-26 Thread Optimus Prime
I have no idea on what the 1st question is about as i have never used orkut... 1. Regarding the 2nd one. Maintain a adjacency list for both the user's friends. 2. Move through the friends of user 1 and mark them grey. 3. Move through the user 2 friends and mark them grey if not marked and mark

[algogeeks] Re: Hashing with strings

2011-07-26 Thread Don
A string hash function typically takes a string as an argument and returns an integer which can be used as an index into a hash table which allows it to be found quickly. The purpose is to relate a string to something else in an efficient way. For instance, a symbol table which stores variable

[algogeeks] Re: Poison River

2011-07-26 Thread Don
No, it might be possible for one person to carry two people. On Jul 26, 12:38 am, sunny agrawal sunny816.i...@gmail.com wrote: For N=3, if the people are named A,B, and C: A wears the shoes and carries B across the river. is there any condition that one can carry only one with him? On Tue,

[algogeeks] Re: Poison River

2011-07-26 Thread Don
It is a *pair* of shoes, after all. Don On Jul 26, 2:16 am, subashree sridhar subashreesrid...@gmail.com wrote: i think this problem can be solved easily for any no of ppl if they are crossin the river using one shoe at a time :D :P On Jul 26, 10:38 am, sunny agrawal sunny816.i...@gmail.com

Re: [algogeeks] size of self referential structure

2011-07-26 Thread Akshata Sharma
why isn't padding done here? We have seen previous posts on size of structures, where due to padding, the size was not just the sum of size of datatypes, but also padded bytes. like here, int (4 bytes), then why is 3 bytes not padded after this, before char* arr[5] (20 bytes)? On Tue, Jul 26,

[algogeeks] Re: Hashing with strings

2011-07-26 Thread syl
thanks for the info...i saw a method of using 4 bytes of string together and then add them and finally take a modulusdoing such a complex thing ...is thr any way to recover the string back using the key only.can you give an example where you have seen using hashing with strings...that

Re: [algogeeks] Closest as Possible

2011-07-26 Thread Puneet Gautam
@rshetty: do u mean the sum of any no of elements separately in the two partitions be equal to each other..? is that what u mean..? On 7/26/11, rShetty rajeevr...@gmail.com wrote: Problem statement goes as : Consider square root of integers form 1 to 100. Now partition the square roots of

Re: [algogeeks] size of self referential structure

2011-07-26 Thread aditya kumar
@akshata: here padding wont come into picture coz int a =4byte, char *b[5]=4*5byte, *link=4byte all are multiple of 4 . ans will be 28 byte On Tue, Jul 26, 2011 at 6:42 PM, Akshata Sharma akshatasharm...@gmail.comwrote: why isn't padding done here? We have seen previous posts on size of

Re: [algogeeks] Re: Hashing with strings

2011-07-26 Thread Puneet Gautam
Doing such a complex thing reduces collisions and makes hashing effective.. Well, I didnt get you fully on dat 4 bytes of string together ... I think u should refer to Article 6.6, Chapter 6(Structures) in The C programming Language by Dennis Rtchie book.. Its very well explained there...!! The

[algogeeks] Re: Hashing with strings

2011-07-26 Thread Don
Usually a hash function is one-way, meaning that you can't recover the original string. That is because there are many more possible values for the string than for the hash index, making the hash function a many-to-one relationship. A very common hash function which I believe was mentioned in

[algogeeks] Re: size of self referential structure

2011-07-26 Thread Don
A reasonable guess would be 28 bytes. But the size of a structure is implementation dependent, and therefore, some other result could be correct as well. Don On Jul 26, 7:40 am, Puneet Gautam puneet.nsi...@gmail.com wrote: #includestdio.h #includestddef.h struct node{        int a;        

[algogeeks] The Google Resume

2011-07-26 Thread Akshata Sharma
Anyone having the Google Resume book pdf? -- 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.

[algogeeks] Amazon Question

2011-07-26 Thread swetha rahul
Hi, Print all the substrings of a given string. Is there any solution better than O(n^2). Eg: abc the possible substrings are {a,b,c,ab,bc,abc} -- 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] C Output

2011-07-26 Thread swetha rahul
Dipankar, Thanks!!! On Tue, Jul 26, 2011 at 8:44 AM, Dipankar Patro dip10c...@gmail.com wrote: Swetha, '\' in C is used to denote a escape sequence in C strings (and also in many other languages). e.g '\n' is for New Line '\n' is counted as one character. Now '\ooo' is for an ASCII in

Re: [algogeeks] The Google Resume

2011-07-26 Thread Saravanan T
+1 Pls send to my email id as well.. On Tue, Jul 26, 2011 at 7:09 PM, Akshata Sharma akshatasharm...@gmail.comwrote: Anyone having the Google Resume book pdf? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] Re: size of self referential structure

2011-07-26 Thread Puneet Gautam
@everyone: I have this mind strangling doubt..!!! Why is char *s[5] of 20 bytes...? yes the output is 28... On 7/26/11, Don dondod...@gmail.com wrote: A reasonable guess would be 28 bytes. But the size of a structure is implementation dependent, and therefore, some other result could be

Re: [algogeeks] Re: size of self referential structure

2011-07-26 Thread Akshata Sharma
char *s[5] is an array of 5 char pointers. A pointer is an int, of size 4 bytes. So, 5*4 = 20 bytes On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: @everyone: I have this mind strangling doubt..!!! Why is char *s[5] of 20 bytes...? yes the output is 28... On

Re: [algogeeks] Re: size of self referential structure

2011-07-26 Thread aditya kumar
char *s[5] is a array of pointers of type char . but the thing is size of pointers is 4byte irrespective of its type . coz address is always an unsigned int which is of 4byte. On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: @everyone: I have this mind strangling

[algogeeks] AMAZON Q

2011-07-26 Thread Piyush Sinha
You have an array like ar[]= {1,3,2,4,5,4,2}. You need to create another array ar_low[] such that ar_low[i] = number of elements lower than or equal to ar[i] in ar[i+1:n-1]. So the output of above should be {0,2,1,2,2,1,0} Time complexity : O(nlogn) use of extra space allowed. -- *Piyush

Re: [algogeeks] Re: size of self referential structure

2011-07-26 Thread Puneet Gautam
ok...! #includestdio.h #includestddef.h struct node{ int a; char b[5]; struct node *link; }; main() { int a; a=sizeof(struct node); printf(%d,a); getchar(); return 0; } why is its output : 16? Sudnt it be 4(int a) +5(char b[5]

Re: [algogeeks] Re: size of self referential structure

2011-07-26 Thread Prem Krishna Chettri
Its Cos that is pointer and all pointers is 4 bytes address.. On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: @everyone: I have this mind strangling doubt..!!! Why is char *s[5] of 20 bytes...? yes the output is 28... On 7/26/11, Don dondod...@gmail.com

Re: [algogeeks] Re: size of self referential structure

2011-07-26 Thread Puneet Gautam
for the above mentioned code, in previous post,: shudnt the output be 4+5+4=13? On 7/26/11, Prem Krishna Chettri hprem...@gmail.com wrote: Its Cos that is pointer and all pointers is 4 bytes address.. On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: @everyone: I

Re: [algogeeks] AMAZON Q

2011-07-26 Thread Someshwar Chandrasekaran
On Tue, Jul 26, 2011 at 7:18 PM, Piyush Sinha ecstasy.piy...@gmail.com wrote: You have an array like ar[]= {1,3,2,4,5,4,2}. You need to create another array ar_low[] such that ar_low[i] = number of elements lower than or equal to ar[i] in ar[i+1:n-1]. So the output of above should be

Re: [algogeeks] Re: size of self referential structure

2011-07-26 Thread Akshata Sharma
padding.. 4 byes int + 3 padding bytes + 5 char bytes + 4 bytes pointer =16 On Tue, Jul 26, 2011 at 7:22 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: for the above mentioned code, in previous post,: shudnt the output be 4+5+4=13? On 7/26/11, Prem Krishna Chettri hprem...@gmail.com wrote:

Re: [algogeeks] Re: size of self referential structure

2011-07-26 Thread kavitha nk
the link ll not occupy any m/y here...so its output ll be 14(int -4 bytes,ptr-2 bytes);;if i'm wrong jst crct it... On 7/26/11, Prem Krishna Chettri hprem...@gmail.com wrote: Its Cos that is pointer and all pointers is 4 bytes address.. On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam

Re: [algogeeks] Re: size of self referential structure

2011-07-26 Thread Akshata Sharma
@kavitha, what is m/y? On Tue, Jul 26, 2011 at 7:27 PM, kavitha nk kavithan...@gmail.com wrote: the link ll not occupy any m/y here...so its output ll be 14(int -4 bytes,ptr-2 bytes);;if i'm wrong jst crct it... On 7/26/11, Prem Krishna Chettri hprem...@gmail.com wrote: Its Cos that is

Re: [algogeeks] Re: size of self referential structure

2011-07-26 Thread kavitha nk
sry memory... On 7/26/11, Akshata Sharma akshatasharm...@gmail.com wrote: @kavitha, what is m/y? On Tue, Jul 26, 2011 at 7:27 PM, kavitha nk kavithan...@gmail.com wrote: the link ll not occupy any m/y here...so its output ll be 14(int -4 bytes,ptr-2 bytes);;if i'm wrong jst crct it...

Re: [algogeeks] Amazon Question

2011-07-26 Thread kavitha nk
hoe to find the combination and permutation for a given string? On 7/26/11, swetha rahul swetharahu...@gmail.com wrote: Hi, Print all the substrings of a given string. Is there any solution better than O(n^2). Eg: abc the possible substrings are {a,b,c,ab,bc,abc} -- You

Re: [algogeeks]

2011-07-26 Thread kavitha nk
pls explain the questi dint get it.. On 7/26/11, Dipankar Patro dip10c...@gmail.com wrote: Puneet, you missed out the 'sorted' part of array. Your code works fine for randomized array. +1 to Manish's solution. I had the same algo :) On 26 July 2011 00:33, Puneet Gautam

Re: [algogeeks] Closest as Possible

2011-07-26 Thread rajeev bharshetty
Sum of any number of elements on the two partitions should be as close as possible. On Tue, Jul 26, 2011 at 6:49 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: @rshetty: do u mean the sum of any no of elements separately in the two partitions be equal to each other..? is that what u mean..?

Re : [algogeeks] Re: size of self referential structure

2011-07-26 Thread Charlotte Swazki
It is not 28 ? 4 sizeof(int) + 20 + 4 (ptr). And no padding, cos' all is mutiple of 4. On Jul 26, 7:40 am, Puneet Gautam puneet.nsi...@gmail.com wrote: #includestdio.h #includestddef.h struct node{         int a;         char *b[5];         struct node *link;         }; main() {

Re: [algogeeks]

2011-07-26 Thread kavitha nk
@saurabh::gets too could be used //BE COOL// kavi -- 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] Re: size of self referential structure

2011-07-26 Thread Charlotte Swazki
On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: @everyone: I have this mind strangling doubt..!!! Why is char *s[5] of 20 bytes...? 5 x sizeof (*s). do you see ? -- You received this message because you are subscribed to the Google Groups Algorithm

Re: Re : [algogeeks] Re: size of self referential structure

2011-07-26 Thread kavitha nk
sry frendzma above posts were wrongans is 28 if ptr takes 4 bytes... //BE COOL// kavi -- 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,

Re: [algogeeks]

2011-07-26 Thread rajeev bharshetty
test or text ?? On Tue, Jul 26, 2011 at 7:52 PM, kavitha nk kavithan...@gmail.com wrote: @saurabh::gets too could be used //BE COOL// kavi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: Re : [algogeeks] Re: size of self referential structure

2011-07-26 Thread vaibhav shukla
will there be any difference in size on 32 machine and on 64 bit machine ? how and what ? On Tue, Jul 26, 2011 at 7:58 PM, kavitha nk kavithan...@gmail.com wrote: sry frendzma above posts were wrongans is 28 if ptr takes 4 bytes... //BE COOL// kavi -- You received this message

Re: [algogeeks] Re: Graph Based Problems

2011-07-26 Thread rajeev bharshetty
DFS or BFS traversal would do to find the relationships in a network of friends . Traverse the graph and appropriately find the nodes (friends) which are at one level below in a graph(tree). As Linkedin does , it finds people connected to you at various levels of depth as people connected at

[algogeeks] self referential struct. Contd.

2011-07-26 Thread Puneet Gautam
what is meant by padding in self_referenced structure? Is it always necessary? -- 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: Re : [algogeeks] Re: size of self referential structure

2011-07-26 Thread sunny agrawal
yes on a 64 bit machine ans will be 4+5*8+8 = 52 bytes pointers take 8 byte on 64 bit machine On Tue, Jul 26, 2011 at 8:00 PM, vaibhav shukla vaibhav200...@gmail.comwrote: will there be any difference in size on 32 machine and on 64 bit machine ? how and what ? On Tue, Jul 26, 2011 at 7:58

[algogeeks] self referential struct. Contd.

2011-07-26 Thread Puneet Gautam
what is meant by padding in self_referenced structure? Is it always necessary? -- 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]

2011-07-26 Thread Puneet Gautam
yup .. I know... I missed dat out...! But say , the array is random sorted, then is there an O(N) solution? On 7/26/11, Dipankar Patro dip10c...@gmail.com wrote: Puneet, you missed out the 'sorted' part of array. Your code works fine for randomized array. +1 to Manish's solution. I had

  1   2   >