[algogeeks] Algo Question

2013-02-04 Thread marti
You have N guards in a line each with a demand of coins.You can skip paying a guard only if his demand is lesser than what you have totally paid before reaching him.Find the least number of coins you spend to cross all guards. I think its a DP problem but cant come up with a formula.Another

Re: [algogeeks] Algo Question

2013-02-04 Thread navneet singh gaur
I guess it doesn't require a DP, I might have understood your question wrongly but from what I have understood solution is as follows : S = sum at a particular point A[N] = array which contains guard's respective demands i = 0, S=0; while (i N) { if (A[i] = S) { S += A[i]; } i++;

Re: [algogeeks] Algo Question

2013-02-04 Thread sumit kumar pathak
@above [20, 20, 3, 42] regards - Sumit Kumar Pathak (Sumit/ Pathak/ SKP ...) *Smile is only good contagious thing.* *Spread it*! On Mon, Feb 4, 2013 at 7:40 AM, navneet singh gaur navneet.singhg...@gmail.com wrote: I guess it doesn't require a DP, I might have understood your question

Re: [algogeeks] algo qstn

2012-01-17 Thread Umer Farooq
0 On 1/16/12, Ravi Ranjan ravi.cool2...@gmail.com wrote: An ant moves on a regular grid of squares that are coloured either black or white. The ant is always oriented in one of the cardinal directions (left, right, up or down) and moves from square to adjacent square according to the

[algogeeks] algo qstn

2012-01-16 Thread Ravi Ranjan
An ant moves on a regular grid of squares that are coloured either black or white. The ant is always oriented in one of the cardinal directions (left, right, up or down) and moves from square to adjacent square according to the following rules: - if it is on a black square, it flips the color of

[algogeeks] Algo for Search in a 2D Matrix

2011-10-09 Thread Ankur Garg
Given a 2D matrix which is both row wise and column wise sorted. Propose an algorithm for finding the kth smallest element in it in least time complexity A General Max Heap can be used with k space and n+klogk complexity Any other solution or even a way by which we dont scan the whole matrix to

Re: [algogeeks] Algo for Search in a 2D Matrix

2011-10-09 Thread shubham goyal
im assuming it be a square matrix then kth smallest element will be in a first k*k sub matrix. jst look for smallest element in the diagonal of this matrix. it will give the kth smallest element . On Mon, Oct 10, 2011 at 4:45 AM, Ankur Garg ankurga...@gmail.com wrote: Given a 2D matrix which

[algogeeks] Algo

2011-10-07 Thread Deepak arora
Please tell the algo of this problem hasPathSum() We'll define a root-to-leaf path to be a sequence of nodes in a tree starting with the root node and proceeding downward to a leaf (a node with no children). We'll say that an empty tree contains no root-to-leaf paths. So for example, the

[algogeeks] Algo for in-place Stack Reversal.

2011-10-07 Thread .itoa
We are not supposed to use any loop. So that leaves us with recursion. I get the idea and it was working too. But i couldn't UNDERSTAND how the recursion was working. Can someone explain how recursion would work in that case please? -- You received this message because you are subscribed to

Re: [algogeeks] Algo

2011-10-07 Thread anshu mishra
wat is ur question finding maximum path sum or anything other than this? -- You received this message because you are subscribed to the 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] Algo for in-place Stack Reversal.

2011-10-07 Thread shady
i am bit confused... how come using recursion makes this in-place recursion occurs with a stack.. so you will be piling up more and more variables each time... ? On Fri, Oct 7, 2011 at 5:19 PM, .itoa nitm...@gmail.com wrote: We are not supposed to use any loop. So that leaves us with

Re: [algogeeks] Algo for in-place Stack Reversal.

2011-10-07 Thread .itoa
Hmm i guess you are correct! Recursion would require stacking up. Then how are we going to do it ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Algo for in-place Stack Reversal.

2011-10-07 Thread .itoa
But , let's say if we do by recursion , then could you explain the way it would work ? And this in-place keyword is not clear to me. Does it mean we can't use buffer / temporary variables or something else? -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] Algo for in-place Stack Reversal.

2011-10-07 Thread Carl Barton
An in place algorithm is one which only uses a constant amount of extra memory. So recursion is a problem as it will use an implicit stack of size O(n) which is linear extra memory, not constant. On 7 October 2011 15:16, .itoa nitm...@gmail.com wrote: But , let's say if we do by recursion ,

Re: [algogeeks] Algo for in-place Stack Reversal.

2011-10-07 Thread sravanreddy001
in place means: use constant extra space in simple terms O(1) space -- 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/-/nDVS4k7fF34J. To post to this group,

Re: [algogeeks] Algo for in-place Stack Reversal.

2011-10-07 Thread Ankur Garg
To do inplace stack reversal u need a mechanism by which u can transfer the first node to last of the stack making sure u have count of other nodes here Say u have stack 5- top 4 3 2 1 The answer should generate the stack as 1-top 2 3 4 5 This give hints to recursion . A normal recursive func

Re: [algogeeks] Algo for in-place Stack Reversal.

2011-10-07 Thread Wasif Hossain
@Ankur: +1 On Fri, Oct 7, 2011 at 8:44 PM, Ankur Garg ankurga...@gmail.com wrote: To do inplace stack reversal u need a mechanism by which u can transfer the first node to last of the stack making sure u have count of other nodes here Say u have stack 5- top 4 3 2 1 The answer

[algogeeks] Algo Book

2011-09-06 Thread Neha Gupta
hey guys , do tell me a book for algo( other than cormen) with good no. of illustrations or any resource or link on net(especially for dp, backtracking, np problems etc ) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] Algo Book

2011-09-06 Thread siddharam suresh
Data Structures and Algorithms Alfred V. Aho (Author), Jeffrey D. Ullman (Author), John E. Hopcroft (Author) Thank you, Sid. On Tue, Sep 6, 2011 at 3:45 PM, Neha Gupta nehagup...@gmail.com wrote: hey guys , do tell me a book for algo( other than cormen) with good no. of illustrations or any

Re: [algogeeks] Algo Book

2011-09-06 Thread Udit Gupta
Fundamentals of Computer Algorithms by Sartaj Sahni On Tue, Sep 6, 2011 at 3:45 PM, Neha Gupta nehagup...@gmail.com wrote: hey guys , do tell me a book for algo( other than cormen) with good no. of illustrations or any resource or link on net(especially for dp, backtracking, np problems etc

Re: [algogeeks] Algo Book

2011-09-06 Thread Neha Gupta
@siddharam ...iski ebook milegi to refer -- You received this message because you are subscribed to the Google 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.

Re: [algogeeks] Algo Book

2011-09-06 Thread Prashant Kulkarni
The Algorithm Design Manual By Steve S. Skiena -- Prashant Kulkarni On Tue, Sep 6, 2011 at 3:48 PM, Udit Gupta uditgupta...@gmail.com wrote: Fundamentals of Computer Algorithms by Sartaj Sahni On Tue, Sep 6, 2011 at 3:45 PM, Neha Gupta nehagup...@gmail.com wrote: hey guys , do tell me a

Re: [algogeeks] Algo Book

2011-09-06 Thread siddharam suresh
@neha: there is site calledhttp://library.nu register there, u'll get majority of the books. Thank you, Sid. On Tue, Sep 6, 2011 at 3:54 PM, Prashant Kulkarni prashant.r.k...@gmail.com wrote: The Algorithm Design Manual By Steve S. Skiena -- Prashant Kulkarni On Tue, Sep 6, 2011 at

Re: [algogeeks] Algo Book

2011-09-06 Thread Neha Gupta
thanku sid :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this

Re: [algogeeks] Algo Book

2011-09-06 Thread Manikanta Babu
The Algorithm Design Manual is the best book you can refer. But its not for beginners. Cheers, Mani On Tue, Sep 6, 2011 at 4:09 PM, siddharam suresh siddharam@gmail.comwrote: @neha: there is site calledhttp://library.nu register there, u'll get majority of the books. Thank you, Sid.

Re: [algogeeks] Algo Book

2011-09-06 Thread Neha Gupta
thnx to all :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this

Re: [algogeeks] Algo

2011-08-31 Thread Yuchen Liao
Hi, Naman, I have a O(32n) algorithm. You can solve this problem by creating a empty Trie http://en.wikipedia.org/wiki/Trie, then you add each number's binary form(from high to low) into the Trie. For each number X, start from the root of the Trie, if mth bit of X is P(0 or 1), then

[algogeeks] algo ques

2011-08-28 Thread himanshu kansal
you have a path of N steps at every step, you can take onl;y 1 step or 2 steps. how to print all the possible paths that you can take.. PS: please dont give the exact code.your approaches will be appreciated:) -- You received this message because you are subscribed to the

Re: [algogeeks] algo ques

2011-08-28 Thread prashant thorat
Hi, you can do this by recursion , printPath (int length) { if(lenght == N) return; else { if(lenght+1 = N) { Printf ( --one step --) call printPath (length+1) } else if(lenght+2 = N) { Printf ( --two steps --) call printPath (length+2) } else return; } } On Sun, Aug 28, 2011 at 5:42 PM,

Re: [algogeeks] algo ques

2011-08-28 Thread Kamakshii Aggarwal
what is the initial value of length that u r passing?? On Sun, Aug 28, 2011 at 6:47 PM, prashant thorat prashantnit...@gmail.comwrote: Hi, you can do this by recursion , printPath (int length) { if(lenght == N) return; else { if(lenght+1 = N) { Printf ( --one step --) call printPath

Re: [algogeeks] algo ques

2011-08-28 Thread prashant thorat
sorry, pls ignore above code ..a bit modifie code I'm passing length = 0 printPath (int length) { if(lenght == N) return; else { if(lenght+1 = N) { Printf ( --one step --) call printPath (length+1) } else if(lenght+2 = N) { Printf ( --two steps --) call printPath (length+2) }

Re: [algogeeks] algo ques

2011-08-28 Thread Kamakshii Aggarwal
@prashant: if u remove else from this line else if(lenght+2 = N) { Printf ( --two steps --) call printPath (length+2) } i think then the code will work properly. correct me if i am wrong On Sun, Aug 28, 2011 at 7:01 PM, prashant thorat prashantnit...@gmail.comwrote: sorry, pls ignore above

Re: [algogeeks] algo ques

2011-08-28 Thread Mohit kumar lal
we can make a BST(Binary search tree) for this problem, suppose the path is of length 10, and currently i am on 1st platform ,then this one should be in our root node and children of this root would be 2 and 3...Similarly we iterate until we find 10 in every leaves of BST.Then we can easily print

[algogeeks] Algo to identify loose ends of each cable in minimum time.

2011-04-04 Thread Munish Goyal
Hi, Just posted another problem, which comes in category of hard problems. http://industryinterviewquestions.blogspot.com/2011/04/least-number-of-trips-to-number-wires.html -- Munish -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] algo to count the items in a list

2011-03-26 Thread Patidarchat Gmal
reducing more complexity of the tree is not binary, it will be like below instead of node containning the name it will have a (character,count , is_last_char_of_string) the complexity for searching the word is present or not is length_of_word now we can create tree like this words (

[algogeeks] algo for mirror a tree

2011-03-10 Thread Subhransupanigrahi
Hey guys, you guys have came across many time with mirror a tree. if anyone has effective ways interms of memory efficiency way to implement mirror of a tree. Sent from my iPhone -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks] algo to count the items in a list

2010-10-18 Thread Abhijit K Rao
The most crude method would be to do a comparison in the entire array list and increment as and when we find a match. But this method gives a complexity of O(n2). The same method above can be used , and comparisons can be done from either ends of array, which reduces the complexity to O(n2 / 2)

Re: [algogeeks] algo to count the items in a list

2010-10-18 Thread saurabh gupta
sort list.txt|uniq -c On Fri, Oct 15, 2010 at 7:00 AM, Kumar S kush...@gmail.com wrote: Q : A file has list of names. We need an algorithm to find the number each names repeats in that list. NOT case sensitive Example... namefile.txt has the content.. bob abi jack ram jim tim

Re: [algogeeks] algo to count the items in a list

2010-10-15 Thread tech rascal
u can do it by making binary search tree and each node should has 2 data parts i.e, name and count. Whnevr u encounter the same name, update the count of that corresponding node else keep on extending the tree. On Fri, Oct 15, 2010 at 7:00 AM, Kumar S kush...@gmail.com wrote: Q : A file has

Re: [algogeeks] algo to count the items in a list

2010-10-15 Thread preetika tyagi
I think one way we can do it is to sort all the names. And then do the linear scan to find the distinct names and their corresponding count. Another way is to maintain a hash map. Check for each name if it already exists in the map. If it exists, simply increase the counter by 1 otherwise insert

Re: [algogeeks] algo to count the items in a list

2010-10-15 Thread AlgoSau Sau
Storing in hash DS is good.. Another option may be to use Trie DS to store names..at each node of trie the initial count would be 0..whenever a name is encountered then Trie would be updated with that entry and at the last character of the word in node the count will be incremented.. On Sat, Oct

Re: [algogeeks] ALgo help pls

2010-09-22 Thread Asit Baran Das
http://userweb.cs.utexas.edu/users/moore/best-ideas/mjrty/index.html _Asit On Wed, Sep 22, 2010 at 9:12 AM, pre pre.la...@gmail.com wrote: Hi all, pls help me solve this problem.. Design an algorithm to find the majority element of an array.. majority element must be an element tht has the

Re: [algogeeks] ALgo help pls

2010-09-22 Thread Navin Naidu
Use majority vote algorithm: http://userweb.cs.utexas.edu/~moore/best-ideas/mjrty/index.html On Wed, Sep 22, 2010 at 9:12 AM, pre pre.la...@gmail.com wrote: Hi all, pls help me solve this problem.. Design an algorithm to find the majority element of an array.. majority element must be an

[algogeeks] algo for counting integers in a stream

2010-07-03 Thread divya
You are provided with a stream of integers, design a data structure to store the number of occurrences of each integer. If the set of integers is known, then the problem becomes simple. If the set of integers is known: Have a hash of the known set of integers. Parse the input stream, hash it to

[algogeeks] Algo to find all the possible subsets in a set

2009-08-26 Thread AKS
Hello fellas, i am lookin for an algorithm to find all the possible subsets in a given set So, if the Set is say, A={a,b,c} omit the null set o/p: --- {a} {b} {c} {a,b} {b,c} {a,c} {a,b,c} omit the null set regards, Abhijeet --~--~-~--~~~---~--~~ You

[algogeeks] Algo Question

2009-07-01 Thread priya k
we have many machines connected to each other. However, administering these machines is a great hassle. That is because a machine can be administered only by a machine connected directly to it (a machine that is an administrator can administrator itself). So, the system administrators have

[algogeeks] algo for finding the union of two sets ...

2008-06-23 Thread zee
do we have an algo for finding the union of two sets ??? data structure suitable for set operations --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] algo.....

2008-02-07 Thread monty 1987
Hi Can anyone tell me about constraint satisfaying algorithm(simulated annealing)?? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Algo.. phone book

2007-11-07 Thread Rajat Gogri
If you have to implement a phone book of 10 millin people in NYC, what data structure would you use and why ? Show the implementation if HashTable or Binary Trees? Thanks, Raj --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

[algogeeks] Algo to get GCD of given numbers

2007-08-12 Thread sumedh sakdeo
Write algorithm for finding the GCD of given numbers. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this

[algogeeks] algo problem

2007-04-14 Thread monty 1987
My problem is to find out longest subsequence of integers in increasing order in an array of integers. If any one have solution tell it to me. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To