[algogeeks] Re: compiler

2011-08-05 Thread Gene
This depends on the compiler and to some extent on the language. But in most cases, temporary values are stored in registers first. When there are not enough registers, the compiler spills them into space allocated in a stack activation record so that the space is automatically reclaimed when

[algogeeks] pls help

2011-08-05 Thread Kamakshii Aggarwal
given a set of letters and a length N, produce all possible output.(Not permutation). For example, give the letter (p,o) and length of 3, produce the following output(in any order you want, not just my example order) ppp ppo poo pop opp opo oop ooo another example would be given (a,b) and length

Re: [algogeeks] pls help

2011-08-05 Thread Raghavan
A *trie *could help here where the number of children for each node matches the required length. On Fri, Aug 5, 2011 at 12:20 PM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: given a set of letters and a length N, produce all possible output.(Not permutation). For example, give the letter

Re: [algogeeks] pls help

2011-08-05 Thread Gaurav Menghani
On Fri, Aug 5, 2011 at 12:20 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: given a set of letters and a length N, produce all possible output.(Not permutation). For example, give the letter (p,o) and length of 3, produce the following output(in any order you want, not just my example

Re: [algogeeks] pls help

2011-08-05 Thread Kamakshii Aggarwal
@gaurav:i could not understand ur sol.can u explain it again.. On Fri, Aug 5, 2011 at 12:32 PM, Gaurav Menghani gaurav.mengh...@gmail.comwrote: On Fri, Aug 5, 2011 at 12:20 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: given a set of letters and a length N, produce all possible

Re: [algogeeks] pls help

2011-08-05 Thread Gaurav Menghani
The basic idea is that for every position of the string, you fill it with all possible alphabets in your set of allowed alphabets, let the set be called alphabet. Now, you can do this recursively. backtrack(s,l) denotes, a string s has been formed, and is of length l. Now we need to add more

Re: [algogeeks] pls help

2011-08-05 Thread Aman Goyal
as an eg. let ab be the string, and 3 characters length string is wht is expected.. a - - b - - a a - a b - b a - b b - a a a a a b a b a a b b b a a b a b b b a b b b On Fri, Aug 5, 2011 at 12:49 PM, Gaurav Menghani gaurav.mengh...@gmail.comwrote: The basic idea is that for every

Re: [algogeeks] pls help

2011-08-05 Thread Gaurav Menghani
An Implementation: #includeiostream #includestring using namespace std; string alphabet; int maxlen; void backtrack(string s,int l) { if(l==maxlen) { coutsendl; return; } s.push_back('-'); for(int i=0;ialphabet.size();i++) { s[l]=alphabet[i]; backtrack(s,l+1); } } int main() {

[algogeeks] Printf

2011-08-05 Thread anurag
What will be the output. int i=5; printf(%u,i); What it will print: i. 5 ii. Base address of the memory iii. Physical address iv. Logical address -- 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] pls help

2011-08-05 Thread Nitin Nizhawan
Or one could just simulate a counting from 0 to (numchars^N)-1 in base numchars. ... code: void printit(int N,char chars[],int index[]){ for(int i=0;iN;i++){ printf(%c,chars[index[i]]); } printf(\n); } void generate(int numchars,char chars[],int N){ int index[100]={0};

Re: [algogeeks] Printf

2011-08-05 Thread Aman Goyal
physical address i suppose... On Fri, Aug 5, 2011 at 1:09 PM, anurag anurag19aggar...@gmail.com wrote: What will be the output. int i=5; printf(%u,i); What it will print: i. 5 ii. Base address of the memory iii. Physical address iv. Logical address -- You received this message

[algogeeks] Re: Printf

2011-08-05 Thread amit karmakar
Invokes undefined behavior.! On Aug 5, 12:47 pm, Aman Goyal aman.goya...@gmail.com wrote: physical address i suppose... On Fri, Aug 5, 2011 at 1:09 PM, anurag anurag19aggar...@gmail.com wrote: What will be the output. int i=5; printf(%u,i); What it will print: i. 5 ii. Base

[algogeeks] remove duplicate words in a string

2011-08-05 Thread vaibhav shukla
Given a string,remove all duplicates words: input: where there is a will there is a way o/p : where will way. -- best wishes!! Vaibhav MCA -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread aj
you can write a python program to do that easily. program starts here : c=str.split(raw_input()) d=[] for x in c: d[x]=0 print list(d) -- 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: remove duplicate words in a string

2011-08-05 Thread vaibhav shukla
give it in C/C++ On Fri, Aug 5, 2011 at 1:57 PM, aj aj.jaswa...@gmail.com wrote: you can write a python program to do that easily. program starts here : c=str.split(raw_input()) d=[] for x in c: d[x]=0 print list(d) -- You received this message because you are subscribed to

Re: [algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread payel roy
Hash table ??? On 5 August 2011 13:58, vaibhav shukla vaibhav200...@gmail.com wrote: give it in C/C++ On Fri, Aug 5, 2011 at 1:57 PM, aj aj.jaswa...@gmail.com wrote: you can write a python program to do that easily. program starts here : c=str.split(raw_input()) d=[] for x in c:

[algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread amit karmakar
Using a trie data structure this can be solved in O(n). read each character of the input string and build a trie. Maintain the counts of all words. Now traverse the trie again with the input string and making decisions whether to print a string depending on the word count that you get from the

Re: [algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread vaibhav shukla
sorry one more constraint : no extra memory On Fri, Aug 5, 2011 at 2:03 PM, payel roy smithpa...@gmail.com wrote: Hash table ??? On 5 August 2011 13:58, vaibhav shukla vaibhav200...@gmail.com wrote: give it in C/C++ On Fri, Aug 5, 2011 at 1:57 PM, aj aj.jaswa...@gmail.com wrote: you

Re: [algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread ankit sambyal
First traverse the string and hash each word into a hash table if it is not present in the hash table. Then again traverse the string and hash each word. If the word is not present in the hash table, output it to the console. -- You received this message because you are subscribed to the Google

Re: [algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread saurabh singh
use maps for implementation of hash table... if no extra memory allowed then no possible solution within o(n) i think. On Fri, Aug 5, 2011 at 2:07 PM, ankit sambyal ankitsamb...@gmail.comwrote: First traverse the string and hash each word into a hash table if it is not present in the hash

Re: [algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread ankit sambyal
If no extra memory is allowed, then I think we can't do better than O(n^2), which is pretty straight forward. -- 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] Re: remove duplicate words in a string

2011-08-05 Thread vaibhav shukla
provide a solution whether greater than O(n) On Fri, Aug 5, 2011 at 2:09 PM, saurabh singh saurab...@gmail.com wrote: use maps for implementation of hash table... if no extra memory allowed then no possible solution within o(n) i think. On Fri, Aug 5, 2011 at 2:07 PM, ankit sambyal

Re: [algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread Amol Sharma
@ankit: agree with ankit..hash table or O(n^2) if no extra space -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Fri, Aug 5, 2011 at 1:39 AM, ankit sambyal ankitsamb...@gmail.comwrote: If no extra memory is allowed, then I think we can't do better

Re: [algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread Gaurav Menghani
Vaibhav, please don't dynamically alter the requirements of the problem :-) Better to say them up front. On Fri, Aug 5, 2011 at 2:10 PM, vaibhav shukla vaibhav200...@gmail.com wrote: provide a solution whether greater than O(n) On Fri, Aug 5, 2011 at 2:09 PM, saurabh singh saurab...@gmail.com

Re: [algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread vaibhav shukla
these are the final requirements Remove duplicate words, no extra space, On Fri, Aug 5, 2011 at 2:12 PM, Gaurav Menghani gaurav.mengh...@gmail.comwrote: Vaibhav, please don't dynamically alter the requirements of the problem :-) Better to say them up front. On Fri, Aug 5, 2011 at 2:10

Re: [algogeeks] Re: Printf

2011-08-05 Thread Amol Sharma
physical address i think -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Fri, Aug 5, 2011 at 1:01 AM, amit karmakar amit.codenam...@gmail.comwrote: Some discussions here, http://ubuntuforums.org/showthread.php?t=316081 and some here,

Re: [algogeeks] Amazon Question

2011-08-05 Thread Arun Vishwanathan
would u mind giving a short explanation of yr code too if possible? On Thu, Aug 4, 2011 at 5:38 PM, Apoorve Mohan apoorvemo...@gmail.comwrote: I think this should worktell me if this works... void longest_0_1_substring(char *str) { int

Re: [algogeeks] Amazon Question

2011-08-05 Thread Arun Vishwanathan
by the way doesnt it look like an O(n^2) algo? On Fri, Aug 5, 2011 at 10:53 AM, Arun Vishwanathan aaron.nar...@gmail.comwrote: would u mind giving a short explanation of yr code too if possible? On Thu, Aug 4, 2011 at 5:38 PM, Apoorve Mohan apoorvemo...@gmail.comwrote: I think this should

Re: [algogeeks] pls help

2011-08-05 Thread Varun Jakhoria
I think it can be done using bitwise ANDing with a mask On Fri, Aug 5, 2011 at 12:58 PM, Gaurav Menghani gaurav.mengh...@gmail.com wrote: An Implementation: #includeiostream #includestring using namespace std; string alphabet; int maxlen; void backtrack(string s,int l) {  if(l==maxlen)

Re: [algogeeks] max product of a subarray

2011-08-05 Thread Arun Vishwanathan
it is difficult to read code and understand but based on the logic u mentioned in 3 points i just want to know if u also have taken care of the case where u have zero points in the array and as u say find each product around 0 points, do u check within each subarray around the zero point if the

Re: [algogeeks] pls help

2011-08-05 Thread Kamakshii Aggarwal
@gaurav:can u please explain what is the purpose of this line.. s.push_back('-'); On Fri, Aug 5, 2011 at 1:10 PM, Nitin Nizhawan nitin.nizha...@gmail.comwrote: Or one could just simulate a counting from 0 to (numchars^N)-1 in base numchars. ... code: void printit(int N,char chars[],int

Re: [algogeeks] pls help

2011-08-05 Thread Gaurav Menghani
Just to increase the size of the string by one. Then you can put any character at the the new last position, which is 'l'. On Fri, Aug 5, 2011 at 2:34 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: @gaurav:can u please explain what is the purpose of this line.. s.push_back('-'); On Fri,

Re: [algogeeks] pls help

2011-08-05 Thread Gaurav Menghani
Great. On Fri, Aug 5, 2011 at 2:42 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: @gaurav:i got it..thanks for the solution On Fri, Aug 5, 2011 at 2:34 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: @gaurav:can u please explain what is the purpose of this line.. s.push_back('-');

Re: [algogeeks] pls help

2011-08-05 Thread Gaurav Menghani
Even if the number of elements is more than two, it is possible with bitwise operations, but it gets clumsy. Suppose your alphabet has 4 characters. You can either: - Count from 0 to (14*n)-1 and use four bits to denote the selection of the alphabet. Also, only one bit amongst those four should

Re: [algogeeks] pls help

2011-08-05 Thread Nitin Nizhawan
Ok, Thanks On Fri, Aug 5, 2011 at 2:53 PM, Gaurav Menghani gaurav.mengh...@gmail.comwrote: Even if the number of elements is more than two, it is possible with bitwise operations, but it gets clumsy. Suppose your alphabet has 4 characters. You can either: - Count from 0 to (14*n)-1 and use

[algogeeks] adobe

2011-08-05 Thread Agyat
hey, guys adobe is visiting our campus. So those who know questions that adobe asked in written or interview, please post here as it will be of great help (as adobe has visited some colleges already). Thank you in advance. -- You received this message because you are subscribed to the Google

[algogeeks] Goldman sachs intern

2011-08-05 Thread arvind kumar
NIT ALLAHABAD guys!! Please share your experiences abt Goldman sachs recruitment.. -- 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] probabilty

2011-08-05 Thread coder dumca
A man speaks truth 3 out of 4 times. He throws a die and reports it to be a 6. What is the probability of it being a 6? 1 /2 3 /4 5 /8 1 /8 -- 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] probabilty

2011-08-05 Thread nethaji guru
3 /4 -- With regards, Nethaji Guru -- 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

Re: [algogeeks] probabilty

2011-08-05 Thread Nitin Nizhawan
1/8 On Fri, Aug 5, 2011 at 4:19 PM, nethaji guru nethaji.1...@gmail.com wrote: 3 /4 -- With regards, Nethaji Guru -- 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

Re: [algogeeks] probabilty

2011-08-05 Thread aditi garg
1/8 On Fri, Aug 5, 2011 at 4:14 PM, coder dumca coder.du...@gmail.com wrote: A man speaks truth 3 out of 4 times. He throws a die and reports it to be a 6. What is the probability of it being a 6? 1 /2 3 /4 5 /8 1 /8 -- You received this message because you are subscribed to the

Re: [algogeeks] probabilty

2011-08-05 Thread coder dumca
i think it should be 3/4 On Fri, Aug 5, 2011 at 4:20 PM, aditi garg aditi.garg.6...@gmail.comwrote: 1/8 On Fri, Aug 5, 2011 at 4:14 PM, coder dumca coder.du...@gmail.com wrote: A man speaks truth 3 out of 4 times. He throws a die and reports it to be a 6. What is the probability of it

Re: [algogeeks] probabilty

2011-08-05 Thread Aηαη∂
1/8 On Fri, Aug 5, 2011 at 4:20 PM, aditi garg aditi.garg.6...@gmail.comwrote: 1/8 On Fri, Aug 5, 2011 at 4:14 PM, coder dumca coder.du...@gmail.com wrote: A man speaks truth 3 out of 4 times. He throws a die and reports it to be a 6. What is the probability of it being a 6? 1 /2 3

Re: [algogeeks] probabilty

2011-08-05 Thread Nitin Nizhawan
yes it cant be 1/8 I was wrong. On Fri, Aug 5, 2011 at 4:23 PM, coder dumca coder.du...@gmail.com wrote: i think it should be 3/4 On Fri, Aug 5, 2011 at 4:20 PM, aditi garg aditi.garg.6...@gmail.comwrote: 1/8 On Fri, Aug 5, 2011 at 4:14 PM, coder dumca coder.du...@gmail.comwrote: A

[algogeeks] Goldman sachs placements

2011-08-05 Thread Jyoti Gupta
please share questions both for written an interview ! -- 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 Question

2011-08-05 Thread surender sanke
Hi, for 1 do +1 for 0 do -1 maintain count at every index of array eg: 100110 array X 1 0 0 0 0 0 0 1 1 0 count 0 1 0 -1 -2 -3 -4 -5 -4 -3 -4 index -1 0 1 2 3 4 5 6 7 8 9 find count with same value having max index difference. -3 is count at index 4 and 8 max difference

Re: [algogeeks] probabilty

2011-08-05 Thread Arun Vishwanathan
he speaks the truth 1/4 time...the probability of 6 is 1/6so isnt it just 1/4*1/6=1/24?? On Fri, Aug 5, 2011 at 12:54 PM, Nitin Nizhawan nitin.nizha...@gmail.comwrote: yes it cant be 1/8 I was wrong. On Fri, Aug 5, 2011 at 4:23 PM, coder dumca coder.du...@gmail.com wrote: i think it

Re: [algogeeks] probabilty

2011-08-05 Thread aditi garg
@arun he speaks truth 3/4 times On Fri, Aug 5, 2011 at 4:40 PM, Arun Vishwanathan aaron.nar...@gmail.comwrote: he speaks the truth 1/4 time...the probability of 6 is 1/6so isnt it just 1/4*1/6=1/24?? On Fri, Aug 5, 2011 at 12:54 PM, Nitin Nizhawan nitin.nizha...@gmail.comwrote:

Re: [algogeeks] probabilty

2011-08-05 Thread tarang dawer
1/2 -- 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

[algogeeks] hash table

2011-08-05 Thread Kamakshii Aggarwal
can we implement random() function on a hash table in O(1) . -- Regards, Kamakshi kamakshi...@gmail.com -- 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

Re: [algogeeks] Re: Printf

2011-08-05 Thread Kamakshii Aggarwal
logical address On Fri, Aug 5, 2011 at 2:20 PM, Amol Sharma amolsharm...@gmail.com wrote: physical address i think -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Fri, Aug 5, 2011 at 1:01 AM, amit karmakar amit.codenam...@gmail.comwrote:

Re: [algogeeks] Re: Printf

2011-08-05 Thread muthu raj
physical adress is never acessible.Those who claim physical adress pls support ur answers. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Fri, Aug 5, 2011 at 4:57 PM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: logical address On Fri, Aug 5, 2011 at 2:20 PM, Amol Sharma

[algogeeks] Re: adobe

2011-08-05 Thread Manee
ADOBE asks the very basic C/C++ questions one of their toughest however was : every number ending in 3 has a multiple of the form 111...111 e.g 3 has 111 13 has 11 so on.. find the algo for finding the number for an input number ending in 3. On Aug 5, 2:33 pm, Agyat

Re: [algogeeks] probabilty

2011-08-05 Thread Nitin Nizhawan
A dice is 6 B reports 6 P(A) = 1/6 P(!A) = 5/6 P(B|!A) =(1/4)*(1/5) P(B|A) = (3/4) P(A|B) = P(B|A)*P(A)/( P(B|A)*P(A) + P(B|!A)*P(!A)) =((3/4)*(1/6))/( (3/4)*(1/6) + (1/4)*(1/5)*(5/6)) = 3/4 On Fri, Aug 5, 2011 at 4:50 PM, tarang dawer tarrang1...@gmail.com wrote: 1/2 -- You

Re: [algogeeks] Re: Printf

2011-08-05 Thread Dipankar Patro
+1 to logical address. User programs are never given access to physical address. On 5 August 2011 17:00, muthu raj muthura...@gmail.com wrote: physical adress is never acessible.Those who claim physical adress pls support ur answers. *Muthuraj R IV th Year , ISE PESIT , Bangalore*

[algogeeks] Re: max product of a subarray

2011-08-05 Thread WgpShashank
So you Might to Interested to Review It Algorithm Lets us take an array = { 2,-25,4,5,-3,-5} We take 3 variables P , N , Val P=1 , N=0 , Val=0 first value is 2 , A[0] which is +ve . So we multiply both P N with A[0] . P=2 , N=0 now V[1] = -25 -ve . We multiply P with -V[1] N with -V[1] .

[algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread deepikaanand
static int array[256]; removedupli(char s[],int n) { array[s[0]]=1; for(i=1;in;i++) { if(array[s[i]]==0) array[s[i]]=1; else { for(pos=i;in;i++) s[pos]=s[pos+1]; i--; } } } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] Structure Q

2011-08-05 Thread Vijay Khandar
struct list { int x; struct list *next; }*head; The statement head.x=100 A)assigns 100 to one element of the structure list B)creates a node of type list and assigns a value to x C)creates a head of the list D)error Plz anyone provide correct option with explanation.. -- You

Re: [algogeeks] probabilty

2011-08-05 Thread Arun Vishwanathan
oops sorry there On Fri, Aug 5, 2011 at 1:13 PM, aditi garg aditi.garg.6...@gmail.comwrote: @arun he speaks truth 3/4 times On Fri, Aug 5, 2011 at 4:40 PM, Arun Vishwanathan aaron.nar...@gmail.comwrote: he speaks the truth 1/4 time...the probability of 6 is 1/6so isnt it just

[algogeeks] Random number

2011-08-05 Thread payel roy
Given a range 0-N, generate 'M' random numbers from the range without any duplication. The space complexity is O(1). -- 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

Re: [algogeeks] probabilty

2011-08-05 Thread Arun Vishwanathan
@nitin: oh yes i dint see that coming...good working On Fri, Aug 5, 2011 at 1:49 PM, Arun Vishwanathan aaron.nar...@gmail.comwrote: oops sorry there On Fri, Aug 5, 2011 at 1:13 PM, aditi garg aditi.garg.6...@gmail.comwrote: @arun he speaks truth 3/4 times On Fri, Aug 5, 2011 at 4:40 PM,

Re: [algogeeks] Structure Q

2011-08-05 Thread SANDEEP CHUGH
ERROR On Fri, Aug 5, 2011 at 5:19 PM, Vijay Khandar vijaykhand...@gmail.comwrote: struct list { int x; struct list *next; }*head; The statement head.x=100 A)assigns 100 to one element of the structure list B)creates a node of type list and assigns a value to x C)creates a head of the

Re: [algogeeks] Structure Q

2011-08-05 Thread ankit sambyal
error because head is a pointer to the structure, hence head.x gives an error -- 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] Structure Q

2011-08-05 Thread Vijay Khandar
Thanks On Fri, Aug 5, 2011 at 5:25 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: ERROR On Fri, Aug 5, 2011 at 5:19 PM, Vijay Khandar vijaykhand...@gmail.comwrote: struct list { int x; struct list *next; }*head; The statement head.x=100 A)assigns 100 to one element of

Re: [algogeeks] Structure Q

2011-08-05 Thread Vijay Khandar
Thanks. On Fri, Aug 5, 2011 at 5:26 PM, ankit sambyal ankitsamb...@gmail.comwrote: error because head is a pointer to the structure, hence head.x gives an error -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] MS

2011-08-05 Thread rShetty
You're given an array containing both positive and negative integers and required to find the sub- array with the largest sum (O(N) a la KBL). Write a routine in C for the above Is this problem as simple as just adding the positive numbers with the subarray with largest sum being the set of

Re: [algogeeks] MS

2011-08-05 Thread payel roy
Kadane algorithm. Google it. On 5 August 2011 17:35, rShetty rajeevr...@gmail.com wrote: You're given an array containing both positive and negative integers and required to find the sub- array with the largest sum (O(N) a la KBL). Write a routine in C for the above Is this problem as

[algogeeks] Question

2011-08-05 Thread Vijay Khandar
What errors are you likely to get when you run the following program? #includestdio.h #includeconio.h #includestring.h void main() { clrscr(); struct emp { char name[20]; float sal; }; struct emp e[10]; int i; for(i=0;i=3;i++) scanf(%s %f,e[i].name,e[i].sal); getch(); } Plz Explain

Re: [algogeeks] Amazon Question

2011-08-05 Thread Arun Vishwanathan
hmm the problem is we need O(1) spacehaving that count wont make it O(1). i had an approach in mind of O(n) time and O(1) space..problem is i havent tested/debugged the code but it is O(1) space i guess and O(n) time. if total number of zeros(M) and 1s(N) are same print the whole array else

Re: [algogeeks] Question

2011-08-05 Thread Nikhil Gupta
Couldn't find any error. On Fri, Aug 5, 2011 at 5:38 PM, Vijay Khandar vijaykhand...@gmail.comwrote: What errors are you likely to get when you run the following program? #includestdio.h #includeconio.h #includestring.h void main() { clrscr(); struct emp { char name[20]; float sal;

[algogeeks] Question

2011-08-05 Thread Vijay Khandar
What errors are you likely to get when you run the following program? #includestdio.h #includeconio.h #includestring.h void main() { clrscr(); struct emp { char name[20]; float sal; }; struct emp e[10]; int i; for(i=0;i=3;i++) scanf(%s %f,e[i].name,e[i].sal); getch(); } A)floating point format

Re: [algogeeks] Question

2011-08-05 Thread Vijay Khandar
But program is not working properly... On Fri, Aug 5, 2011 at 5:44 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: Couldn't find any error. On Fri, Aug 5, 2011 at 5:38 PM, Vijay Khandar vijaykhand...@gmail.comwrote: What errors are you likely to get when you run the following

[algogeeks] Samsung Written

2011-08-05 Thread Nitin
can anybody give details for smasung written and interview ? -- 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] Samsung Written

2011-08-05 Thread parag khanna
Apti 1 hour -- 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

Re: [algogeeks] Question

2011-08-05 Thread Nikhil Gupta
http://www.ideone.com/ZIibX The changes I have done in the program are to make it compatible to gcc compiler. Check the statement in the bottom of the page. On Fri, Aug 5, 2011 at 5:46 PM, Vijay Khandar vijaykhand...@gmail.comwrote: What errors are you likely to get when you run the following

Re: [algogeeks] Re: Puzzle

2011-08-05 Thread Arun Vishwanathan
I guess anubhav soln seems ok On Thu, Aug 4, 2011 at 8:50 PM, ankit sambyal ankitsamb...@gmail.comwrote: @aditi:Thats a non uniform rope. The 1st half may burn faster than 2nd half. btw Priyanka's solution is correct. -- You received this message because you are subscribed to the

Re: [algogeeks] Question

2011-08-05 Thread SANDEEP CHUGH
ITS (A). BECAUSE WE HAVE TO LINK THE EMULATOR AS COMPILER SEES A REFERENCE TO FLOATING POINT NUMBER IT SETS ITS FLAG TO HAVE THE LINKER LINK INT THE EMULATOR.. ITS IN 16 BIT COMPILER BECAUSE THERE IS NO PROVISION FOR FLOATING POINT OPERATIONS IN 16 BIT MICRO PROCESSOR..SO THEY USE FLOATING POINT

[algogeeks] Reverse Bits

2011-08-05 Thread rShetty
This is the code to reverse the bits in an unsigned integer . Could anyone please explain the logic of this approach ? Thank You !! #define reverse(x) \ (x=x16|(0xx)16, \ x=(0xff00ff00x)8|(0x00ff00ffx)8, \ x=(0xf0f0f0f0x)4|(0x0f0f0f0fx)4, \ x=(0xx)2|(0xx)2, \

Re: [algogeeks] Question

2011-08-05 Thread Vijay Khandar
But program is not giving the o/p. I have taken one printf statement same as scanf..and scanf() taking i/p but prinf() not giving o/p... On Fri, Aug 5, 2011 at 5:53 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: http://www.ideone.com/ZIibX The changes I have done in the program are to

Re: [algogeeks] Question

2011-08-05 Thread SANDEEP CHUGH
INCLUDE THIS FUNCTION linkfloat( ) { float a = , *b ; b = a ; /* cause emulator to be linked */ a = *b ;/* suppress the warning - variable not used */ }; On Fri, Aug 5, 2011 at 6:04 PM, Vijay Khandar vijaykhand...@gmail.comwrote: But program is not giving the o/p. I have taken one printf

Re: [algogeeks] Random number

2011-08-05 Thread Gaurav Menghani
You might want to read the theory on Pseudo-Random Number Generators [0] and Linear Feedback Shift Register [1] The basic way of generating a random number is taking up a polynomial, f(x) = ax^n + bx^(n-1) + .. + yx + z, and finding f(i + seed) % N, where i is the ith random number you want, and

Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package

2011-08-05 Thread Lakshmi Prasad
for some inputs its giving junk as the answer and for others its giving segmentation fault could u plese explain why -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Reverse Bits

2011-08-05 Thread Nitin Nizhawan
x = x16 | (0xx)16 this line exchanges ls 16bits with ms 16bits, i.e. 1 pair of 16bit this logic of exchanging bits is the used for 2 pairs of 8bits each, then for 4 pairs of 4bit, then for 8 pairs of 2 bit and finally 16 pairs of 1bit. On Fri, Aug 5, 2011 at 6:04 PM, rShetty

Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package

2011-08-05 Thread Nitin Nizhawan
if input starts with one or more characters from the string A telephone girl then it will give SEG FAULT because it scanf will try to write to CS, else initial value junk will be printed On Fri, Aug 5, 2011 at 6:28 PM, Lakshmi Prasad prasadlakshmi...@gmail.comwrote: for some inputs its giving

Re: [algogeeks] Reverse Bits

2011-08-05 Thread mithun bs
Hi Rajeev, I follow similar approach. The basic logic is swap bits of a pair, then swap nibbles(2 bits) and then swap (4bits), 8bits and go on. So for ex. 0110 1101 1100 0101 In first step, I swap bits of each pair. So this becomes, Input - 0110 1101 1100 0101 output- 1001 1110 1100 1010 In

Re: [algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread mithun bs
Can you please explain this? Is array[256] not extra space? On Fri, Aug 5, 2011 at 5:14 PM, deepikaanand swinyanand...@gmail.comwrote: static int array[256]; removedupli(char s[],int n) { array[s[0]]=1; for(i=1;in;i++) { if(array[s[i]]==0) array[s[i]]=1; else { for(pos=i;in;i++)

Re: [algogeeks] MS

2011-08-05 Thread Naren s
http://people.csail.mit.edu/bdean/6.046/dp/ -- 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] nlogn, in-place, iterative mergesort?

2011-08-05 Thread Nitin Nizhawan
does anyone know of any in-place, iterative mergesort algorithm with nlogN worst case complexity? It would be good if it is stable also. TIA Nitin -- 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] Reverse Bits

2011-08-05 Thread rajeev bharshetty
@mithun : Thanks On Fri, Aug 5, 2011 at 6:37 PM, mithun bs mithun...@gmail.com wrote: Hi Rajeev, I follow similar approach. The basic logic is swap bits of a pair, then swap nibbles(2 bits) and then swap (4bits), 8bits and go on. So for ex. 0110 1101 1100 0101 In first step, I swap bits

Re: [algogeeks] Makemytrip.com

2011-08-05 Thread snehi jain
NIT kurukshetra people ... could post some information regarding the procedure followed by makemytrip during their recruitment process ... On Sat, Jul 30, 2011 at 1:51 AM, sukhmeet singh sukhmeet2...@gmail.comwrote: CTC ??? On Thu, Jul 28, 2011 at 10:22 PM, Raman Gugnani

[algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread deepikaanand
ya an array of 256 is surely a wastage of space but this was i couls think in my microsoft interview as the result should have also been i place that is i/p : AAA BBB CCC o/p:A BC//space should also be removed ::explanantion s[0] is alwayz unique therfor array[s[0]] = 1 = this char has already

[algogeeks] Circle

2011-08-05 Thread rShetty
Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all. -- 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

Re: [algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread Nitin Nizhawan
@deepika this is a different question, your solution is great for removing duplicate characters. original question is about removing duplicate words. On Fri, Aug 5, 2011 at 7:06 PM, deepikaanand swinyanand...@gmail.comwrote: ya an array of 256 is surely a wastage of space but this was i couls

Re: [algogeeks] Circle

2011-08-05 Thread Nitin Nizhawan
I think this will do. http://en.wikipedia.org/wiki/Midpoint_circle_algorithm On Fri, Aug 5, 2011 at 7:08 PM, rShetty rajeevr...@gmail.com wrote: Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all. -- You received this

Re: [algogeeks] Circle

2011-08-05 Thread deepika anand
u can use bresenhems algo or mid point (2nd order algo) -- 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] Random number

2011-08-05 Thread payel roy
How do you guarantee termination of your algorithm if duplication occurs ?? On 5 August 2011 18:25, Gaurav Menghani gaurav.mengh...@gmail.com wrote: You might want to read the theory on Pseudo-Random Number Generators [0] and Linear Feedback Shift Register [1] The basic way of generating a

Re: [algogeeks] Random number

2011-08-05 Thread Gaurav Menghani
1. Get a good seed. 2. Increase the degree of the polynomial. This is no fixed algorithm, if you find that more than T steps have passed and a new number has not been generated, you can always change the polynomial. And, please remember it is a 'pseudo-random number generator'. You can read the

Re: [algogeeks] Question

2011-08-05 Thread Dipankar Patro
try doing this way and tell if the program is working properly now: for (i=0; i3; i++) { scanf(%[^\n], e[i].name); scanf(%f, e[i].sal); } There is always some problem in string input using %s, don't really know why though deeply. On 5 August 2011 17:48, Vijay Khandar vijaykhand...@gmail.com

[algogeeks] simple doubt

2011-08-05 Thread Arun Vishwanathan
I guess someone had posted a link earlier from which I have a basic doubt when u have int arr[3]={1,0,2}; int **dp; int (*pa)[3]; is this the right assingment for instance? pa=arr; dp=arr; or have I flipped the ampersand in assigning? Also when I do pa++ will it jump by size of int or the

Re: [algogeeks] Question

2011-08-05 Thread Vijay Khandar
I include this fn linkfloat(), Now my program working properlybut why we have to include this fn externally plz explain. On Fri, Aug 5, 2011 at 6:07 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: INCLUDE THIS FUNCTION linkfloat( ) { float a = , *b ; b = a ; /* cause

  1   2   3   >