[algogeeks] Re: alternative of stack

2011-09-10 Thread htross
please put some other questions of informatica pleaseit will be helpful. On Sep 11, 11:25 am, Vijay Khandar wrote: > property of stack is last in first out > > On Sun, Sep 11, 2011 at 11:52 AM, UTKARSH SRIVASTAV > > > > > > > > wrote: > > hi i think we have to maintain the property o

Re: [algogeeks] alternative of stack

2011-09-10 Thread Vijay Khandar
property of stack is last in first out On Sun, Sep 11, 2011 at 11:52 AM, UTKARSH SRIVASTAV wrote: > hi i think we have to maintain the property of stack that is first come > first out this can be made only when there is linked list maintain with > property of stack and it will grow in run t

Re: [algogeeks] alternative of stack

2011-09-10 Thread UTKARSH SRIVASTAV
hi i think we have to maintain the property of stack that is first come first out this can be made only when there is linked list maintain with property of stack and it will grow in run time On Sun, Sep 11, 2011 at 11:43 AM, Vijay Khandar wrote: > Can u explain how? linked list > > On Sun, S

Re: [algogeeks] alternative of stack

2011-09-10 Thread Vijay Khandar
Can u explain how? linked list On Sun, Sep 11, 2011 at 11:22 AM, Neha Singh wrote: > Linked 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 t

Re: [algogeeks] alternative of stack

2011-09-10 Thread sukran dhawan
linked list On Sun, Sep 11, 2011 at 11:22 AM, Neha Singh wrote: > Linked 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 ema

Re: [algogeeks] Max sub matrix problem

2011-09-10 Thread Neha Singh
@victor: Can u provide the algo ?? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For mor

[algogeeks] B-tree

2011-09-10 Thread Vijay Khandar
Plz anyone write program in C++ and C of searching,inserting and deleting node in or from a B-tree... Vijay.. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To uns

Re: [algogeeks] Re: Write a program

2011-09-10 Thread praveen raj
Use of binary tree.. which has node(value,count) count -number of elements having having element = value... With regards, Praveen Raj DCE-IT 3rd yr 735993 praveen0...@gmail.com On Sun, Sep 11, 2011 at 10:32 AM, Ishan Aggarwal < ishan.aggarwal.1...@gmail.com> wrote: > What would be the

Re: [algogeeks] alternative of stack

2011-09-10 Thread Neha Singh
Linked 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 g

[algogeeks] alternative of stack

2011-09-10 Thread ravi maggon
if you don't know the size of stack and it grows during run time then which data structure will you prefer for stack and why? 1. BST 2. Linked list 3. Arrays 4. Hash Tables Asked in written test of informatica -- Regards Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this

[algogeeks] Re: Questions -->

2011-09-10 Thread deepikaanand
seed fill or flood fill is a technique to fill polygon of arbitrary boundaries ..by selecting a point or a seed in the polygon and recursively calling the function to fill the polygon -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to

Re: [algogeeks] Questions -->

2011-09-10 Thread Ishan Aggarwal
I dont know. I got this question from Facebook interview page. So posted it here.. On Sun, Sep 11, 2011 at 10:51 AM, bharatkumar bagana < bagana.bharatku...@gmail.com> wrote: > what is seed fill algorithm? > > On Sun, Sep 11, 2011 at 10:45 AM, Ishan Aggarwal < > ishan.aggarwal.1...@gmail.com> wro

Re: [algogeeks] Questions -->

2011-09-10 Thread bharatkumar bagana
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] > Presiden

Re: [algogeeks] Re: MICROSOFT in VJTI mumbai

2011-09-10 Thread bharatkumar bagana
will u pls provide the answer for 2nd questionfinding the closest pair of points... On Sun, Sep 11, 2011 at 4:48 AM, KK 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

[algogeeks] Questions -->

2011-09-10 Thread Ishan Aggarwal
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 -- You received this mess

Re: [algogeeks] Re: Write a program

2011-09-10 Thread Ishan Aggarwal
What would be the complexity in that case ?? On Sun, Sep 11, 2011 at 10:29 AM, bharatkumar bagana < bagana.bharatku...@gmail.com> wrote: > @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 f

Re: [algogeeks] Question --> plz answer

2011-09-10 Thread bharatkumar bagana
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 f

Re: [algogeeks] Re: Write a program

2011-09-10 Thread bharatkumar bagana
@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 wrote: > Watch this video for the concepts of hashing.. > http://www.youtube.com

Re: [algogeeks] Circular Left shift

2011-09-10 Thread praveen raj
Whatever changes have been made in array in first step 1 will be continue to 2nd step(reverse the n-k elements) With regards, Praveen Raj DCE-IT 3rd yr 735993 praveen0...@gmail.com On Sun, Sep 11, 2011 at 9:51 AM, bharatkumar bagana < bagana.bharatku...@gmail.com> wrote: > @prave

Re: [algogeeks] Circular Left shift

2011-09-10 Thread rahul sharma
first do swap like this if k=3 do 3 tym swap let start: 1 element from front...its index let end: 3rd last elemtn index...k lement from last swap first wiht 3rd last 2nd with second last 3 wiht last now we have list as:-14 2 4 5 3 23 9 7 6 now set ;4th element from last i.e k+1 from front swap thes

Re: [algogeeks] Circular Left shift

2011-09-10 Thread bharatkumar bagana
@praveen: will u pls explain the second step ... i didn't understand .. On Sat, Sep 10, 2011 at 8:09 PM, praveen raj 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

Re: [algogeeks] tree traversal

2011-09-10 Thread amrit harry
level order and spiral traversing On Sat, Sep 10, 2011 at 9:27 PM, sukran dhawan wrote: > level order traversal > > On Sat, Sep 10, 2011 at 10:48 AM, ravi maggon wrote: > >> give some traversal other then pre,in and post order to print all elements >> of tree? >> Asked in informatica interview. >

Re: [algogeeks] Max sub matrix problem

2011-09-10 Thread Victor Manuel Grijalva Altamirano
The problem can be reduce to find the submatrix with the max area...for that there is a algorithm in o(n*n*n*n) or o(n*n*n), try with DP. 2011/9/10 Neha Singh > Given a matrix containing only 1s and 0s. Find the largest sub matrix > containing only 1s(not necessarily a square sub matrix)

[algogeeks] Re: MICROSOFT in VJTI mumbai

2011-09-10 Thread KK
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 c

[algogeeks] tejas network???

2011-09-10 Thread htross
what questions are asked in first round of tejas network -- You received this message because you are subscribed to the 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...

[algogeeks] Re: Implementing a grep

2011-09-10 Thread KK
grep is actually implemented using a suffix tree -- You received this message because you are subscribed to the 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...@googleg

Re: [algogeeks]

2011-09-10 Thread sagar pareek
And please read my previous post again... i wrote "stupid question"not "u r stupid"... On Sun, Sep 11, 2011 at 4:24 AM, sagar pareek wrote: > @Ayush > I m sorry ... my intention was not to hurt you. > > > On Sat, Sep 10, 2011 at 11:32 PM, shady wrote: > >> easy dude, no one's making fun

Re: [algogeeks]

2011-09-10 Thread sagar pareek
@Ayush I m sorry ... my intention was not to hurt you. On Sat, Sep 10, 2011 at 11:32 PM, shady wrote: > easy dude, no one's making fun of you. Who knows you solve this problem in > future and become a millionaire ? > > Just keep posting and contributing to group :) > > > On Sat, Sep 10, 2011

[algogeeks] Re: Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Dave
Replying to my own posting: I messed up the while statements. The code should be int gcd( int a, int b) // a > 0 and b > 0 is assumed { int i, k=0; i = a | b; while( ! i & 1 ) { i >>= 1; ++k; } a >>= k; b >>= k; while( ! a & 1 ) a >>= 1; while(

[algogeeks] what is the output????

2011-09-10 Thread htross
main() { int tmp; for(i=0;i<9;i++) { tmp=fork(); if(tmp>0) break; printf("Hello"); } } -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To

[algogeeks] Re: Object Oriented Programming

2011-09-10 Thread Don
Head First Design Patterns On Sep 10, 2:12 pm, Brijesh wrote: > Guys please suggest me any good book for object oriented programming..which > have lots of example of good design pattern. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To po

Re: [algogeeks] Solve this problem

2011-09-10 Thread Sandy
http://stackoverflow.com/questions/6967853/dynamic-programming-can-interval-of-even-1s-and-0s-be-found-in-linear-time On Sun, Sep 11, 2011 at 12:10 AM, Neha Singh wrote: > Can't hv linear solution to this problem. The no. of intervals itself can > be of the order of O(n^2) > > -- > You received t

[algogeeks] Object Oriented Programming

2011-09-10 Thread Brijesh
Guys please suggest me any good book for object oriented programming..which have lots of example of good design pattern. -- 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/ms

[algogeeks] Max sub matrix problem

2011-09-10 Thread Neha Singh
Given a matrix containing only 1s and 0s. Find the largest sub matrix containing only 1s(not necessarily a square sub 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.c

[algogeeks] Re: Question --> plz answer

2011-09-10 Thread Dave
@Ishan: Here is the algorithm: If L <= C, then cup1 = L cup2 = cup3 = cup4 = cup5 = cup6 = overflow = 0 else if L < 3*C, then cup1 = C cup2 = cup3 = (L-C)/2 cup4 = cup5 = cup6 = overflow = 0 else if L < 5*C, then cup1 = cup2 = cup3 = C cup4 = cup6 = (L-3*C)/4 cup5 =

Re: [algogeeks] Solve this problem

2011-09-10 Thread Neha Singh
Can't hv linear solution to this problem. The no. of intervals itself can be of the order of O(n^2) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this grou

[algogeeks] Given a matrix consisting only 0s and 1s, find the maximum size sub-matrix with all 1s.(not necessarily square sun matrix)

2011-09-10 Thread Neha Singh
-- You received this message because you are subscribed to the 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 ht

[algogeeks] Re: Question --> plz answer

2011-09-10 Thread Ankuj Gupta
what is C and M On Sep 10, 7:40 pm, Ishan Aggarwal 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 o

Re: [algogeeks]

2011-09-10 Thread shady
easy dude, no one's making fun of you. Who knows you solve this problem in future and become a millionaire ? Just keep posting and contributing to group :) On Sat, Sep 10, 2011 at 11:06 PM, aayush jain wrote: > @sagar > bro i m not intelligent than u so thats why u r making fun of mine..u know

Re: [algogeeks]

2011-09-10 Thread aayush jain
@sagar bro i m not intelligent than u so thats why u r making fun of mine..u know one thing God is not giving equal capability of mind and he has given something special to everyone that thing surely is not in u... so think about it before say anythink.. -- You received this message because you a

[algogeeks] Re: Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Dave
@Shady: I really haven't studied the complexity of the binary gcd algorithm. It is well known that the complexity of Euclid's algorithm is O(log_phi(max(a,b))), where phi is the golden ratio: phi = (1 + sqrt(5)) / 2, with the worst case being two consecutive Fibonacci numbers. E.g., Euclid's algori

Re: [algogeeks]

2011-09-10 Thread aayush jain
thanx praveen... -- You received this message because you are subscribed to the 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 t

Re: [algogeeks] Write a program to Convert an ASCII representation of a positive integer to it's numeric value ??

2011-09-10 Thread sukran dhawan
u can use atoi function On Sat, Sep 10, 2011 at 10:26 PM, shady wrote: > #include > #include > > main(){ > char *s = "88934\0"; > int sum=0; > int i=0; > while(i int value = s[i]-'0'; > sum = 10*sum+value; > i++; >

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Neha Singh
Can anybdy sum up, wats the best approach and under what cicumstances ?? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks

Re: [algogeeks] Write a program to Convert an ASCII representation of a positive integer to it's numeric value ??

2011-09-10 Thread shady
#include #include main(){ char *s = "88934\0"; int sum=0; int i=0; while(i wrote: > Not able to find some good solution for this... > > > On Sat, Sep 10, 2011 at 10:17 PM, shady wrote: > >> string manipulation... google it. >> >> On Sat, Sep 10, 2011 at 10:06 PM,

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread shady
@dave no doubt division is costly, but will time complexity change in your case ? On Sat, Sep 10, 2011 at 10:25 PM, Neha Singh wrote: > the time complexity of my approach : O(a*b)^2 > and of the other approach, i guess : O(a) , where a is the larger no. > correct me if i m wrong > > So, complexi

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Neha Singh
the time complexity of my approach : O(a*b)^2 and of the other approach, i guess : O(a) , where a is the larger no. correct me if i m wrong So, complexity wise my approach does not seem to be gud -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" gro

Re: [algogeeks] how to find if sum of some of the elements of an array equals to k

2011-09-10 Thread shady
@sukran nope, that won't work. @neha true On Sat, Sep 10, 2011 at 10:19 PM, avi0889 wrote: > adding how...do u mind elaborating a little plz...:) > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the w

[algogeeks] Re: Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Dave
@Neha: Although some have suggested Euclid's Algorithm without condition, and some have expressed disgust that you would even ask the question, it actually is worth discussing. If division is expensive compared to logical operations, such as in a microcontroller that does not have a hardware divide

Re: [algogeeks] Write a program to Convert an ASCII representation of a positive integer to it's numeric value ??

2011-09-10 Thread Ishan Aggarwal
Not able to find some good solution for this... On Sat, Sep 10, 2011 at 10:17 PM, shady wrote: > string manipulation... google it. > > On Sat, Sep 10, 2011 at 10:06 PM, Ishan Aggarwal < > ishan.aggarwal.1...@gmail.com> wrote: > >> >> >> -- >> Kind Regards >> Ishan Aggarwal >> [image: Aricent Gro

Re: [algogeeks]

2011-09-10 Thread shady
@sagar hahaha, 101% true @others this is a million $ question... all the best. On Sat, Sep 10, 2011 at 6:19 PM, sagar pareek wrote: > @aayush > > Dude... i dont knw from where did u find such a stupid question... > Whole cryptography.mean all SSL , RSA , etc etc based on large > numbers

Re: [algogeeks] how to find if sum of some of the elements of an array equals to k

2011-09-10 Thread avi0889
adding how...do u mind elaborating a little plz...:) -- 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/-/FqHIYXKWamYJ. To post to this group, send email to algo

Re: [algogeeks] Write a program to Convert an ASCII representation of a positive integer to it's numeric value ??

2011-09-10 Thread shady
string manipulation... google it. On Sat, Sep 10, 2011 at 10:06 PM, Ishan Aggarwal < ishan.aggarwal.1...@gmail.com> wrote: > > > -- > Kind Regards > Ishan Aggarwal > [image: Aricent Group] > Presidency Tower-A, M.G.Road,Sector-14 > Gurgaon,Haryana.122015 INDIA > Phone : +91-9654602663 > ishan2.ag

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread shady
yup, yours(binary gcd) is better. On Sat, Sep 10, 2011 at 9:34 PM, Neha Singh wrote: > How abt dis : > > The algorithm reduces the problem of finding the GCD by repeatedly applying > these identities: > 1. gcd(0, v) = v, because everything divides zero, and v is the largest > number that divides

Re: [algogeeks] Write a function to find the least common multiple of integers in an array

2011-09-10 Thread shady
O(n log(n)) can we do better ? On Sat, Sep 10, 2011 at 10:02 PM, sukran dhawan wrote: > after finding gcd of first two elements use gcd as first no and next array > element as second no annd call gcd function > repeat the proc till array exhausts > > On Sat, Sep 10, 2011 at 9:39 PM, Neha Singh wr

Re: [algogeeks] how to find if sum of some of the elements of an array equals to k

2011-09-10 Thread Neha Singh
this problem is more or less same as subset sum problem. So, i guess only brute force solution ( O(2^n) ) is available. Correct me if i m 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@g

Re: [algogeeks] Write a function to find the least common multiple of integers in an array

2011-09-10 Thread Neha Singh
got 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

Re: [algogeeks] Write a function to find the least common multiple of integers in an array

2011-09-10 Thread sukran dhawan
after finding gcd of first two elements use gcd as first no and next array element as second no annd call gcd function repeat the proc till array exhausts On Sat, Sep 10, 2011 at 9:39 PM, Neha Singh wrote: > @sukran : we hv to find gcd of all the elements of the array, not of 2 > elements. > Give

Re: [algogeeks] how to find if sum of some of the elements of an array equals to k

2011-09-10 Thread sukran dhawan
sorting and then adding individual elements and then comparing with k On Sat, Sep 10, 2011 at 9:59 PM, sukran dhawan wrote: > sorting will help i guess > > > On Sat, Sep 10, 2011 at 9:51 PM, avi0889 wrote: > >> how to find if sum of some of the elements of an array equals to k >> >> -- >> You re

Re: [algogeeks] how to find if sum of some of the elements of an array equals to k

2011-09-10 Thread sukran dhawan
sorting will help i guess On Sat, Sep 10, 2011 at 9:51 PM, avi0889 wrote: > how to find if sum of some of the elements of an array equals to k > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the web visit

[algogeeks] Solve the following problems

2011-09-10 Thread Ishan Aggarwal
Hi All, Please answer these questions :- 1.) A tree is serialized in such a way that all the leaves are market with L and all the other nodes with N. The tree is serialized keeping the order derived by a pre-order traversal. Write an algorithm for reconstructing the tree. Also, suggest a methodolo

[algogeeks] how to find if sum of some of the elements of an array equals to k

2011-09-10 Thread avi0889
how to find if sum of some of the elements of an array equals to k -- 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/-/Lb3JgT4eWDAJ. To post to this group, send

Re: [algogeeks] Write a function to find the least common multiple of integers in an array

2011-09-10 Thread Neha Singh
@sukran : we hv to find gcd of all the elements of the array, not of 2 elements. Give detailed algo -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this grou

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Neha Singh
How abt dis : The algorithm reduces the problem of finding the GCD by repeatedly applying these identities: 1. gcd(0, v) = v, because everything divides zero, and v is the largest number that divides v. Similarly, gcd(u, 0) = u. gcd(0, 0) is not typically defined, but it is convenient to set gcd(0

Re: [algogeeks] Code it

2011-09-10 Thread Ishan Aggarwal
can someone plz provide the solution to it??? On Sat, Sep 10, 2011 at 9:30 PM, sukran dhawan wrote: > best way it to invoke the function recursively > > just like a k-1 ary tree > correct me if im wrong > > On Sat, Sep 10, 2011 at 2:49 PM, Ishan Aggarwal < > ishan.aggarwal.1...@gmail.com> wrote:

Re: [algogeeks] Re: Write a program

2011-09-10 Thread Ishan Aggarwal
Howz this solution?? void main() { int a[10] = {9,3,9,3,9,3,2}; int c[10],i,j,k,co; k=0; for(i=0;i<7;i++) { co = 0; for( j = 1+1; j<7; j++) if( a[i] == a[j]) co++ ; if( co == 0) { c[k++] = a[i]; } for (i=0;iwrote: > yes for integer arrays we need to sort o(nlogn) and den compare in o(n) > > >

Re: [algogeeks] Code it

2011-09-10 Thread sukran dhawan
best way it to invoke the function recursively just like a k-1 ary tree correct me if im wrong On Sat, Sep 10, 2011 at 2:49 PM, Ishan Aggarwal < ishan.aggarwal.1...@gmail.com> wrote: > What would be the efficient way to code this program.?? > > Given an array of size n, find all the possible sub

Re: [algogeeks] MICROSOFT WRITTEN QUESTION

2011-09-10 Thread Gaurav Menghani
No. I think you should revisit complexity. That's not how it works. Factoring a million digit number outputs two numbers. It should take O(1), right? :D On Sat, Sep 10, 2011 at 11:56 AM, Neha Singh wrote: > we hv to just fill an array of size n, so complexity should be O(n) in worst > case > > -

Re: [algogeeks] tree traversal

2011-09-10 Thread sukran dhawan
level order traversal On Sat, Sep 10, 2011 at 10:48 AM, ravi maggon wrote: > 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

Re: [algogeeks] MICROSOFT WRITTEN QUESTION

2011-09-10 Thread Neha Singh
we hv to just fill an array of size n, so complexity should be O(n) in worst case -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Re: Write a program

2011-09-10 Thread sukran dhawan
yes for integer arrays we need to sort o(nlogn) and den compare in o(n) On Sat, Sep 10, 2011 at 7:12 PM, Ishan Aggarwal < ishan.aggarwal.1...@gmail.com> wrote: > Hi, > > Actually I am not good at hash tables. can u plzz suggest me some gud link > from where I can study hash tables... > and also t

Re: [algogeeks] Paypal

2011-09-10 Thread mohit mittal
coming arnd 25th eligibily : 65% pay - arnd 8 On Sat, Sep 10, 2011 at 9:23 PM, vivek goel wrote: > cau u elaborate me.m not getting it... > > > On Sat, Sep 10, 2011 at 9:21 PM, mohit mittal wrote: > >> around 25th >> 65 >> arnd 8 >> >> -- >> You received this message because you

Re: [algogeeks] logical and physical address

2011-09-10 Thread sukran dhawan
page size (logical address space) = 512 = 2 power 9 so 9 bits base address = 10 bits so combining them 10+ 9 = 19 bits On Sat, Sep 10, 2011 at 7:18 PM, rohit kumar wrote: > please explain ... > > > On Sat, Sep 10, 2011 at 5:10 PM, bharatkumar bagana < > bagana.bharatku...@gmail.com> wrote: > >

Re: [algogeeks] Paypal

2011-09-10 Thread vivek goel
cau u elaborate me.m not getting it... On Sat, Sep 10, 2011 at 9:21 PM, mohit mittal wrote: > around 25th > 65 > arnd 8 > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the web visit > http

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread sukran dhawan
while(num2 != 0) { rem = num1 % num2 num1 = num2 num2 = rem } On Sat, Sep 10, 2011 at 8:59 PM, Gaurav Menghani wrote: > C'mon > > http://en.wikipedia.org/wiki/Greatest_common_divisor > > On Sat, Sep 10, 2011 at 11:24 AM, Neha Singh > wrote: > > > > -- > > You received this message because you

Re: [algogeeks] Paypal

2011-09-10 Thread mohit mittal
around 25th 65 arnd 8 -- 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/-/7FtN8hsesrgJ. To post to this group, send email to algogeeks@googlegroups.com. To uns

Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....

2011-09-10 Thread sukran dhawan
where n is the size of array On Sat, Sep 10, 2011 at 9:16 PM, sukran dhawan wrote: > > > large1 = a[0]; > large2 = a[1]; > > > if(large1 < large2) > swap(large1,large2) > > while(i < n) > { > if(a[i] > large1) >{ > large2 = large1 > large1 = a[i] > } > else if(a[i] > large2) > l

Re: [algogeeks] Write a function to find the least common multiple of integers in an array

2011-09-10 Thread sukran dhawan
find GCD by eucledian method LCM = (a * b )/GCD; On Sat, Sep 10, 2011 at 9:13 PM, Gaurav Menghani wrote: > http://tinyurl.com/3hm3gug > > On Sat, Sep 10, 2011 at 10:46 AM, Neha Singh > wrote: > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm

Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....

2011-09-10 Thread sukran dhawan
large1 = a[0]; large2 = a[1]; if(large1 < large2) swap(large1,large2) while(i < n) { if(a[i] > large1) { large2 = large1 large1 = a[i] } else if(a[i] > large2) large2 = a[i] } // test the case if no of elements is 1 :) On Sat, Sep 10, 2011 at 8:54 PM, Dave wrote: > @Abhinav:

Re: [algogeeks] Write a function to find the least common multiple of integers in an array

2011-09-10 Thread Gaurav Menghani
http://tinyurl.com/3hm3gug On Sat, Sep 10, 2011 at 10:46 AM, Neha Singh wrote: > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send em

Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....

2011-09-10 Thread Gaurav Menghani
Well you can avoid that condition by comparing the number by: 1. Keeping two numbers, largest and second largest. 2. Comparing with the second largest. If it is greater than the second largest, set second_largest = num. Else continue. 3. If second_largest > largest, swap(largest,second_largest). O

Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....

2011-09-10 Thread abhinav gupta
sort it in quicksort (descending order)...den take arr[1] -->second largest On Sat, Sep 10, 2011 at 8:34 AM, Akhilesh Vedhera wrote: > Then the complexity will be nlogn not n and if it is the worst case > then it would be O(n^2)... > > On Sat, Sep 10, 2011 at 8:58 PM, abhinav gupta > wrote:

Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....

2011-09-10 Thread Akhilesh Vedhera
Then the complexity will be nlogn not n and if it is the worst case then it would be O(n^2)... On Sat, Sep 10, 2011 at 8:58 PM, abhinav gupta wrote: > Oops ..no u hav to quicksort it. > > > On Sat, Sep 10, 2011 at 8:24 AM, Dave wrote: > >> @Abhinav: Does it work correctly on {1, 3, 2}, or, f

Re: [algogeeks] MICROSOFT WRITTEN QUESTION

2011-09-10 Thread Gaurav Menghani
On Sat, Sep 10, 2011 at 11:28 AM, teja bala wrote: > @Gaurav > > wat if here is n=1 > den >  W(0)=? > >  i dint get that See, when you get to W(0) state, that means, you have created a valid combination. That means, you have gone through one 'path' through the various possibilities. That is why W

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Gaurav Menghani
C'mon http://en.wikipedia.org/wiki/Greatest_common_divisor On Sat, Sep 10, 2011 at 11:24 AM, Neha Singh wrote: > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To uns

Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....

2011-09-10 Thread abhinav gupta
Oops ..no u hav to quicksort it. On Sat, Sep 10, 2011 at 8:24 AM, Dave wrote: > @Abhinav: Does it work correctly on {1, 3, 2}, or, for that matter, on > any array where the second largest comes after the largest? > > Dave > > On Sep 10, 10:16 am, abhinav gupta wrote: > > temp2 is second largest

Re: [algogeeks] MICROSOFT WRITTEN QUESTION

2011-09-10 Thread teja bala
@Gaurav wat if here is n=1 den W(0)=? i dint get 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...@g

Re: [algogeeks] MICROSOFT WRITTEN QUESTION

2011-09-10 Thread Gaurav Menghani
On Sat, Sep 10, 2011 at 11:22 AM, Neha Singh wrote: > O(n/a) For every n, it would add values for W(n-v1), W(n-v2),..., W(n-vm), if there are m denominations of coins. So the complexity would be O(nm). Also, this can be implemented in two ways. Top-down (which is what I mentioned), and Bottom-up.

Re: [algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread amrit harry
Euclid's GCD Algorithm: http://www.cs.berkeley.edu/~vazirani/s99cs170/notes/lec3.pdf On Sat, Sep 10, 2011 at 8:54 PM, Neha Singh wrote: > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@g

[algogeeks] Find th gcd of 2 nos in the most efficient way

2011-09-10 Thread Neha Singh
-- You received this message because you are subscribed to the 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 ht

[algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....

2011-09-10 Thread Dave
@Abhinav: Does it work correctly on {1, 3, 2}, or, for that matter, on any array where the second largest comes after the largest? Dave On Sep 10, 10:16 am, abhinav gupta wrote: > temp2 is second largest element. > > On Sat, Sep 10, 2011 at 8:00 AM, abhinav gupta > wrote: > > > > > > > I can so

Re: [algogeeks] MICROSOFT WRITTEN QUESTION

2011-09-10 Thread Neha Singh
O(n/a) where n is the required sum which is to be created by grouping the coins and a is the coin of smallest denomination so, O(n) in the worst case -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge

Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....

2011-09-10 Thread abhinav gupta
temp2 is second largest element. On Sat, Sep 10, 2011 at 8:00 AM, abhinav gupta wrote: > I can solve this problem in O(n) > i=0; > temp1=arr[0]; > > while(i != len) > { > if(arr[i] > temp1) > { > temp2=temp1; > temp1=arr[i] > } > i++; > } > > On Sat, Sep 10, 2011 at 7:42 AM, Dave wrote: > >> @Re

Re: [algogeeks] MICROSOFT WRITTEN QUESTION

2011-09-10 Thread Gaurav Menghani
You can use a trivial dynamic programming for this. Let W(n) be the number of ways to create n rupees, then W(n) = W(n-1) + W(n-5) + W(n-10) + W(n-25) + W(n-50) if(n<0) then W(n) = 0 if(n==0) then W(n) = 1 What do you think would be the complexity of this solution? On Sat, Sep 10, 2011 at 10:57

Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....

2011-09-10 Thread abhinav gupta
I can solve this problem in O(n) i=0; temp1=arr[0]; while(i != len) { if(arr[i] > temp1) { temp2=temp1; temp1=arr[i] } i++; } On Sat, Sep 10, 2011 at 7:42 AM, Dave wrote: > @Replying to my own posting: remove the words "one of the numbers that > lost to", so that the explanation reads > > The q

[algogeeks] MICROSOFT WRITTEN QUESTION

2011-09-10 Thread teja bala
There are set of coins of {50,25,10,5,1} paise in a box.Write a program to find the number of ways a 1 rupee can be created by grouping the paise. post ur code. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this g

[algogeeks] Write a function to find the least common multiple of integers in an array

2011-09-10 Thread Neha Singh
-- You received this message because you are subscribed to the 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 ht

[algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....

2011-09-10 Thread Dave
@Replying to my own posting: remove the words "one of the numbers that lost to", so that the explanation reads The question should be "How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons?" The answer is to use a tournament to select the largest number. T

[algogeeks] Question --> plz answer

2011-09-10 Thread Ishan Aggarwal
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 o

Re: [algogeeks] Circular Left shift

2011-09-10 Thread praveen raj
@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...@go

  1   2   >