Re: [algogeeks] google os ques on pipelining
for the first instruction : 150+5+120+5+160+5+140=585 ns for the rest of the instructions , though pipeline max(150,120,160,140)=160 (160+5)*999=164835 ns we assume that there will be no extra stalls existed in our system -585 + 164835 =165420 ns =165.4 us... correct me if I'm wrong . On Sun, Sep 25, 2011 at 9:25 AM, siva viknesh sivavikne...@gmail.comwrote: A 4-stage pipeline has the stage delays as 150, 120, 160 and 140 ns (nano seconds) respectively. Registers that are used between the stages have a delay of 5 ns each. Assuming constant clocking rate, the total time taken to process 1000 data items on this pipeline will approximately be a. 120 us (micro seconds) b. 165 us c. 180 us d. 175 us ...plz give detailed explanation for the ans -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: question
this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Dheeraj Sharma Comp Engg. NIT Kurukshetra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Ratan Kumar B. Tech MNNIT, Allahabad -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Amazon SDE onsite interview question
@anush: we should look at all descendants and ancestors. .. but u 'r looking at pars In our structure we should have a parent pointer .. and we should look at all our descendants --- takes O(n) time .. correct me if I'm wrong ... On Tue, Sep 20, 2011 at 10:54 AM, anshu mishra anshumishra6...@gmail.comwrote: for simplicity i am doing it for binary tree (liittle modification) struct node { bool lock; int lockedDesc; node *left, *right, *par; }; bool Islock(node *cur) { return cur-bool; } void unLock(node *cur) { node *temp; cur-lock = false; temp = cur-par; while (temp != NULL) { temp-lockedDesc--; temp = temp-par; } } bool Lock(node *cur) { if (cur-lockedDesc) return false; node *temp = cur-par; while (temp != NULL temp-lock== false) { temp-lockedDesc++; temp = temp-par; } if (temp == NULL) { cur-lock = true; return true; } cur = cur-par; while (cur != temp) { cur-lockedDesc--; cur= cur-par; } return false; } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: Microsoft Question
@piyush: what is time and space complexity of u'r sol.. On Mon, Sep 19, 2011 at 11:03 AM, Piyush Grover piyush4u.iit...@gmail.comwrote: sry, in the findWord function all a's are different e.g a0, a1a7 and if(!a) is actually if(a0||a1||...||a7) thnx piyush On Mon, Sep 19, 2011 at 1:10 AM, Piyush Grover piyush4u.iit...@gmail.comwrote: for(i = 0; i n; i++) for(j = 0; j n; j++){ setColor(i, j) = black; if(A[i][j] == str[0]){ setColor(i, j) = blue; a = findWord(A, i, j, str, 1) if(!a) setColor(i, j) = black; else break; } } findWord(A, i, j, str, k){ if(k == strlen(str)) return true; if(A[i-1][j-1] == str[k] getColor(i-1, j-1) != blue) setColor(i-1, j-1) = blue; a = findWord(A, i-1, j-1, str, k+1); if(A[i-1][j] == str[k] getColor(i-1, j) != blue) setColor(i-1, j) = blue; a = findWord(A, i-1, j, str, k+1); if(A[i-1][j+1] == str[k] getColor(i-1, j+1) != blue) setColor(i-1, j+1) = blue; a = findWord(A, i-1, j+1, str, k+1); if(A[i][j-1] == str[k] getColor(i, j-1) != blue) setColor(i, j-1) = blue; a = findWord(A, i, j-1, str, k+1); if(A[i][j+1] == str[k] getColor(i, j+1) != blue) setColor(i, j+1) = blue; a = findWord(A, i, j+1, str, k+1); if(A[i+1][j-1] == str[k] getColor(i+1, j-1) != blue) setColor(i+1, j-1) = blue; a = findWord(A, i+1, j-1, str, k+1); if(A[i+1][j] == str[k] getColor(i+1, j) != blue) setColor(i+1, j) = blue; a = findWord(A, i+1, j, str, k+1); if(A[i+1][j+1] == str[k] getColor(i+1, j+1) != blue) setColor(i+1, j+1) = blue; a = findWord(A, i+1, j+1, str, k+1); if(!a) setColor(i, j) = black; return a; } This is a pseudo code. I haven't considered the boundary cases to make it understandable. On Mon, Sep 19, 2011 at 12:21 AM, vikas vikas.rastogi2...@gmail.comwrote: hmm, nice questions, can we create an efficient DS to query the strings ?? tried using trie but memory prints are very large ( O(n^2) )? :-(( On Sep 18, 12:59 pm, Anup Ghatage ghat...@gmail.com wrote: For the mentioned scenario, it seems to be the only feasible solution. On Sun, Sep 18, 2011 at 3:57 AM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: @anup : the time complexity will be very high ... O(n*M*M)...n=#characters to be checked...M=size of the matrix ... On Sat, Sep 17, 2011 at 8:30 AM, Anup Ghatage ghat...@gmail.com wrote: As WgpShashank once pointed out. Search the whole matrix for the first character instances, for each instance, send the array, string and that char's position to a function that will recursively check its direct neighbors for the next character. Exhaustively check like that for each starting characters appearance till you find the string, if any. On Fri, Sep 16, 2011 at 11:55 PM, Ankur Garg ankurga...@gmail.com wrote: In a matrix of. characters, find an string. String can be in any way (all 8 neighbours to be considered) like find Microsoft in below matrix. A C P *R *C* *X *S **O *P *C* V *O* V N *I* W G *F **M *N Q A *T* I T *Any Ideas How to Solve/Approach this problem ?* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Anup Ghatage -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumar http://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Anup Ghatage -- You received this message because you are subscribed
Re: [algogeeks] MS interview
Memory management has following things.. 1.Relocation To maintain the free pages and when a page is to be swapped, we have to add that page into free page list .. For this ,if we maintain a bool array which is equal to # pages in RAM,it gives whether it is free or not .. 2.Protection If ours is strict paging , then this is easy task to implement ... any way we have the fixed page size ... In segmentation , we maintain length of the segment..we can achieve protection... 3.Sharing for each page if we maintain the list of users this page has been given permission (either read or write) 4.Logical Organization 5.Physical Organization On Thu, Sep 15, 2011 at 2:06 PM, teja bala pawanjalsa.t...@gmail.comwrote: 13. Propose an algo/data struct for memory manager. 14. Propose and algo/data struct for timer manager. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Programs
@karthick: as per u'r code... for ex: total is i/p---o/p will be 'l' not 'o' since 'l' comes before to 'o' ... On Thu, Sep 15, 2011 at 10:55 PM, kartik sachan kartik.sac...@gmail.comwrote: soluntion for 1ST question is :http://ideone.com/LSOj6 # includecstdio# includecstringchar checknonrepeat(char *a,int *b,int n){ int i; for(i=0;in;i++) { if(b[a[i]]==1) break; }return a[i];}int main(){ int b[300]={0}; char a[]=teeter; int n=strlen(a); int i; for(i=0;in;i++) b[a[i]]++; printf(NON REPEATED CHAR=%c\n,checknonrepeat(a,b,n)); return 0;} complex O(lenght of string) plz correct me if i am 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: question on algorithm
@don: will u pls explain why divided by 5 is used On Fri, Sep 16, 2011 at 3:44 PM, prasanth n nprasnt...@gmail.com wrote: @Don: thanks a lot On Sat, Sep 17, 2011 at 12:28 AM, Don dondod...@gmail.com wrote: The algorithm is to count them, looping over the number of quarters and dimes. Then it is easy to compute the number of nickles which could be used, and the shortfall is made up with pennies. It is very common to see a recursive solution, but that is not necessary or beneficial when the iterative solution is so simple. Don int result = 0; for(int quarters = 0; quarters = n; quarters += 25) for(int dimes = 0; (quarters+dimes) = n; dimes += 10) result += 1 + (n-quarters-dimes) / 5; On Sep 16, 1:35 pm, prasanth n nprasnt...@gmail.com wrote: Given an infinite number of quarters (25 cents), dimes (10 cents), nickels (5 cents) and pennies (1 cent), write code to calculate the number of ways of representing n cents. also do give an algorithm first.. -- *prasanth* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *prasanth* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Microsoft Question
@anup : the time complexity will be very high ... O(n*M*M)...n=#characters to be checked...M=size of the matrix ... On Sat, Sep 17, 2011 at 8:30 AM, Anup Ghatage ghat...@gmail.com wrote: As WgpShashank once pointed out. Search the whole matrix for the first character instances, for each instance, send the array, string and that char's position to a function that will recursively check its direct neighbors for the next character. Exhaustively check like that for each starting characters appearance till you find the string, if any. On Fri, Sep 16, 2011 at 11:55 PM, Ankur Garg ankurga...@gmail.com wrote: In a matrix of. characters, find an string. String can be in any way (all 8 neighbours to be considered) like find Microsoft in below matrix. A C P *R *C* *X *S **O *P *C* V *O* V N *I* W G *F **M *N Q A *T* I T *Any Ideas How to Solve/Approach this problem ?* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Anup Ghatage -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Can we define a bijective function from set(strings) ------ Q?
@Anil : is there any reason in taking 31 in function pow(31,x) ?. On Wed, Sep 14, 2011 at 10:31 AM, AnilKumar B akumarb2...@gmail.com wrote: Hi, Can we define a bijective function from set(strings) -- Q? I thought of using a polynomial function, for example: f(ANIL)=pow(31,0)*ASCII(L)+pow(31,1)*ASCII(I)+pow(31,2)*ASCII(I)+pow(31,3)*ASCII(A), In this f will be one-one from set(Strings)---N, but I don't whether is onto or not? And one more thing for all combinations of Strings the output of this hash function might be 9,223,372,036,854,775,807, which cannot be represented in JAVA. So is it possible to define a bijective from Set(Strings)Q? Thanks Regards, B Anil Kumar. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] plzzzzzzzz heeeppppp!!!!!!!!!!1
+1 prem On Thu, Sep 15, 2011 at 2:54 AM, Prem Krishna Chettri hprem...@gmail.comwrote: Its an open ended question for the New Guys.. So.. here its some analysis.. If its project is RD with high profile org like Amazon.. Google.. SDET is Developer in Test (Framework Developer for TESTING) but QA is a Complete Tester (Mostly No Code Work).. So SDET will develop in basically in Some Scripting Languages like Ruby.. Python .. Shell etc.. However Development is not only writing feature in Complied Languages like C/C++ and Java but also maintenance and bug Fix.. So, for High profile org.. its always a great wk Exp in any of these filed . but for medium org its always Dev on top (few Exception).. Now its your Choice. Prem On Thu, Sep 15, 2011 at 12:10 PM, siddharam suresh siddharam@gmail.com wrote: testing is very broad area of s/w development. first get clear about the job, when i was giving interview with MS for SDET, they said its developing test s/w for already build s/w. my view, testing requires more skills than developer, to find out the flaws in the code. Thank you, Sid. On Thu, Sep 15, 2011 at 11:42 AM, vivek goel vivek.thapar2...@gmail.comwrote: hello nikhil, suppose if we currently opt for testing OR consultant profile then Is it possible to switch to Software Development profile later on. plss tell me... On 9/15/11, Nikhil Kumar nikhil.nsit...@gmail.com wrote: Testing profile : You have to test the features developed by others.Kinda bruteforce work , you will be given a set of commands and a large no. of test cases.All you have to do is run commands and validate test cases again and again.Boring.Only periodic growth. Developers: Much better. You have to develop new features yourself.You will apply concepts to mould the product.Growth chances are good.Growth basis is your talent and capability. On Thu, Sep 15, 2011 at 11:07 AM, abhinav gupta abhinav@gmail.comwrote: in my opinion developer profile is better than testing...one On Thu, Sep 15, 2011 at 10:57 AM, rahul sharma rahul23111...@gmail.comwrote: hey guys plz tell the difference b/w testing n develp. profile ??? n joing i n testing profile has growth as much as in develpoer???plz tell soon..?should i go in testing profile in lagre industry or in developer in medium scale...plz hepl -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Nikhil Kumar , Software Engineer @ Ciena Gurgaon. B.E.( Information Technology ) , NSIT Delhi , 2007-2011 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@gmail.com -- You received
Re: [algogeeks] C++ Query...
@teja : r u looking for something like this... #includestdio.h #includestdlib.h class Hai { public : int* getPointerToPrivate() { return i; } void setI(int j) { i=j; } private: int i; }; main() { Hai h; h.setI(10); int *i=h.getPointerToPrivate(); printf(%d,*i); } On Thu, Sep 15, 2011 at 6:41 AM, teja bala pawanjalsa.t...@gmail.comwrote: How to access class private data members with a pointer? thx in advance? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: Microsoft Question
The well known examples of priority queue is minheap and maxheap.. i guess the question is how do we implement one of these(at least) using queue? On Wed, Sep 14, 2011 at 9:08 AM, Ankuj Gupta ankuj2...@gmail.com wrote: I guess the functionality of priority should be maintained On Sep 13, 11:59 pm, Ankur Garg ankurga...@gmail.com wrote: But dude are u saying stack will be implemented as a map with value,priority and then choose element based on priority ? regards Ankur On Tue, Sep 13, 2011 at 10:16 PM, Ankuj Gupta ankuj2...@gmail.com wrote: For stack :- Keep incrementing the priority of each pushed element. So the last pushed element will have the greatest priority and the element pushed first will have lowest priority. For queue:- keep decrementing the priority of each inserted element. On Sep 13, 1:45 am, Ankur Garg ankurga...@gmail.com wrote: How to Implement a Queue with a Priority Queue Similarly how woud you implement Stack with Priority Queue -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] program
with space O(n) and time O(n), we can trace the whole array and maintain the freq of each number and by one more trace with using 3 variables , we can find top 3 On Wed, Sep 14, 2011 at 11:20 AM, raj raji20.pat...@gmail.com wrote: program to find the top 3 repeating number from the given array eg You r given an array and u have to find out the top 3 repeated numbers. for ex: GAURAV[]={20,8,3,7,8,9,20,6,4,6,20,8,20} so the output will be: 20 is repeated 4 times 8 is repeated 3 times 6 is repeated 2 times. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Matrix
will u pls provide one example .. so that every one understand ... On Wed, Sep 14, 2011 at 1:29 PM, guna sekaran vgun...@gmail.com wrote: Write a program for reversing the matrix -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] MICROSOFT WRITTEN QUESTION-2010
@jai gupta : merge sort for 2 sorted arrays --O(nlogn) right? On Tue, Sep 13, 2011 at 1:03 PM, jai gupta sayhelloto...@gmail.com wrote: @bharat: When each step of nishant's algo is O(n) how can it sum up to O(nlogn)??? On Tue, Sep 13, 2011 at 9:18 AM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: @nishant : your algo takes O(nlogn) time with higher constant behind this. can't we write better than this ? @sairam : will u pls provide implementation logic of u'r idea .. On Mon, Sep 12, 2011 at 12:43 PM, Sairam Ravu ravu...@gmail.com wrote: By merging smaller trees into larger trees we can obtain a much more efficient solution. -- With love and regards, Sairam Ravu I M. Tech(CS) Sri Sathya Sai Institute of Higher Learning To live life, you must think it, measure it, experiment with it, dance it, paint it, draw it, and calculate it -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Programs
For 2nd question : @Ishan : U'r code is not giving compilation error in gcc .. it is going into infinite loop .. This is working fine .. #includestdio.h #includestring.h int main() { int temp1[256]; int i=0; char str[50] = Battle of the vowels: Hawaii vs. Gronzy; char temp[6] = aeiou; for(i=0;i256;i++) temp1[i] = 0; i=0; while(temp[i]) { temp1[temp[i]] = 1; i++; } i=0; int flag=0,tail=0; while(str[i]) { if(temp1[str[i]] != 1) str[tail++] = str[i]; i++; } str[tail]='\0'; printf(%s, str); } output : Bttl f th vwls: Hw vs. Grnzy On Sun, Sep 11, 2011 at 1:27 PM, sukran dhawan sukrandha...@gmail.comwrote: #includebitset #includeiostream #includequeue using namespace std; int main() { char answer; bitset26 charset; bitset26 repeat; char a[]={'s','a','s','a','b','v','s','a'}; #ifdef TEST gets(a); #endif int i; for(i=0;a[i]!='\0';i++){ if(charset.test(a[i]-'a')) { repeat.set(a[i]-'a'); } charset.set(a[i]-'a'); } for(int j=0;ji;j++) { if(!repeat.test(a[j]-'a')){ couta[j]endl; return 0; } } cerrNo non repeating Characterendl; return 0; On Sun, Sep 11, 2011 at 9:16 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: @neha:can u pls explain ur method? On Sun, Sep 11, 2011 at 9:09 PM, sukran dhawan sukrandha...@gmail.comwrote: ya +1 to neha use bitset concept in c++ On Sun, Sep 11, 2011 at 8:24 PM, Neha Singh neha.ndelhi.1...@gmail.comwrote: for ques 1 use bit manipulation its more efficient -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] MICROSOFT WRITTEN QUESTION-2010
@nishant : your algo takes O(nlogn) time with higher constant behind this. can't we write better than this ? @sairam : will u pls provide implementation logic of u'r idea .. On Mon, Sep 12, 2011 at 12:43 PM, Sairam Ravu ravu...@gmail.com wrote: By merging smaller trees into larger trees we can obtain a much more efficient solution. -- With love and regards, Sairam Ravu I M. Tech(CS) Sri Sathya Sai Institute of Higher Learning To live life, you must think it, measure it, experiment with it, dance it, paint it, draw it, and calculate it -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] C Puzzle
*a = 20; gives seg fault .. because 'a' has not been allocated memory space... On Mon, Sep 12, 2011 at 2:28 PM, Kunal Patil kp101...@gmail.com wrote: Allocate memory for pointer variables. On Mon, Sep 12, 2011 at 11:03 AM, sukran dhawan sukrandha...@gmail.comwrote: run time error first int * a is not assigned some address... so it will be pointing to some garbage value second two pointers of different types without a typecast will result in unpredictable results On Mon, Sep 12, 2011 at 10:25 AM, teja bala pawanjalsa.t...@gmail.comwrote: #includestdio.h main() { int *a; char *c; *a = 20; *c = *a; printf(%d %c,*a,*c); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] MS written
ya from the 2nd quest, we can infer some more ... like the way we represent the date of birth is different than other countries...PIN code,6 digits in INDIA, but may not be same in other countries ... On Mon, Sep 12, 2011 at 7:06 PM, teja bala pawanjalsa.t...@gmail.comwrote: 1-Write test cases for a new student registration form. The registration form captures Student name, email address, Address, Date of birth, Password. It also asks the student to confirm the password. 2-Consider that this application is being deployed as Web application and Desktop application and deployed in multiple countries Is der anything to do with Statement 2 in dis question. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] branching factor when BFS and DFS of a graph is same
@nishaanth: ex: 1 23 4 5 bfs:12345 dfs:12345 branching factor of this tree is not 1 .. On Tue, Sep 13, 2011 at 9:38 AM, nishaanth nishaant...@gmail.com wrote: yes branching factor should be 1. it can be not equal to 1 only for the penultimate node. by penultimate node i mean whose children are the leaves of the tree. rest all cases it should be 1. On Tue, Sep 13, 2011 at 9:24 AM, siddharam suresh siddharam@gmail.com wrote: cant say if there more than one leaf element still both the algo give same result Thank you, Sid. On Tue, Sep 13, 2011 at 7:52 AM, Sundi sundi...@gmail.com wrote: if the dfs and bfs of a graph is same, does it mean that if the branching factor of a graph is one? abcd example: both dfs abd bfs are same here -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] virtual table count
as of my knowledge ... virtual table is created for every class which has either a virtual function or derived from a class which has virtual function.. suppose..B is child of A , if u create an obj for A and called virtual method overloaded in B,then the method in A only be called... So, in ur prog , there are 3 classes and 3 virtual tables ... class Base { public: virtual void method() { printf(in base virtual); } }; class Child : public Base { public: void method() { printf(in child virtual); } }; main() { /* Base *b=new Child(); b-method(); // prints in child virtual... */ Base b; b.method(); // prints in base virtual } On Sat, Sep 10, 2011 at 1:05 AM, ravi maggon maggonr...@gmail.com wrote: let their be two classes A and B having a virtual function. class C derives both class A and B. How many virtual table does class C have? -- Regards Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] tree traversal
in traversing a tree , all we know are conventional tree traversals(pre,in,post).. there r converse tree traversals also... converse pre,in,post... ex: 1 23 45 6 7 converse preorder : 13276254 converse inorder : 7361524 converse postorder : 7635421 On Sat, Sep 10, 2011 at 1:56 AM, amrit harry dabbcomput...@gmail.comwrote: there is one more way called as.. Level order traversing or spiral traversing google this term u will find a new method. On Sat, Sep 10, 2011 at 11:08 AM, ravi maggon maggonr...@gmail.comwrote: can u elaborate its algo On Sat, Sep 10, 2011 at 10:58 AM, Shravan Kumar shrava...@gmail.comwrote: zigzag, level by level ? On Sat, Sep 10, 2011 at 10:48 AM, ravi maggon maggonr...@gmail.comwrote: give some traversal other then pre,in and post order to print all elements of tree? Asked in informatica interview. -- Regards Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- AMRIT -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] plz help for C output
2nd answer is compiler dependent ..i think so .. in gcc it gives garbage values . On Sat, Sep 10, 2011 at 3:51 AM, parag khanna khanna.para...@gmail.comwrote: 1. 100 2. 400...300 3. 4 .. 2 -- Parag Khanna B.tech Final Year NIT,Kurukshetra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Write a program
#includestdio.h int main() { int a[]={3,1,2,1}; int n=4; int top=0,i; for(int i=0;in;i++) { int flag=0; for(int j=0;ji;j++) { if(a[i]==a[j]) { flag=1; break;} } if(!flag) { a[top++] =a[i]; } } n=top; for(int i=0;in;i++) printf(%d,a[i]); } time :O(n^2) space :O(1) extra ... If we hashing , we can do this in O(n) with cost of space O(n) extra ... On Sat, Sep 10, 2011 at 5:21 AM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Write a program to remove duplicate elements from an array by printing them only once? What will be the minimum time and space complexity required for this program? -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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 group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] logical and physical address
physical address:19 bits(10+9) logical address : 15 bits(6+9) On Sat, Sep 10, 2011 at 6:48 AM, ravi maggon maggonr...@gmail.com wrote: we have page table having 64 entries of 10 bits each. and page size is of 512 bytes. tell the no of bits required for physical and logical address. -- Regards Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Circular Left shift
swap k elements form 1 to k and n-k to n respectively... ex: k=3 temp=k; int a[9]= {9,7,6,5,3,23,14,2,4} ; has become {14,2,4,5,3,23,9,7,6}; now swap first k elements with k+1 to 2k elements ...now k=2k+1 , do this step again up to (kn-temp)... at last {5,3,23,14,2,4,9,7,6,} ; Time :O(n) and space O(1). On Sat, Sep 10, 2011 at 7:15 AM, kumar raja rajkumar.cs...@gmail.comwrote: @sarath: I did not get u .Could u please explain it with the example. On 10 September 2011 03:39, sarath prasath prasathsar...@gmail.comwrote: consider this approach.. first reverse the entire array... so it will be.. 4,2,14,23,3,5,6,7,9 and u want to shift k times right so u have to cut the array as n-k and reverse both the sides u ll get it.. so in ur scenario we are reversing upto the element 5 in array and reversing the remaining elements.. hope the complexity is of o(n).. On Sat, Sep 10, 2011 at 3:17 PM, kumar raja rajkumar.cs...@gmail.comwrote: U have used c[3] extra array.It is already known solution. so it is using O(k) space .i want the solution with constant space.. On 10 September 2011 02:08, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Solution :- void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k =0;for ( i=0;i3;i++) c[i]= a[i];for(i=3;i9;i++) a[i-3] =a[i];for(i=9-3;i9;i++) a[i] = c[k++];for(i=0;i9;i++)printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(\n%d,a[i]);} On Sat, Sep 10, 2011 at 2:09 PM, kumar raja rajkumar.cs...@gmail.comwrote: Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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 group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Circular Left shift
@rohit : why don't u have a look at the older posts before replying some thing ...ok .. I'm sorry if u are hurt .. what is the time complexity and space complexity of u'r older post .. On Sat, Sep 10, 2011 at 8:03 AM, Rohit jalan jalanha...@gmail.com wrote: This can also be done: for( i=0; ik;i++) { b[i]=a[i]; } for (;in;i++) { a[i-k]=a[i]; } while((i-k)n) { a[i-k]=b[i]; } But extra array is used here. On Sat, Sep 10, 2011 at 5:30 PM, Rohit jalan jalanha...@gmail.com wrote: How is this one ?? int a[9]={9,7,6,5,3,23,14,2,4} n=9 int *p,*q; p=a; for(q=a;in;q++,i++); ReverseArray(p,q) p=a[0]; q=a[n-1-k] ReverseArray(p,q) p=a[n-k]; q=a[n-1] ReverseArray(p,q) void ReverseArray(int *l,int *r) { int temp; while(lr) { temp=*l; *l=*r; *r=temp l++; r--; } } Thanks Regards, -Rohit On Sat, Sep 10, 2011 at 5:24 PM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: swap k elements form 1 to k and n-k to n respectively... ex: k=3 temp=k; int a[9]= {9,7,6,5,3,23,14,2,4} ; has become {14,2,4,5,3,23,9,7,6}; now swap first k elements with k+1 to 2k elements ...now k=2k+1 , do this step again up to (kn-temp)... at last {5,3,23,14,2,4,9,7,6,} ; Time :O(n) and space O(1). On Sat, Sep 10, 2011 at 7:15 AM, kumar raja rajkumar.cs...@gmail.comwrote: @sarath: I did not get u .Could u please explain it with the example. On 10 September 2011 03:39, sarath prasath prasathsar...@gmail.comwrote: consider this approach.. first reverse the entire array... so it will be.. 4,2,14,23,3,5,6,7,9 and u want to shift k times right so u have to cut the array as n-k and reverse both the sides u ll get it.. so in ur scenario we are reversing upto the element 5 in array and reversing the remaining elements.. hope the complexity is of o(n).. On Sat, Sep 10, 2011 at 3:17 PM, kumar raja rajkumar.cs...@gmail.comwrote: U have used c[3] extra array.It is already known solution. so it is using O(k) space .i want the solution with constant space.. On 10 September 2011 02:08, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Solution :- void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k =0;for ( i=0;i3;i++) c[i]= a[i];for(i=3;i9;i++) a[i-3] =a[i];for(i=9-3;i9;i++) a[i] = c[k++];for(i=0;i9;i++)printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(\n%d,a[i]);} On Sat, Sep 10, 2011 at 2:09 PM, kumar raja rajkumar.cs...@gmail.com wrote: Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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 group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group
Re: [algogeeks] Circular Left shift
@praveen: will u pls explain the second step ... i didn't understand .. On Sat, Sep 10, 2011 at 8:09 PM, praveen raj praveen0...@gmail.com wrote: @amrit... +1 .. With regards, Praveen Raj DCE-IT 3rd yr -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: Write a program
@brijesh: if we don't want to print .. and want to eliminate duplicates ...then ? means..want to store in some place which doesn't have any duplicate for further purpose ... On Sun, Sep 11, 2011 at 12:08 AM, Brijesh brijeshupadhyay...@gmail.comwrote: Watch this video for the concepts of hashing.. http://www.youtube.com/watch?v=KW0UvOW0XIofeature=player_embedded or go through the pdf file -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/cRPUHhf-2tUJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Question -- plz answer
what is M? On Sat, Sep 10, 2011 at 8:10 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: 1.) there is a pyramid with 1 cup at level , 2 at level 2 , 3 at level 3 and so on.. It looks something like this 1 2 3 4 5 6 every cup has capacity C. you pour L liters of water from top . when cup 1 gets filled , it overflows to cup 2,3 equally, and when they get filled , Cup 4 and 6 get water only from 2 and 3 resp but 5 gets water from both the cups and so on. Now given C and M .Find the amount of water in ith cup. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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 group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: MICROSOFT in VJTI mumbai
will u pls provide the answer for 2nd questionfinding the closest pair of points... On Sun, Sep 11, 2011 at 4:48 AM, KK kunalkapadi...@gmail.com wrote: MS visited out col with 2 profiles... written test: 3 different papers: 1 one all objectives 2nd 2 subjective problems... 1 ws to find the closest pair of points... and other was to find the bugs and provide the test cases for the already provided string copying code... then it was followed by 4 coding PI. I dont remember all the Qs but few of them are... LCA generating mnemonics of a phone keypad a DFS or BFS ques removing all the repeated character of string in O(1) space given all would be [A-Z a-z] given an ip address store it const space... i stored it in integer and he was satisfied... Inorder Successor the above Qs were for intern... although they followed the same process for final year people... Finally I made it through :)) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Questions --
what is seed fill algorithm? On Sun, Sep 11, 2011 at 10:45 AM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: 1.) how would you detect mouth in a picture 2.) write iterative version of seed fill algorithm -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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 group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] stack implementation with a constraint
@surender: say the hash table of freq,linked_lis is as follows... 1,2-3-4 2,5-6 3,7-8 pop(7) would decrease the frequency of element 7 means that element has to be added to 2nd key i.e 2,5-6-7 here how do u get the element 7 from hash table as freq is the key element in u'r table? And after getting element u have to add 7 LinkedList linked_list=hash.get(new_freq(7)); linked_list.addLast(7); hash.add(new_freq(7),linked_list); Any better approach? On Fri, Sep 9, 2011 at 11:09 AM, surender sanke surend...@gmail.com wrote: maintain a hash of freq,linked_list linked_list consists of values of that frequency. values with same frequency comes under same list if pop of a particular value is done, then frequency is changed of that number, a new record would be created if required. maintain two values tracking max and second_max, which would track of highest frequency value. let me know ur suggestions surender On Wed, Sep 7, 2011 at 1:03 PM, kARTHIK R k4rth...@gmail.com wrote: The frequency is also stored in the heap right? So to do heapify based on frequency, first you have to spot the element on the heap. That itself will take O(n). [ Heapfying after that takes only O(log n) ] If you use a hashmap and store frequencies, and each time mostFrequent is called, do a linear search on the map, it will have the same complexity. Can anyone come up with a better solution? Karthik R, RD Engineer, Tejas Networks. On Wed, Sep 7, 2011 at 8:49 AM, *$* gopi.komand...@gmail.com wrote: HI, Need logic to implement a stack which should support push , pop , top as well as mostFrequent. mostFrequent should return the most frequently pushed element. I have provided the following logic have one general stack implementation and one Heap .. (Heapify based on frequeny not based on element value) can any one tell me the time complexity for the above logic .. as well as any other good algo for the same. Thx, --Gopi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: Aps
@ gmago: how did u arrive at 16 ... is there any idea in choosing that number .. On Wed, Sep 7, 2011 at 8:44 PM, Don dondod...@gmail.com wrote: Clearly you are sitting still looking at a Route 66 sign. Don On Sep 7, 10:09 am, Mani Bharathi manibharat...@gmail.com wrote: While traveling at uniform speed. U read a two digit no. after one hr the number is reversed order. After another hour the number read is same two digit number. What is the average speed? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Objective Question
@piyush: can u pls elaborate the explanation for option d) ... On Wed, Sep 7, 2011 at 9:07 PM, Piyush Grover piyush4u.iit...@gmail.comwrote: Option a) i didn't understand properly, please elaborate!! Option b) certainly yes. Option c) No (remember, the size of the table is subjective) Option d) yes (use index on the column used in the where clause) On Wed, Sep 7, 2011 at 8:58 PM, Mani Bharathi manibharat...@gmail.comwrote: when is index of a table used? a)when table is less range of values b)when table is used frequently c) when the table is small d)when we use join statement with select and where clause. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/vtHvd8sE1AUJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] computer organization
can any one tell me how a processor supports an external hard disk with huge memory like 1000 TB ? what are the requirements needed to access a data element in that drive? -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] computer organization
To access a data element , processor has to have the address of that data element .. for that, processor should have some register or address bus or some thing like that to fetch the data ...what is the limitation from processor side in extending the memory? and also what is the limitation from processor side in extending RAM size ? like while buying a laptop or a system he gives the limitation like up to 8 GB extendable for RAM...based on what will he give that constraint ? On Thu, Sep 8, 2011 at 9:23 PM, Aditya Virmani virmanisadi...@gmail.comwrote: wht do u mean by tht qn? i didn get it...OS isnt processing any data...it just simply maintains the imaging indexing operations...wht do u mean by managing...? accessing involves use of indexing seeking to the particular data point... On Thu, Sep 8, 2011 at 3:41 PM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: can any one tell me how a processor supports an external hard disk with huge memory like 1000 TB ? what are the requirements needed to access a data element in that drive? -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] sorting..
Randomized quick sort .. even the worst case in this algo is O(n^2) also, this is best sorting algo .. It is showed that nearly 20-25% of time O.S spends its time in sorting.In unix based systems , they are using this algo only .. A random choice will only choose from middle parts half the time. However, this is good enough. Imagine that you are flipping a coin over and over until you get *k* heads. Although this could take a long time, on average only 2*k* flips are required, and the chance that you won't get *k* heads after 100*k* flips is highly improbable. By the same argument, quicksort's recursion will terminate on average at a call depth of only 2(2log2*n*). http://en.wikipedia.org/wiki/Quicksort#Randomized_quicksort_expected_complexity On Thu, Sep 8, 2011 at 11:08 PM, aayush jain ajain...@gmail.com wrote: very easy qus...which is the best sorting tech. n why? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: MICROSOFT
@himansu: how can quicksort selecting kth largest element be done in O(n) time ...I think in worst case it takes O(n^2) time will u pls explain this. On Fri, Sep 9, 2011 at 2:10 AM, Himanshu Neema potential.himansh...@gmail.com wrote: @Dave: Thanks for pointing that out . In that case , if tree is really big and we want to *save memory* : *Algorithm #1 :* 1) Convert tree to a linked list ( Right rotation or left rotation ) : O(n) 2) Quick Select Kth largest element : Worst case O(n^2) ( when tree was already a bst + if we chose pivot to be fist node of linked list everytime) 3) apply second phase of DSW algorithm to recreate the tree. O(n) Time : O(n^2) Space: O(1) Bonus : After fist call tree is perfectly balanced If tree is small , we want to *save run time* : *Algorithm #2 :* 1) Traverse tree , store elements in array : O(n) 2) Quick Select Kth largest element : O(n) Time : O(n) Space : O(n) On Thu, Sep 8, 2011 at 8:58 AM, Dave dave_and_da...@juno.com wrote: @Himanshu: You apparently are assuming that the data is presented in a binary search tree, but the original problem stated that the data is presented in an unordered array. You need to account for the complexity of forming the bst and how much space it will take. Dave On Sep 7, 7:20 pm, Himanshu Neema potential.himansh...@gmail.com wrote: Do reverse inorder and count number of nodes visited, Kth visited node will be Kth largest. Time : O(n) Space : O(1) On Mon, Sep 5, 2011 at 5:16 PM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: @monish: u'rs is correct , time =O(nlogn) Ok but, the constant behind this prog is very huge .. for every number coming in , u maintain minheap and maxheap,and also if the sizes are of mismatch , u delete from minheap and add that to max heap--- here deletion--O(logn),addition--O(logn),this occurs on an average for every 3 elements ... On Mon, Sep 5, 2011 at 2:08 AM, sachin goyal monugoya...@gmail.com wrote: @anup,@sukran ithink u both are right in case of binary search tree... we can traverse and then easily find the value... but in case of heap first we have to create the heap and accordingly apply the algo the create min heap. it will be the complex program so simple is bst just traverse by inorder and compare if anyone has simple solution or any other case then plz tell. On Sun, Sep 4, 2011 at 9:56 PM, monish001 monish.gup...@gmail.com wrote: ALGO: 1. For each element 1 to k: insert in into min-heap 2. for each element k+1 to n delete the root of min-heap and insert this item into the min- heap 3. Finally you have a min-heap of k largest numbers and the root is your answer COMPLEXITY: O(n logn) -Monish On Sep 3, 3:03 pm, teja bala pawanjalsa.t...@gmail.com wrote: //Asked in MS please help me with the coding or Give an algorithm Write code to return the kth largest element in a tree ... function prototype is int fucnkth(node *root,int k) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumar http://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group
Re: [algogeeks] computer organization
@vishwa : Only addr bus!! or opcode also needed to fit in the register think of it .. and 2nd quest(RAM limitation)ans? On Fri, Sep 9, 2011 at 10:06 AM, vishwa vishwavam...@gmail.com wrote: It depends on Address Bus... whether its 32bit or 64 bit... its like can address bus hold that address. On Fri, Sep 9, 2011 at 9:40 AM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: To access a data element , processor has to have the address of that data element .. for that, processor should have some register or address bus or some thing like that to fetch the data ...what is the limitation from processor side in extending the memory? and also what is the limitation from processor side in extending RAM size ? like while buying a laptop or a system he gives the limitation like up to 8 GB extendable for RAM...based on what will he give that constraint ? On Thu, Sep 8, 2011 at 9:23 PM, Aditya Virmani virmanisadi...@gmail.comwrote: wht do u mean by tht qn? i didn get it...OS isnt processing any data...it just simply maintains the imaging indexing operations...wht do u mean by managing...? accessing involves use of indexing seeking to the particular data point... On Thu, Sep 8, 2011 at 3:41 PM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: can any one tell me how a processor supports an external hard disk with huge memory like 1000 TB ? what are the requirements needed to access a data element in that drive? -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: Please provide Code to Find kth Smallest or kth Largest element in unsorted array in liner time ?
@Dave: Can u pls provide the link for median of median algo in O(n) time .. On Wed, Sep 7, 2011 at 11:44 AM, Karan Thakral karanthak...@gmail.comwrote: check the case 63 62 46 71 28 39 43 24 36 12 You have to find 3rd largest 62 your case you will miss 62 in your first iteration On Wed, Sep 7, 2011 at 9:41 AM, Anup Ghatage ghat...@gmail.com wrote: Here is another one. Pardon me if it goes by some other name. Divide the array in K parts. Find the Maximum in each of these parts and store it in an array of size K. Find the Minimum in K to find the K'th max. Total Time Complexity = O ( n + k ) where 0 = k = n -- Anup Ghatage -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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]
@sukran : sieve of erathothenes algo gives only the prime numbers below a number .. How can we find a number's all prime factors using this algo pls explain ... On Wed, Sep 7, 2011 at 5:15 PM, sukran dhawan sukrandha...@gmail.comwrote: sieve of erathothenes algo On Wed, Sep 7, 2011 at 1:36 PM, Yogesh Yadav medu...@gmail.com wrote: prime no has only 2 factors. number itself and 1. On Wed, Sep 7, 2011 at 12:14 PM, aayush jain ajain...@gmail.com wrote: can anybody tell me the code of find the prime no. and after finding prime no. find its prime factore using linkes list?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: EOF
#includeiostream #includefstream using namespace std; int main() { ifstream stream1(D:\\file1.txt); char a[80]; if(!stream1) { cout While opening a file an error is encountered endl; } else { cout File is successfully opened endl; } while(!stream1.eof()) { stream1 a; cout a endl; } return(0); } OR string line; getline(stream1,line); On Wed, Sep 7, 2011 at 7:51 PM, Anurag Gupta anurag.gupta...@gmail.comwrote: @ kunal I was attempting this problem: http://www.spoj.pl/problems/NHAY/ here,input size of haystick is not limited so,can you tell me how to read the haystick. On Sep 7, 12:06 am, Kunal Patil kp101...@gmail.com wrote: If I understand question correctly, then just read as many characters as you can using standard string functions. (like fgets n all related) Output these all characters in a file. Iterate until you have read all the characters and go on appending what you have read to file. You intended to ask something else? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] MICROSOFT
@Anup: how can u say that the hash function used is a%10 That is internal , not in the hands of user .. Usually while inserting a value in Hash Table , we don't give the size of the table ahead ... It decides some size, and implements.. when we cross the assumed size,then it again gives some more memory so that all the operations are optimum (less collisions). On Sun, Sep 4, 2011 at 5:32 PM, Anup Ghatage ghat...@gmail.com wrote: Sid, I'm afraid a hash table won't help much. Given the elements as follows: { 10,20,30,10,20,20,30,30,30,30,10 } All of them will be hashed into the 0'th cell for a % 10 hash function, and then probably the overflow will be handled by chaining. So that will be governed by m^2 in worst case. So the algorithm would be O( m^2 log m ) just to populate the hash and find the frequencies. -- Anup Ghatage -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Tejas networks
http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm For Q4): Dijkstra is the best one .. as there is no root for negative weight edge ... Floyds algo gives all pairs shortest path with negative weight edges also .. so that doesn't work in this situation ... On Sun, Sep 4, 2011 at 6:22 PM, aditya kumar aditya.kumar130...@gmail.comwrote: q4) floyds algorithm for shortest path . On Sun, Sep 4, 2011 at 5:41 PM, sukran dhawan sukrandha...@gmail.comwrote: for q3 :either both inorder and preorder traversal shud be stored or inorder and postorder shud be stored On Sun, Sep 4, 2011 at 2:54 PM, sukran dhawan sukrandha...@gmail.comwrote: -- Forwarded message -- From: sukran dhawan sukrandha...@gmail.com Date: Sun, Sep 4, 2011 at 2:53 PM Subject: Re: [algogeeks] Tejas networks To: algogeeks@googlegroups.com reverse a linked list void reverse(struct node ** head) { struct node * last,*temp; last = *head; while(last-next != null) last = last-next; while(*head != last) { temp = *head; *head = (*head)-next; temp-next = last-next; last-next = temp } } On Sun, Sep 4, 2011 at 2:46 PM, Anup Ghatage ghat...@gmail.com wrote: Could you please give an example for question 3? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: character count in array
@mohit: that will modify the original array and also time =O(nlogn)... On Mon, Sep 5, 2011 at 1:01 AM, Ankuj Gupta ankuj2...@gmail.com wrote: @mohit: that will modify the original array On Sep 4, 6:40 pm, sarath prasath prasathsar...@gmail.com wrote: here is my approach where i left the non repeating characters as it is and done some good code.. char * runlengthencode(char* str,int size) { int i,j,flag=0; for(i=0,j=1;str[i]str[j]jsize;i++,j++) { while(str[i]==str[j]) { j++; flag=1; } if(flag) { j=j-1; str[i+1]=48+(j-i+1); flag=0; i=j; j++; } } return str; } On Sat, Sep 3, 2011 at 6:54 PM, Aman Kumar amanas...@gmail.com wrote: Hiii if array is given like this arr[]=aabcabbcdeadef convert this array into like arr[]=a4b3c2d2e2f1 how can we do this can we do it with space complexity O(1). reply asap -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: Stack problem
+1 sandeep @don: u'r sol is correct , but if the number of elements are very huge and the updated min is long numbers , then we are storing the min in each element ... its waste of memory ... if the # elements are less, then this is good sol.. On Mon, Sep 5, 2011 at 1:02 AM, Nitin Garg nitin.garg.i...@gmail.comwrote: Don's solution is correct. At each push() operation, you update the value of min element upto that depth in stack. Can be illustrated with the following example - stack = {} push(2) stack = {(2,2)} push(3) stack = {(3,2),(2,2)} push(1) stack = {(1,1),(3,2),(2,2)} where b in tuple (a,b) represents the min value upto current depth in stack. pop() and min() are straight forward. On Mon, Sep 5, 2011 at 12:48 AM, Don dondod...@gmail.com wrote: Each element in the stack will contain not only its own value, but the min value at that depth of the stack: struct stackItemStruct { int value; int min; struct stackItemStruct *next; }; typedef struct stackItemStruct stackItem; class stack { public: stack(); void push(int v); int pop(); int min(); private: stackItem *_stack; }; stack::stack() { _stack = 0; } void stack::push(int v) { stackItem newItem = new stackItem; newItem-value = newItem-min = v; if (_stack (_stack-min v) ) newItem-min = _stack-min; newItem-next = _stack; _stack = newItem; } int stack::pop() { int result = 0; if (_stack) { result = _stack-val; stackItem *tmp = _stack; _stack = tmp-next; delete tmp; } return result; } int stack::min() { return _stack ? _stack-min : 0; } On Sep 4, 12:08 pm, Sangeeta sangeeta15...@gmail.com wrote: How would you design a stack which,in addition to push and pop,also has a function min which returns the minimum element?push,pop and min should all operate in O(1) time -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Nitin Garg Personality can open doors... but only Character can keep them open -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: MICROSOFT
@monish: u'rs is correct , time =O(nlogn) Ok but, the constant behind this prog is very huge .. for every number coming in , u maintain minheap and maxheap,and also if the sizes are of mismatch , u delete from minheap and add that to max heap--- here deletion--O(logn),addition--O(logn),this occurs on an average for every 3 elements ... On Mon, Sep 5, 2011 at 2:08 AM, sachin goyal monugoya...@gmail.com wrote: @anup,@sukran ithink u both are right in case of binary search tree... we can traverse and then easily find the value... but in case of heap first we have to create the heap and accordingly apply the algo the create min heap. it will be the complex program so simple is bst just traverse by inorder and compare if anyone has simple solution or any other case then plz tell. On Sun, Sep 4, 2011 at 9:56 PM, monish001 monish.gup...@gmail.com wrote: ALGO: 1. For each element 1 to k: insert in into min-heap 2. for each element k+1 to n delete the root of min-heap and insert this item into the min- heap 3. Finally you have a min-heap of k largest numbers and the root is your answer COMPLEXITY: O(n logn) -Monish On Sep 3, 3:03 pm, teja bala pawanjalsa.t...@gmail.com wrote: //Asked in MS please help me with the coding or Give an algorithm Write code to return the kth largest element in a tree ... function prototype is int fucnkth(node *root,int k) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] convert a word into a palindrome with minimum addition of letters to it
@hemank: sukran's prog works .. int main() { char str[]=Nitan; int n=strlen(str); for(int i=0;in/2;i++) { str[n-1-i] = str[i]; } printf(%s,str); } ouput :NitiN On Mon, Sep 5, 2011 at 4:39 AM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: #includeconio.h #includestdio.h #includestring.h #includeiostream.h void substr(char *dst,char *src, size_t start, size_t stop) { int count = stop - start; sprintf(dst, %.*s, count, src + start); } int ispalin(char *k) { int i1=0; int i2=strlen(k)-1; while(i2i1) { if(k[i2]!=k[i1]) return 0; i1++; i2--; } return 1; } void makepalin(char *t) { char s[50]; char *p=t; int i=0; char k[50]; while (!ispalin(p)) { s[i]=p[0]; substr(p,p,1,(strlen(t))); i++; } strcpy(k,s); strcat(k,p); strcat(k,strrev(s)); printf( palin is %s ,k); } int main( ) { char s[50]; gets(s); makepalin(s); getch(); } On Mon, Sep 5, 2011 at 10:46 AM, hemank lamba hemankla...@gmail.comwrote: @Sukran: This wont work for the test case like this for example the word is Nitan: then the word ur algorithm will create is Nitanatin hence the number of additions =4 but ideal case i would be nitatin : where number of additions is only 2. On Sun, Sep 4, 2011 at 11:11 PM, sukran dhawan sukrandha...@gmail.comwrote: On Sun, Sep 4, 2011 at 11:11 PM, sukran dhawan sukrandha...@gmail.comwrote: for(i0;in/2;i++) { a[n-1-i] = a[i]; } will this work ? where n is the length os string On Sun, Sep 4, 2011 at 7:54 PM, learner nimish7andr...@gmail.comwrote: Given a word, convert it into a palindrome with minimum addition of letters to it. letters can be added anywhere in the word. for eg if yahoo is given result shud be yahohay. Thanks -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: character count in array
+1 rahul and +1 ankuj On Sat, Sep 3, 2011 at 11:37 AM, icy` vipe...@gmail.com wrote: Just use a hash to count frequency of something; e.g. in ruby: ar= %w(a a b c a b b c d e a d e f) freq=Hash.new(0) ar.each {|c| freq[c]+=1} p freq #output #{a=4, b=3, c=2, d=2, e=2, f=1} you could only do it in place in O(1) only if your input array is already 2*(number of all possible characters) size, but you didnt mention size of input array. For example, what if input was just [a,b,c,d,e] ? The size is 5.You cant just convert the input into [a,1,b,1,c,1,d,1,e,1] without increasing the size to 10. So hash is the better method. On Sep 3, 11:04 am, Ankuj Gupta ankuj2...@gmail.com wrote: if for all inputs you array remains of same size we can take it as constant space On Sep 3, 7:49 pm, rajul jain rajuljain...@gmail.com wrote: @ankuj just want to clarify that in hashing method we require array of fixed size let say arr[26] , so is it considered as constant space or not? On Sat, Sep 3, 2011 at 8:02 PM, siddharam suresh siddharam@gmail.comwrote: sol already posted please search old thread Thank you, Sid. On Sat, Sep 3, 2011 at 8:01 PM, Ankuj Gupta ankuj2...@gmail.com wrote: If we take our input to be characters a-z ans A-Z then we require fixed space which can be treated as O(1). On Sep 3, 7:10 pm, teja bala pawanjalsa.t...@gmail.com wrote: this 'll work if u i/p the string in dis manner aaabbcc(consecutive same) a3b2c2 #includestdio.h #includeconio.h main() { int x=1,i=0; char a[100]; gets(a); while(a[i]!='\0') { while(a[i]==a[i+1]) { x++; i++; } printf(%c%d,a[i],x); x=1; i++; } getchar(); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] explain the putput of this program
output 1 because it is pointing to first position of the array.. 5 is because (*h)++; --- here it is adding sizeof(int) to 1... if u make h as short type , then it will add 2 to 1.. i don't know why exactly .. On Sat, Sep 3, 2011 at 2:36 PM, Ankit Sablok ankitsablok19091...@gmail.comwrote: #includeiostream #includecstdio #includecctype #includecstdlib #includecstring using namespace std; int main() { int **h; int a[2][2]={1,2,3,4}; h= (int **)a; int i,j; printf(\n%d,*h); (*h)++; printf(\n%d,*h); getchar(); getchar(); return 0; } gives an output 1 and 5 why? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Pattern Matching
There is Pattern class Java and also same like function in C++ http://leepoint.net/notes-java/data/strings/40regular_expressions/26pattern-matcher.html On Sat, Sep 3, 2011 at 2:41 PM, Dheeraj Sharma dheerajsharma1...@gmail.comwrote: for '?' u just increment ur pointer(which is returned by previous one.) by 1.. On Sun, Sep 4, 2011 at 12:09 AM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: for * it can be like.. for example we have any string say *ab*c*de* it is composed of three strings ..that has to be searched.in that sequece in only..which means..first ab would appear..then c ..then de.. first search for pattern ab in string..using pattern matching function.. then search for c in the remaining string(which can be found..using the pointer returned by first) then search for de in the remaining string(which can be found..using the pointer returned by second) the string b/w first and last pointer would be the result.. Correct me if am wrong.. On Sat, Sep 3, 2011 at 12:10 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: Implement a function that receive a string S and a pattern containing wild characters ( * and ? only) in string P. Function return true if S matches the pattern P. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] MICROSOFT
+1 siddarth On Sat, Sep 3, 2011 at 2:54 PM, Dheeraj Sharma dheerajsharma1...@gmail.comwrote: yeah..we it works for +ve number..within some specified range..it was alternate to O(nlogn) solution..if range is known On Sun, Sep 4, 2011 at 12:07 AM, mohit verma mohit89m...@gmail.comwrote: @dheeraj - for count sort we need to know the range the numbers are in. Otherwise how will u initialize array keeping count? On Sun, Sep 4, 2011 at 12:03 AM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: count sort in reverse order would help i guess :) On Sat, Sep 3, 2011 at 11:49 PM, mohit verma mohit89m...@gmail.comwrote: Ohh my bad. the complexity should be O(nlogn) + O(mlogm) +O(m) = O(tlogt) where t=max(m,n) On Sat, Sep 3, 2011 at 11:46 PM, mohit verma mohit89m...@gmail.comwrote: create a binary search tree by scanning the whole array and if the value already exists increase count field in that node O(nlogn). Now traverse the tree in any order by creating another tree with kery - count. O(nlogn). Doing reverse inorder traversal print value field of each node count number of times O(n). overall complexity - O(nlogn)+O(nlogn)+O(n) = O(nlogn). On Sat, Sep 3, 2011 at 11:16 PM, Siddhartha Banerjee thefourrup...@gmail.com wrote: perhaps we can make it O(mlogm), m= no of distinct elements... just create a hash table and store the count of the number of time elements occur... O(n), now sort the m elements and proceed as above... it is obviously not possible to do it faster than O(mlogm), where m = no of distinct elements... so order = O(n+mlogm)=O(mlogm)(???, assuming m!n) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *MOHIT VERMA* -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: whats d problem wid using gets?
gets is deprecated ... that's why gcc gives warning... On Sun, Sep 4, 2011 at 12:46 AM, sukran dhawan sukrandha...@gmail.comwrote: ya +1 to anup.tats why when u use gets() in gcc i reports a warning On Sun, Sep 4, 2011 at 8:40 AM, Anup Ghatage ghat...@gmail.com wrote: I had once read somewhere that they had used gets() during the first compilations of unix, and it used to always crash for some test cases. So after that they stopped using it and alerted everyone of the problem.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] c problem
@priya: compiler thinks that a++; statement is correct... But for that to do...' a' should be of type modifiable ... so it gives error saying that If u want to modify , that should be lvalue, so lvalue required On Sun, Sep 4, 2011 at 2:27 AM, Yogesh Yadav medu...@gmail.com wrote: @Priya: Because a is *unmodifiable* LValue. When we are using a=a+1(a++) , this means that we are changing the *base address* of array a[], and that can not be possible due to Library files. On Sun, Sep 4, 2011 at 11:49 AM, priya ramesh love.for.programm...@gmail.com wrote: @yogesh: Thanks a lot for the explaination. Good one indeed. Can you plz tell me y the compiler says lvalue required for the statement a++ when a is an lvalue?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Padding....
struct data { char a; int b; }__attribute__((packed)); This is way to get the actual size of struct without any padding http://tuxsudh.blogspot.com/2005/05/structure-packing-in-gcc.html On Sun, Sep 4, 2011 at 2:38 AM, Debabrata Das debabrata.barunhal...@gmail.com wrote: @Dheeraj, Thanks for the link @Anshul Considering double to be alligned as a 4 byte boundary.. structc_tag c 1 byte padding 1 byte padding 1 byte padding 1 byte double 8 byte int4 byte whole structure is multiple of 4 so no padding required. structd_tag 8 byte for double 4 byte for int 1 byte for char padding 3 byte last 3 byte padding for structure size to be multiple of 4 Correct me if am wrong On Sun, Sep 4, 2011 at 2:40 AM, Anshul AGARWAL anshul.agarwa...@gmail.com wrote: #include stdio.h // structure C typedef struct structc_tag { charc; double d; int s; } structc_t; // structure D typedef struct structd_tag { double d; int s; charc; } structd_t; int main() { printf(sizeof(structc_t) = %d\n, sizeof(structc_t)); printf(sizeof(structd_t) = %d\n, sizeof(structd_t)); return 0; } plz explain the output ?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] unique key
There can be any # candidate keys but only one primary key in a table.. every candidate key can give u unique row in that table deciding which key should be the primary depends on some parameters like .. --length of the key .. --# of attributes in that key .. --frequency of using that key for u'r queries ..etc .. On Sun, Sep 4, 2011 at 2:47 AM, sarath prasath prasathsar...@gmail.comwrote: what is the difference in this.. we have a table which has one primary key and one unique key with not null constraint.. so r they equal... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] puzzle
+1 amit.. On Sun, Sep 4, 2011 at 4:15 AM, tarun kumar taruniit1...@gmail.com wrote: can we open the door twice(with the condition that once the door is opened switch can't be manipulated).? if not ,It is riddle rather an algorithmic question and the above written answer seems to be right. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: subarray wid sum=k
here is the solution of O(n) ... int maxSubArray(int array[],int n) // n is the length of the given array ... { int left=0,right=0; // these are to indicate the subscript range on which we got the max array .. int temp_left=0; int max=0,sum=0; for(int i=0;in;i++) { sum += array[i]; if(maxsum) { max=sum; right=i; left=temp_left; } if(sum0) // if the sum is negative .. { sum=0; temp_left=i+1; } } return max; } This'll work On Sun, Sep 4, 2011 at 4:54 AM, tarun kumar taruniit1...@gmail.com wrote: the problem can be solved in O(n) time without using extra space .using the algorithm of finding the subarray of maximum sum in a given array.(time complexity is O(n) and no extra space). here you just have to stop when you find sum equal to k. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: subarray wid sum=k
In my previous post .. if all the array elements are negative .. then it returns zero and this is also satisfiable .. On Sun, Sep 4, 2011 at 7:02 AM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: here is the solution of O(n) ... int maxSubArray(int array[],int n) // n is the length of the given array ... { int left=0,right=0; // these are to indicate the subscript range on which we got the max array .. int temp_left=0; int max=0,sum=0; for(int i=0;in;i++) { sum += array[i]; if(maxsum) { max=sum; right=i; left=temp_left; } if(sum0) // if the sum is negative .. { sum=0; temp_left=i+1; } } return max; } This'll work On Sun, Sep 4, 2011 at 4:54 AM, tarun kumar taruniit1...@gmail.comwrote: the problem can be solved in O(n) time without using extra space .using the algorithm of finding the subarray of maximum sum in a given array.(time complexity is O(n) and no extra space). here you just have to stop when you find sum equal to k. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@gmail.com -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] MICROSOFT
traverse the tree and place the elements in an array --O(n) take a pivot element and make sure that all the elements which are greater than pivot is on right side and lesser than pivot are on left side-O(n) if # elements on right side is larger than k , then take a pivot in right side ..and repeat the same until # elements on right side is k-1 ---pivot is k th largest element else go to left side and do on left for k-right.size(). Time:O(nlogn) ... but the constant is low ..like quick sort .. On Sun, Sep 4, 2011 at 5:12 AM, mohit verma mohit89m...@gmail.com wrote: it would be better if we insert values in array in while loop and then outside call makeheapk() and then return topheap(); this will reduce the heap making complexity. On Sun, Sep 4, 2011 at 2:29 PM, mohit verma mohit89m...@gmail.com wrote: int funkth(node *root,int k) { queuenode * q; q.insert(root); node *temp; while(!q.empty()) { temp=q.top(); q.pop(); if(temp-l) q.insert(temp-l); if(temp-r) q.insert(temp-r); makeheapk(temp-value); //make minheap of size k } return topheap(); //return top element of heap } any corrections please? On Sun, Sep 4, 2011 at 10:20 AM, sukran dhawan sukrandha...@gmail.com wrote: for bst step 1 :count the number of nodes in a tree step2: traverse in inorder.after each node visit decrement n. if n == k then the result On Sun, Sep 4, 2011 at 12:33 AM, teja bala pawanjalsa.t...@gmail.comwrote: //Asked in MS please help me with the coding or Give an algorithm Write code to return the kth largest element in a tree ... function prototype is int fucnkth(node *root,int k) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *MOHIT VERMA* -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: subarray wid sum=k
@shasank; i don't think it works... prefix sum means u are taking sum from starting index ... sub array can be from middle ..It is like max sub array in an array problem ...O(n^2) algo is available in Cormen text book .google it . On Fri, Sep 2, 2011 at 6:05 AM, manish kapur manishkapur.n...@gmail.comwrote: r u sure space used is O(n)? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: subarray wid sum=k
we can do this without taking O(n) space .. but time is O(n^2) as in i already mentioned where the solution is ... On Fri, Sep 2, 2011 at 7:35 AM, Neha Singh neha.ndelhi.1...@gmail.comwrote: @Shashank : I think the sub array need not start from the the index 0. For eg: If the array is of size 10, then the sub array can be from index 3 to 7. Here is my solution : Given : int arr[size] , int sum 1. Take an array prefix_sum[size] 2. int temp=0;prefix_sum[0]=0; for(int i=0;isize;i++) { temp+=arr[i]; prefix_sum[i]=temp; } 3. for (int i=0;isize;i++) for(int j=0;j=i;j++) { if(prefix_sum[i]-prefix_sum[j]+arr[j] == sum) printf(%d %d,i,j); // sub array from index i to j is the required sub array } Time : O(n^2) Space : O(n) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: subarray wid sum=k
we have to consider 3 cases .. 1) that sub array can be in first half 2) that sub array can be in second half 3) that sub array can be in middle . On Fri, Sep 2, 2011 at 7:56 AM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: we can do this without taking O(n) space .. but time is O(n^2) as in i already mentioned where the solution is ... On Fri, Sep 2, 2011 at 7:35 AM, Neha Singh neha.ndelhi.1...@gmail.comwrote: @Shashank : I think the sub array need not start from the the index 0. For eg: If the array is of size 10, then the sub array can be from index 3 to 7. Here is my solution : Given : int arr[size] , int sum 1. Take an array prefix_sum[size] 2. int temp=0;prefix_sum[0]=0; for(int i=0;isize;i++) { temp+=arr[i]; prefix_sum[i]=temp; } 3. for (int i=0;isize;i++) for(int j=0;j=i;j++) { if(prefix_sum[i]-prefix_sum[j]+arr[j] == sum) printf(%d %d,i,j); // sub array from index i to j is the required sub array } Time : O(n^2) Space : O(n) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@gmail.com -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: Need algorithm asap
@shasank: how come the valid bipartition s are n/2.. those should be at least n right? ex: {1,2,3} {1},{2,3} --{1,2},{3} --{},{1,2,3} If this is correct , then for printing sake it takes O(n^2) . correct me if I'm wrong. On Fri, Sep 2, 2011 at 2:48 PM, WgpShashank shashank7andr...@gmail.comwrote: Piyush Has Correct Idea, If You Have N elements in Set/Array You Will Have Maximum 2^n Subsets (Power Set), Now Problem Reduced to generate the all such subsets , it will take O(2^n*n ) time , Now number of Valid Bipartitions are exactly n/2 . Note: Power Set includes 0 as well Correct me missed something or provicde any other better approach ? Shashank Mani Computer Science Birla Institute of Technology,Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/UUb4EWQof1gJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] activation record
The activation records for all of the active functions are stored in the region of computer memory called *the stack*. A good way to remember this is to think of the stack as ``the region of memory where all the activation records are stacked''. Allocation and deallocation of activation records is always done in a stack structure manner : TRUE On Fri, Sep 2, 2011 at 2:53 PM, rajeev bharshetty rajeevr...@gmail.comwrote: http://www.enel.ucalgary.ca/People/Norman/enel339fall2000/activ_rec/ False On Fri, Sep 2, 2011 at 10:13 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: what are activation records?? On Fri, Sep 2, 2011 at 9:00 PM, sukran dhawan sukrandha...@gmail.comwrote: true On Fri, Sep 2, 2011 at 7:44 PM, priya ramesh love.for.programm...@gmail.com wrote: Allocation and deallocation of activation records is always done using a stack (LIFO) structure. True or false?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Rajeev N B http://www.opensourcemania.co.cc *Winners Don't do Different things , they do things Differently* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] dictionary
WHY trie? any reason ? Dictionary means not only to save efficiently and also we have to get back in almost O(1) time .. I think Hash Table is best suited for this... Or any way we have Dictionary Data Structure in Java.. On Fri, Sep 2, 2011 at 3:23 PM, Yuchen Liao lycdra...@gmail.com wrote: Trie is good, but I prefer inverted index. On Fri, Sep 2, 2011 at 1:38 PM, somya mishra somya.bvm...@gmail.comwrote: trie On Sat, Sep 3, 2011 at 12:05 AM, sukran dhawan sukrandha...@gmail.comwrote: trie data structure On Fri, Sep 2, 2011 at 11:21 PM, Aman Kumar amanas...@gmail.com wrote: Hii Which data structures can be used for implementation for dictionary? which is best/good among them? provide good link for that. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- from Yuchen Liao via Gmail -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: Find Max Sum Value Pairs
@pitush: pls explain your logic once On Fri, Sep 2, 2011 at 4:09 PM, Piyush Grover piyush4u.iit...@gmail.comwrote: if I have understood the question correctly then: a[n-1] + b[i] a[j] + b[i] for all 0 = j n-1 and a[j] + b[n-1] a[j] + b[i] for all 0 = i n-1 therefore, i = j =n-1; count = 1; S[0] -- (a[n-1], b[n-1]) p = a[n-1] + b[n-2]; q = a[n-2] + b[n-1] while(count n){ if(p q){ j--; S[count++] -- (a[n-1], b[j]); }else{ i--; S[count++] -- (a[i], b[n-1]); } p = a[n-1] + b[j-1]; q = a[i-1] + b[n-1]; } Time complexity: O(n) : http://ideone.com/FXfVj On Fri, Sep 2, 2011 at 10:05 PM, WgpShashank shashank7andr...@gmail.comwrote: @Dave Correct , Missed to Provide the Correct Time Complexity in Worst Case it Will be O(N^2) , as we need to find out n such maximum pair , will think about O(N0) Algo, if able to do it, will post the Algo here Thanks Shashank Mani Computer Science Birla Institute of Technology,Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/a14Pj22tbJgJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Network Question
all the addresses which come under second addr will also come under first Can those 2 be exist in same LAN ? If yes , how can router decides to which subnet it has to pass through the incoming packet .. On Fri, Sep 2, 2011 at 6:36 PM, aditya kumar aditya.kumar130...@gmail.comwrote: their wont be any conflict in ip address . coz within dhcp assigns ip adsress from the pool of available address and within the n/w (LAN) we need to have unique ip address bt across the n/w (LAN) we can use same ip from the pool of ip addresses . On Sat, Sep 3, 2011 at 1:56 AM, sagar pareek sagarpar...@gmail.comwrote: It is urgent to get the answer thats why i m posting network question here... searching on net is not working HI !! I stuck on a question related to VLSM Suppose we have two subnets as 10.0.1.0/24 valid ip address can be 10.0.1.2 and 10.0.1.0/26 here also valid ip address can be 10.0.1.2 now suppose we are using these two subnets in a LAN and having this ip (10.0.1.2) in both the subnets then is there any IP conflict will happen or not? -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] pattern matching
wht is KMP? pls give some info .. On Fri, Sep 2, 2011 at 11:59 PM, sukran dhawan sukrandha...@gmail.comwrote: start drom brue force.then interviewer will ask u to optimize it.then refine it.dont jum into the optimised soln directly On Sat, Sep 3, 2011 at 12:35 AM, Aman Kumar amanas...@gmail.com wrote: Hiii Friends ,if pattern matching question is asked in the interview , we should answer brute force(with some optimization) approach or use ADVANCED algorithm like KMP? I am very much confused regarding this because in on blog i have read that we should not use advanced data structure in interview. help me out. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: subarray wid sum=k
ya , it can start from middle ...but continuous right .. On Fri, Sep 2, 2011 at 4:34 PM, WgpShashank shashank7andr...@gmail.comwrote: Yes Neha, I Never Said That SubArray has to be Started from 0th index,else What Will be the advantage of this saying subarray anyways, here O(N) time O(N) space solution int prefix_sum = 0; hash_mapint,int find_subarray; int start_index = -1, end_index = -1; for (int i = 0,;i n; ++i) { if (a[i]==k) { start_index = i; end_index = i; break; } prefix_sum += a[i]; if (prefix_sum==k) { start_index = 0; end_index = i; break; } if (find_subarray.find(prefix_sum) == k) { find_subarray[prefix_sum] = i; } else { start_index = find_subarray[prefix_sum] + 1; end_index = i; break; } } if (start_index != -1) { cout Zero sum subarray found. Start index : start_index . End Index: end_index \n; } -2 1 -2 5 -1 4 -6 -7 k=9 subarray will be -2 5-1 4 -6 @all Whats Say ? Shashank Mani Computer Science Birla Institute of Technology,Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/SNpbdnf1PTMJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: Network Question
I didn't understand so subnet 10.0.1.0/26 cannot communicate with 10.0.1.0/24 having same ip node more over packet sent within 10.0.1.0/24 will reach 10.0.1.0/26 not to the nodes on the same network .. so 10.0.1.0/24 can communicate with 10.0.1.0/26 but cannot communicate within itself .. what do u mean? In a n/w all the IP 's should be unique ? can there exist like this .. pls explain me detail y ... On Sat, Sep 3, 2011 at 1:09 AM, Vengadanathan fantastic.n...@gmail.comwrote: ya both the subnet can exisit in the same network , but problem is lack of communication between the two subnets ,because in routing table of the router the record for 10.0.1.0/26 will be first then record for 10.0.1.0/24 will be , so 10.0.1.0/26 will be given first preference , so subnet 10.0.1.0/26 cannot communicate with 10.0.1.0/24 having same ip node more over packet sent within 10.0.1.0/24 will reach 10.0.1.0/26 not to the nodes on the same network .. so 10.0.1.0/24 can communicate with 10.0.1.0/26 but cannot communicate within itself .. On Sep 3, 9:38 am, bharatkumar bagana bagana.bharatku...@gmail.com wrote: all the addresses which come under second addr will also come under first Can those 2 be exist in same LAN ? If yes , how can router decides to which subnet it has to pass through the incoming packet .. On Fri, Sep 2, 2011 at 6:36 PM, aditya kumar aditya.kumar130...@gmail.comwrote: their wont be any conflict in ip address . coz within dhcp assigns ip adsress from the pool of available address and within the n/w (LAN) we need to have unique ip address bt across the n/w (LAN) we can use same ip from the pool of ip addresses . On Sat, Sep 3, 2011 at 1:56 AM, sagar pareek sagarpar...@gmail.com wrote: It is urgent to get the answer thats why i m posting network question here... searching on net is not working HI !! I stuck on a question related to VLSM Suppose we have two subnets as 10.0.1.0/24 valid ip address can be 10.0.1.2 and 10.0.1.0/26 here also valid ip address can be 10.0.1.2 now suppose we are using these two subnets in a LAN and having this ip (10.0.1.2) in both the subnets then is there any IP conflict will happen or not? -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumar http://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: Closest ancestor of two nodes
For BST it is easy ...it can be find in O(logn) time .. when ever we find that the direction we are searching for x and y are different, that node is the common ancestor ...no need to find either x or y where the nodes are... what about binary tree ? how do we search an element in binary tree efficiently ? On Sat, Sep 3, 2011 at 12:44 AM, rajul jain rajuljain...@gmail.com wrote: @anika this solution only works for BST On Mon, Aug 15, 2011 at 4:20 PM, Anika Jain anika.jai...@gmail.comwrote: node *common_ancestor(node *root, node **prev, int x,int y) { if(root-a==x || root-a==y) return *prev; else if(root-a x root-a y) { prev=root; return common_ancestor(root-l,prev, x,y); } else if(root-a x root-a y) { prev=root; return common_ancestor(root-r,prev, x,y); } else { prev=root; return *prev; } } with call as node *prev=NULL; common_ancestor(root,prev,x,y); On Sun, Aug 14, 2011 at 10:08 PM, Yasir yasir@gmail.com wrote: Guys, How about the below mentioned implementation? The only assumptions is that nodes should exist in the tree. (will fail if one node exists and another doesn't) static Node LCA(Node root, int d1, int d2){ if(root==null) return root; if(root.left!=null ( root.left.data == d1 || root.left.data==d2 ) ) // both nodes exists in left sub-tree return root; if(root.right!=null ( root.right.data == d1 || root.right.data==d2) ) // both nodes exists in right sub-tree return root; Node ltree = LCA(root.left, d1, d2); //check recursively in left subtree Node rtree = LCA(root.right, d1, d2);// check recursively in right subtree if(ltree!=null rtree!=null)// One node in left another in right return root; return (ltree==null)?rtree:ltree; } Just to mention that, closest ancestor of 54 OR 49 would be 3 in the following tree: 3 \ 4 /\ 5 8 / 9 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/24JUUQsBHvIJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: finding duplicates
This works for numbers with in 2^32 for 32-bit word length systems .. int i=0; for(int j=0;jn;j++) { if((i 1Array[j])0) Array[j] is duplicate .. else i |= (1Array[j]); } On Wed, Aug 31, 2011 at 7:15 PM, Gene gene.ress...@gmail.com wrote: Sorting is fine but destroys the input, which often hurts, especially in version 2. Unless you use fancy probing techniques, number of comparisons is O(n). If you're not sorting, then you need a set data structure of some form. If the numbers are small integers, an array of bits is good. Set respective bits as numbers are found, and print those found with bit already set. The number of times 2 numbers need to be compared for equality is _zero_. If the numbers are not small enough, then a hash table is usually the best set data structure. Number of equality tests is O(n) expected. Binary trees are only 3rd best, and they should be auto-balancing. Comparisons mumber O(n log n). On Aug 30, 2:49 pm, Dave dave_and_da...@juno.com wrote: @Kamakshii: With O(1) extra space, it can be done with O(n) comparisons. Do a radix sort on the input (no comparisons), and then check adjacent numbers for equality. Dave On Aug 30, 1:34 pm, Kamakshii Aggarwal kamakshi...@gmail.com wrote: develop an algorithm to find duplicates in a list of numbers without using a binary tree..if there are n distinct numbers in the list ,how many times must two numbers be compared for equality in your algorithm?what if all numbers are equal? -- Regards, Kamakshi kamakshi...@gmail.com- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Find Max Sum Value Pairs
@Mac: It gives us the first largest pair but need not all n pairs .. ex: A=1 1 3 4 B=1 2 3 4 pairs : (4,4),(4,3),(3,3),(2,4) . On Thu, Sep 1, 2011 at 4:57 AM, MAC macatad...@gmail.com wrote: since its sorted , cant we just take last (largest if assedning) elements of each and return o(1) .. (since +ve we can do so i guess) On Thu, Sep 1, 2011 at 2:15 PM, Navneet Gupta navneetn...@gmail.comwrote: Given two sorted positive integer arrays A(n) and B(n), we define a set S = {(a,b) | a in A and b in B}. Obviously there are n2 elements in S. The value of such a pair is defined as Val(a,b) = a + b. Now we want to get the n pairs from S with largest values. need an O(n) algorithm. -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- thanks --mac -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: String Problem
bool interleave(string s1,string s3) { char *str1=(char*)s1.c_str(); char *str3=(char*)s3.c_str(); int pos=-1; for(int i=0;istrlen(str1);i++) { if(posfindPosition(str1[i],str3)) { pos=findPosition(str1[i],str3); } else {flag=1; break;} } if(flag==1) print NOT } Do the same for string2 also ... This works only for non duplicated strings On Thu, Sep 1, 2011 at 5:19 AM, vikas vikas.rastogi2...@gmail.com wrote: @ above, a third string is used, s3 which is strlen(s2)+ strlen(s1) and thus in O(n) space I guess qs calls out for O(1) space. besides , if we have O(n) space , this question simply reduces to finding the number of permutation of string s1+s2 I doubt we can do it in O(1) space, any idea guys ??? On Aug 31, 7:00 pm, Don dondod...@gmail.com wrote: // Returns true if string s3 is s1 interleaved with s2. // The function is iterative when possible, but uses a recursive // call when both s1 and s2 match the next character in s3. // Note that this function is not intended to be called directly. It is called by Interleaved(). bool interleaved2(char *s1, char *s2, char *s3) { while(1) { // End case is when all three strings are empty if (!s1[0] !s2[0] !s3[0]) return true; if (s1[0] == s3[0]) { if (s2[0] == s3[0]) { // Tries both using s1 and s2 next. The recursive call uses s1, // and the postincrement of s2 uses s2 iteratively. if (interleaved2(s1+1, s2++,s3+1)) return true; } // s1 is the only match else ++s1; } else { // s2 is the only match if (s2[0] == s3[0]) ++s2; // Neither s1 nor s2 match the next character in s3 so the strings are not interleaved else return false; } // Move on to the next character in s3 ++s3; } } bool Interleaved(char *s1, char *s2, char *s3) { // Frequency counts int count1[256] = {0}; int count2[256] = {0}; int i,j; // Count the number of occurances of each character in s1 and s2 for(i = 0; s1[i]; ++i) ++count1[s1[i]]; for(j = 0; s2[j]; ++j) ++count1[s2[j]]; j += i; // Next count the number of occurances of each character in s3 for(i = 0; s3[i]; ++i) ++count2[s3[i]]; // If the total number of characters in s3 is not s1+s2, interleaved is false if (i != j) return false; // If s3 is s1 interleaved with s2, these counts must be equal for(i = 1; i 128; ++i) if (count1[i] != count2[i]) return false; // Call the function to do the real work. return interleaved2(s1,s2,s3); } On Aug 31, 8:43 am, Navneet navneetn...@gmail.com wrote: Suppose the two strings are ab and cd. The possible strings formed by interleaving these two are abcd, acbd, acdb , cabd etc.. On Aug 31, 5:23 pm, sukran dhawan sukrandha...@gmail.com wrote: what do u mean by interleaving ? On Wed, Aug 31, 2011 at 5:01 PM, Navneet Gupta navneetn...@gmail.comwrote: The important thing to notice here is that relative order of characters is important and hence you should not look for just count char based approaches. On Wed, Aug 31, 2011 at 11:20 AM, Navneet Gupta navneetn...@gmail.com wrote: Given two strings S1 and S2, Find whether another string S3 can formed by interleaving S1 and S2. Only constant space. -- Regards, Navneet -- -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: Static variable
+1 Don That's correct ..if we write as follows while(i0) { --i // rest .. } in this case we got all zeros On Thu, Sep 1, 2011 at 12:47 PM, Shashwat Shukla shashwatshukla.i...@gmail.com wrote: People, Use debugger and watch i. Answer is self explanatory. On 1 September 2011 19:58, sukran dhawan sukrandha...@gmail.com wrote: its oly 0 10 times since it is a static variable On W ed, Aug 31, 2011 at 7:02 PM, teja bala pawanjalsa.t...@gmail.comwrote: @rohit i think 0 will also be printed as the last while condition'll be checked too On Wed, Aug 31, 2011 at 6:59 PM, rohit raman.u...@gmail.com wrote: 123456789 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/OsL6-Vp91qoJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- --Regards Shashwat Shukla -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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: finding duplicates
bitset n duplicates;// n- bit space.. for(int i=0;in;i++) { if(duplicates[array[i]] ==1) print duplicate... else duplicate[array[i]]=1; } there is no comparison between any 2 numbers O(n) time .space is O(n)bits ... On Tue, Aug 30, 2011 at 5:18 PM, Dave dave_and_da...@juno.com wrote: Replying to myself... A radix sort takes O(n) extra space. Dave On Aug 30, 1:49 pm, Dave dave_and_da...@juno.com wrote: @Kamakshii: With O(1) extra space, it can be done with O(n) comparisons. Do a radix sort on the input (no comparisons), and then check adjacent numbers for equality. Dave On Aug 30, 1:34 pm, Kamakshii Aggarwal kamakshi...@gmail.com wrote: develop an algorithm to find duplicates in a list of numbers without using a binary tree..if there are n distinct numbers in the list ,how many times must two numbers be compared for equality in your algorithm?what if all numbers are equal? -- Regards, Kamakshi kamakshi...@gmail.com- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] stack interview question
explanation for *b)* push(0) push(1) push(2) push(3) push(4) pop()---4 push(5) push(6) pop()-6 push(7) push(8) pop()-8 pop()7 pop()5 pop()-3 pop()2 push(9) pop()--9 here, noway we can get 0 before 1 .. so this sequence is not possible.. On Wed, Aug 31, 2011 at 3:36 AM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: I DNT GET IT.. EXPLAIN PROPERLY ANYONE On Wed, Aug 31, 2011 at 12:57 PM, Yuchen Liao lycdra...@gmail.com wrote: The sequence like 3 1 2 is invalid. So, ans is *b*,* f* and *g* On Wed, Aug 31, 2011 at 1:35 AM, Siddhartha Banerjee thefourrup...@gmail.com wrote: couldn't get it... what are the sequences given in options??? are they the pushed values or popped values or what??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- from Yuchen Liao via Gmail -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] query for nit kurukshtra students
can u pls tell me the answer for the 2nd question.. On Tue, Aug 30, 2011 at 12:04 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: yeah it came yesterday..the paper was very easy 1.u have to find loop in linked list.. 2.u are given a number..you have to print it down to zero(subtracting 5) and then print from 0 to that number(adding 5) without using local variables. 3.two C questions ..that were very easy.. 4.Print the sum of the even terms occuring in Fibbonaci (till 1000 terms) rest i dont remember..as i didnt gave the paper..this is what my frnds told me.. On Tue, Aug 30, 2011 at 9:23 PM, rahul sharma rahul23111...@gmail.comwrote: had microsoft came in nit kurukshetra in last weekif yes then guys from nit kurukshetra plz tell there procedure n questions???thnx in advance guys -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Algorithm to find two numbers in an array that sum up to a given number
Its brute force method.O(n^2) algo... for(int i=0;in;i++) for(int j=i+1;jn;j++) { if(x==A[i]+A[j]) { print A[i],A[j]; break;} } On Wed, Aug 31, 2011 at 1:15 AM, Reynald reynaldsus...@gmail.com wrote: For example, in array, say, 8, 9, 2, 4, 6, 2, 3 Input 5, output 2 and 3. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 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] Amazon - Interview Qn
this takes us to traverse for 2 times the whole linked list ... one time is to know the end of the linked list node .. can't we do better in place ...by using 3 variables p,q,r roughly... p=NULL; q=head; r=q-next; while(q) { n=3; while(n!=0) { q-next=p; q=r; r=r-next; n--; } } But in this code .. we have to maintain some more to work correctly...like for each iteration the start_node-next of previous iteration should point to p .. On Wed, Aug 31, 2011 at 1:10 AM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: remove the 'n' nodes from the beginning..push in the stack..pop them up and insert at the end of linked list..till the stack becomes empty..do this for(m/n) times..m is length of list.. correct me if i am wrong On Wed, Aug 31, 2011 at 6:57 AM, Reynald Suz reynaldsus...@gmail.comwrote: Question: Given: A singly linked list and a number 'n'. Write a program, that will reverse consecutive 'n' nodes in the linked list. Optimize for space and time. Example: Input: Linked list: A-B-C-D-E-F number 'n': 3 Output: C-B-A-F-E-D -- Regards Reynald Reni Masters in Software Engineering CIT - India -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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 group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.