Re: [algogeeks] Urgent Need ITIL Service Management Operations Business/Process Analyst in Manhattan, NY for 6+ months

2015-09-10 Thread Shashwat Anand
Can we please get rid of this spammer ? On Thu, Sep 10, 2015 at 1:53 AM, Shachindra A C wrote: > ^^ +1 > > On Wed, Sep 9, 2015 at 12:54 PM, Rahul Vatsa > wrote: > >> Please block this guy. >> >> On Thu, Sep 10, 2015 at 1:08 AM, Shaik Asif

[algogeeks] Find max sum of elements in an array ( with twist)

2015-03-24 Thread atul anand
Given a array with +ve and -ve integer , find the maximum sum such that you are not allowed to skip 2 contiguous elements ( i.e you have to select atleast one of them to move forward). eg :- 10 , 20 , 30, -10 , -50 , 40 , -50, -1, -3 Output : 10+20+30-10+40-1 = 89 -- You received this message

Re: [algogeeks] Better data structure/Algorithm to handle the following porblem

2014-12-29 Thread atul anand
B+ tree is used by database... i guess same can be used here. On 28 Dec 2014 16:13, kumar raja rajkumar.cs...@gmail.com wrote: which is like a table in database, and produces results for user queries. Data is: in txt file. ID, FIRSTNAME, LASTNAME, AGE, SALARY, TITLE 1, venkatesh, kumar, 21,

[algogeeks] Distributed System problem

2014-12-14 Thread atul anand
It is a system design problem . Suppose a http request is sent to server . Now Server maintains cache for fast retrieval . if link is present int the cache then it just takes a data from cache and return it to user but if not , then user will fetch that http address and then store it in its

Re: [algogeeks] Distributed System problem

2014-12-14 Thread atul anand
the Cache will point to the New NameServer .. Thanks, Somnath Singh On Sun, Dec 14, 2014 at 2:04 PM, atul anand atul.87fri...@gmail.com wrote: It is a system design problem . Suppose a http request is sent to server . Now Server maintains cache for fast retrieval . if link is present int

Re: [algogeeks] Openings in Adobe India !!!

2014-10-14 Thread Shashwat Anand
People seems to confuse algogeeks with job board. No idea, how can we get rid of these spam. On Tue, Oct 14, 2014 at 2:25 PM, Ashish Mehta mehta.ashis...@gmail.com wrote: There are multiple openings in Adobe India for Developer position. Send me your resume ASAP. Here is the list of urgent

Re: [algogeeks] DP problems

2014-06-05 Thread Shashwat Anand
I am not too sure about your O (N^3) solution even. Can you link the working code ? On Thu, Jun 5, 2014 at 6:48 PM, kumar raja rajkumar.cs...@gmail.com wrote: This is a very good collection of DP problems. I want the answers for problem 2(e) and problem 14. for problem 14 the recurrence

Re: [algogeeks] DP problems

2014-06-05 Thread Shashwat Anand
, and it works. On 5 June 2014 18:53, Shashwat Anand m...@shashwat.me wrote: I am not too sure about your O (N^3) solution even. Can you link the working code ? On Thu, Jun 5, 2014 at 6:48 PM, kumar raja rajkumar.cs...@gmail.com wrote: This is a very good collection of DP problems. I want

Re: [algogeeks] Re: Solving coin change problem with limited coins.

2014-05-16 Thread Shashwat Anand
@Don int coins [] = {1, 3, 5}; int cnt [] = {7, 3, 1}; int S = 9; Your code returns 9, for the aforementioned test case. Should not it return 3 ? Here is my take which takes O (|number of denominators| x |S| x |maximum count for any coin|) time and O (|number of denominators| x |S|) time. It

Re: [algogeeks] Re: Solving coin change problem with limited coins.

2014-05-15 Thread atul anand
@Don : i am intersted in DP bottom up approach with less time complexity. solving it recursively is a simpler approach... On 15 May 2014 22:25, Don dondod...@gmail.com wrote: How about this: const int N = 6; unsigned int coins[N] = {100,50,25,10,5,1}; unsigned int count[N] = {2, 1, 1, 5, 4,

[algogeeks] Solving coin change problem with limited coins.

2014-05-14 Thread atul anand
Solving coin change problem with limited coins. Given an array of denominations and array Count , find minimum number of coins required to form sum S. for eg: coins[]={1,2,3}; count[]={1,1,3}; i.e we have 1 coin of 1$ , 1 coin of 2$ , 3 coins of 3$. input S = 6 output = 2 possible

Re: [algogeeks] Remove minimum set of vertices to make the grap divided into more than one component

2014-04-29 Thread atul anand
find articulation point in graph On 29 Apr 2014 16:56, shashi kant shashiski...@gmail.com wrote: Problem is as follows: 1. Given a connected graph. 2. Remove a vertex out of it and if graph is divided into two components return that vertex. 3. else find a set of vertices to be removed that

Re: [algogeeks] Remove minimum set of vertices to make the grap divided into more than one component

2014-04-29 Thread Shashwat Anand
On Tue, Apr 29, 2014 at 10:33 PM, atul anand atul.87fri...@gmail.comwrote: find articulation point in graph It won't work. Say there are N nodes and every node is connected to every other node. This graph does not have any articulation point. You need to remove more than one vertex

Re: [algogeeks] Remove minimum set of vertices to make the grap divided into more than one component

2014-04-29 Thread Shashwat Anand
On Tue, Apr 29, 2014 at 4:56 PM, shashi kant shashiski...@gmail.com wrote: Problem is as follows: You have given a terrible description of problem. 1. Given a connected graph. Connected, how ? Is the graph directed or undirected ? 2. Remove a vertex out of it and if graph is divided

Re: [algogeeks] Re: maximum subsquare such that all four borders are filled black

2014-03-31 Thread atul anand
@Don: what is the point of considering s=2 when we have already found s=3.As question says find the maximum subsquare. Which is of size 3 and this the expected outcome. On Mon, Mar 31, 2014 at 11:28 PM, Don dondod...@gmail.com wrote: 00 00 010100 011100 01 00 In this

Re: [algogeeks] Re: maximum subsquare such that all four borders are filled black

2014-03-30 Thread atul anand
@don : According to question we want to find the maximum subsquare. can you give me test case for which this wont work? On Fri, Mar 28, 2014 at 9:41 PM, Don dondod...@gmail.com wrote: No, that is not the same. It won't find a square smaller than s. Don On Thursday, March 27, 2014

[algogeeks] explanation of solution required.

2014-03-30 Thread atul anand
Hello, i found this question online and its solution tooBut i am not able to fully understand the solution.Need your help to proof correctness of the algo. Question is as follows :- *Question:* *Given an array A and a number S', provide an efficient algorithm (nlogn) to find a number K

Re: [algogeeks] Re: maximum subsquare such that all four borders are filled black

2014-03-27 Thread atul anand
@Don : your algo time complexity is O(n^2) It can be reduced to this :- // Now look for largest square with top left corner at (i,j) for(i = 0; i n; ++i) for(j = 0; j n; ++j) { s = Min(countRight[i][j], countDown[i][j]); if (countRight[i][j]

Re: [algogeeks] Re: strictly sorting by adding or subtracting a range of numbers

2014-03-26 Thread atul anand
@bhargav : could you please explain your algorithmn On 3/25/14, bhargav krishna yb ybbkris...@gmail.com wrote: Even i completed it :). It was from one of the coding challenges... public class Hill { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated

[algogeeks] Data structure question

2014-03-08 Thread atul anand
1) - When u login, it retrieves all the unread mails only. Which data structure should you use ? 2)- If you get an event invitation then u have to be notified . eg if u have two event invitations, one is in the next hour and other one 2 months later, the one that is tomorrow will be given a

Re: [algogeeks] Integer partition problem - DP

2014-03-01 Thread atul anand
Problem is similar to coin change problem(i.e given an array of coins denomination , Find number of ways to create N Rupees).So given input K...fill up array from 1 to K.and use this array and a input to coin change problem On Sat, Mar 1, 2014 at 9:55 PM, kumar raja rajkumar.cs...@gmail.com

Re: [algogeeks] Integer partition problem - DP

2014-03-01 Thread Shashwat Anand
Let us assume you have sum S. The possible numbers it is made up are { 1, 2, .., S }. Now, for every number belonging to the set, you have two options. 1. Subtract currently chosen number from the given set to sum. 2. Choose next number. The state will be defined as (num, sum), where num is the

Re: [algogeeks] Permuations with stack constraints

2014-02-20 Thread Shashwat Anand
Think in binaries. '1' = push, '0' = pop. So a sequence of operations will consist of 0's and 1s. Say N = length of set. Property 1: count of 0 = count of 1 = N. There will be N push and N pop. Property 2: At any point count of 1s = count of 0s. 1100 is valid. [2 push, 2 pop.] 1001

Re: [algogeeks] Re: Find 3 digit number.

2014-02-13 Thread Shashwat Anand
@Don, amazing solution. Let us say, I don't have the insight to see the greedy solution mentioned by @Don there is an obvious dp solution for the general case. typedef long long int64; const int64 LINF = (int64) 1e16 + 5; map int64, int64 memo; int64 solve (int n) { if (n 10) return n;

[algogeeks] Find 3 digit number.

2014-02-12 Thread atul anand
Given a number N, find the smallest 3 digits number such that product of its digits is equal to N. For Eg:- for input 24 , output :138 (1*3*8 = 24) for input 36 , output :149 (1*4*9 = 36) for input 100 , output : 455 (4*5*5 = 100) -- You received this message because you are subscribed to the

Re: [algogeeks] Find 3 digit number.

2014-02-12 Thread Shashwat Anand
in range (100, 1001) if int (str (i) [0]) * int (str (i) [1]) * int (str (i) [2]) == N) 149 N = 100 min (i for i in range (100, 1001) if int (str (i) [0]) * int (str (i) [1]) * int (str (i) [2]) == N) 455 On Wed, Feb 12, 2014 at 8:45 PM, atul anand atul.87fri...@gmail.com wrote: Given a number N

Re: [algogeeks] Re: Generate random number from 1 to 10.

2014-02-07 Thread atul anand
@don : awesome +1 . I was not aware of George Marsaglia's Multiply With Carry generator. But it is soo clll . If you have any good link for its proof or explanation of the idea behind it then please mention it. I never knew generating random number can be few lines of code :) Thanks :)

Re: [algogeeks] Re: Generate random number from 1 to 10.

2014-02-06 Thread atul anand
@don: algo look fine..i tested it ,but it did not generate 1-10 with probabilty of 1/10 everytime. actually question was asked in an intrview. question started with displaying all elements in an array randomly without repetition i.e only once( probabilty 1/10)...which can be done with fisher yates

[algogeeks] Generate random number from 1 to 10.

2014-02-01 Thread atul anand
Generate random number form 1 - 10 with probability of 1/10.You are not allowed to used rand() function. any simple way of achieving above with using any complex implementation of random number generators algorithm . -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] strictly sorting by adding or subtracting a range of numbers

2014-01-29 Thread Shashwat Anand
How about a normal binary search ? We know that X can be [0, 2^31 - 1]. Also if X is a valid configuration, all the values above X will too. Monotonicity is all we need here. So, take lo = 0 and hi = 2 ^ 31 - 1. Now check, if your mid is a valid X. If yes, X can lie between [0, mid]. If not, X

[algogeeks] changing structure of binary tree based on gravity and node selected.

2014-01-14 Thread atul anand
Imagine a binary tree lying on the floor with nodes as balls and edges as threads, you are given a pointer to a node. When you pick the tree from that node up what will be the structure of the tree. You have gravity changing the structure of the tree -- You received this message because you are

[algogeeks] Solving equation

2014-01-11 Thread atul anand
Hello, How to solve an equation with one unknown variable ? operator allowed are : + , - for eg . input could be :- x + ( 5 + 4 ) = 6 (x - 7) + 7 = (x + 1) - 5 If operator also allows * (multiply) , then what change in algorithm is required. -- You received this

Re: [algogeeks] Job Openings at Adobe India

2014-01-08 Thread Shashwat Anand
We need active moderators who can ban these guys spamming the list. This group deals with algorithm problems, we don't need salesmen and brokers here. On Wed, Jan 8, 2014 at 1:42 PM, RM rmath...@gmail.com wrote: Job postings to this mailing list should be marked as spam, and the senders

Re: [algogeeks] Re: Median Finding in Sorted Arrays

2014-01-06 Thread atul anand
@dave : could you provide pseudo code for ur approach On 6 Jan 2014 07:39, Dave dave_and_da...@juno.com wrote: Use a binary search. Assume that you have arrays a[m] and b[n] sorted in ascending order. If a[i] is the kth smallest element, then b[k-i-2] must be smaller than a[i], and b[k-i-1]

Re: [algogeeks] coloring problem Dynamic programming

2013-12-28 Thread atul anand
. i am not able to understand , how it is taking care that 3 adjacent are colored different. could you please clarify my doubt. On Thu, Dec 26, 2013 at 5:25 PM, Saurabh Paliwal saurabh.paliwa...@gmail.com wrote: @atul anand :- no, we need not use all the colors. @kumar raja :- sorry dude

Re: [algogeeks] D

2013-12-26 Thread Shashwat Anand
Yes, we know now that you are a proud owner of Apple iPod. On Fri, Jan 2, 1970 at 9:32 AM, Chitra chitradevi.ramachand...@gmail.comwrote: Sent from my iPod -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group

Re: [algogeeks] coloring problem Dynamic programming

2013-12-18 Thread atul anand
@kumar : i have one doubt regarding this question.Do we have to use all K colors[K] to color all building. for example :- color[3]={1,2,10}; now if we have to color 6 building then i can use only 1st 2 color to color all building and never 10 ...is this allowed ??? building[N]={1,2,1,2,1,2}

Re: [algogeeks] coloring problem Dynamic programming

2013-12-17 Thread atul anand
@saurabh : answer[i][j] = min(answer[i-1][t]) + colorvalue[t] where t varies from 1 to k except j. how this DP is taking care of the case where no adjacent house if of same color. what i understand from the DP is the following :- find minimum cost of coloring previous house with color t (

Re: [algogeeks] coloring problem Dynamic programming

2013-12-17 Thread atul anand
ohh shoots...my bad.got this condition wrong t varies from 1 to k except j. now got it :)..ignore my previous comment :) :) On Tue, Dec 17, 2013 at 11:47 PM, atul anand atul.87fri...@gmail.comwrote: @saurabh : answer[i][j] = min(answer[i-1][t]) + colorvalue[t] where t varies from 1

Re: [algogeeks] [Algogeeks] Longest increasing sub sequence length in linear time

2013-12-16 Thread atul anand
can be done with nlogn i dont think so O(n) is possible... On 17 Dec 2013 01:30, bujji jajala jajalabu...@gmail.com wrote: Given an Array of integers (A1,A2,...,An) of length n, Find the maximum possible length of increasing sub sequence formed from A1, A2,,An. I read that it is

Re: [algogeeks] [Algogeeks] Longest increasing sub sequence length in linear time

2013-12-16 Thread Shashwat Anand
On Tue, Dec 17, 2013 at 1:30 AM, bujji jajala jajalabu...@gmail.com wrote: Given an Array of integers (A1,A2,...,An) of length n, Find the maximum possible length of increasing sub sequence formed from A1, A2,,An. I read that it is possible to compute in linear time as mentioned in

Re: [algogeeks] Re: Saving and restoring Binary trees in files

2013-11-13 Thread atul anand
@Don : +1 ..got it ..thanks On Wed, Nov 13, 2013 at 10:35 PM, Dave dave_and_da...@juno.com wrote: @Don: Excellent solution. It requires little extra data to be stored, and it is easy to implement. Dave On Wednesday, November 13, 2013 9:31:47 AM UTC-6, Don wrote: The data file contains

Re: [algogeeks] Re: Saving and restoring Binary trees in files

2013-11-11 Thread atul anand
@don : i did not get it , what will be data in file? On Mon, Nov 11, 2013 at 10:14 PM, Don dondod...@gmail.com wrote: Save in preorder, tagging each node with two bits indicating if that node has a left and right subtree. Then rebuild like this: Tree rebuild() { Tree result =

Re: [algogeeks] Re: Saving and restoring Binary trees in files

2013-11-08 Thread atul anand
@don : it is not BST , it is binary tree ...so your approach will not work in this case. @kumar : save pre-order and in-order traversal with some delimiter in b/w traversals. pre-order : a b c d e in-order : c b e a d write in file :- a b c d e # c b e a d now use pre-order and in-order

Re: [algogeeks] Message distribution through rooted tree dynamic programming

2013-10-31 Thread atul anand
we can first count number of nodes in a subtree below each node.Now transfer message to max(count(root-left),count-root-right); On 11/1/13, kumar raja rajkumar.cs...@gmail.com wrote: Suppose we need to distribute a message to all the nodes in a rooted tree. Initially, only the root node knows

Re: [algogeeks] variation of LIS problem

2013-10-28 Thread atul anand
using idea mentioned in below link , we can solve this similar problem in O(n^2*k). http://stackoverflow.com/questions/12862077/number-of-increasing-strings-of-length-k On 10/26/13, atul anand atul.87fri...@gmail.com wrote: @saurabh : i did not get ur algo...can you please explain

Re: [algogeeks] variation of LIS problem

2013-10-26 Thread atul anand
wont be greater than O(n logn). So it is bounded by O(nlogn) . In the worst case it might go up to O(n^2). But i am not sure of this. On 25 October 2013 00:17, atul anand atul.87fri...@gmail.com wrote: OK, i got now why you were using min-heap. now consider this example

Re: [algogeeks] variation of LIS problem

2013-10-24 Thread atul anand
) a[i] delete root in min- heap inseart a[i] in min - heap at the end of main loop the min-heap will contain the final sequence. On Thu, Oct 24, 2013 at 8:50 AM, atul anand atul.87fri...@gmail.comwrote: @Saurabh Paliwal : yes On 10/24/13, Saurabh Paliwal saurabh.paliwa...@gmail.com

Re: [algogeeks] variation of LIS problem

2013-10-24 Thread atul anand
, but min heap is used for storing the largest elements. So it is preferable DS, On Thu, Oct 24, 2013 at 8:35 PM, atul anand atul.87fri...@gmail.com wrote: @pankaj : how can you maintain increasing sub-sequence using heapyour soln is for finding finding K largest element in the array...so

Re: [algogeeks] variation of LIS problem

2013-10-24 Thread atul anand
insert because temp = 100 and 30temp insert 8 cant insert temp = 100 and 8temp (500temp)size of heap ==4 so delete root of min-heap(which is 2) insert 555 now if i check the heap elements {5, 10, 100 , 555} On Thu, Oct 24, 2013 at 11:25 PM, atul anand atul.87fri...@gmail.comwrote: in your

[algogeeks] variation of LIS problem

2013-10-23 Thread atul anand
Given an array with N elements and integer K . Find sum of longest increasing sub-sequence of length K elements such that sub-sequence found is maximum among all K max su-sequence. Eg arr[]={5,2,1,10,9,30,8,55} K = 3 output : 10,30,55sum = 10+30+55 = 95 if K=4 output : 5,10,30,55 sum =

Re: [algogeeks] variation of LIS problem

2013-10-23 Thread atul anand
@Saurabh Paliwal : yes On 10/24/13, Saurabh Paliwal saurabh.paliwa...@gmail.com wrote: Do you mean *of all the increasing subsequences of length k in this array, find the one with maximum sum ?* On Wed, Oct 23, 2013 at 10:52 PM, atul anand atul.87fri...@gmail.comwrote: Given an array

Re: [algogeeks] Breaking a string problem (Dynamic programming)

2013-10-16 Thread atul anand
Question seems similar to matrix chain multiplication problemhere you need to find min cost.. Recurrence for this could be the following , please validate it. DP(i,j) = j + (j - i) * min( DP(i , k) , DP(k, j) ) for all i k j i j On Sat, Oct 12, 2013 at 12:54 PM, kumar raja

[algogeeks] Generating random number without using rand()

2013-10-10 Thread atul anand
Hello, Given integer N , How to generate random number from 0 to N without using rand() function. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [algogeeks] Find the max element of sets of size K

2013-09-19 Thread atul anand
question is different...here we have to find max of k elements in the window..not max subarry of size kfoe eg input is say ... 1 4 5 66 7 9 and k=3 then output should be (1,4,5) = 5 (4,5,66) = 66 (5,66,7)=66 (66,7,9)=66 output - 5,66,66,66 On 19 Sep 2013 19:00, igor.b...@gmail.com

Re: [algogeeks] determine if 2 BSTs will be identical or not based on input order of its keys

2013-07-06 Thread atul anand
http://www.geeksforgeeks.org/check-for-identical-bsts-without-building-the-trees/ On Thu, Jun 6, 2013 at 11:27 AM, Sambhavna Singh coolsambha...@gmail.comwrote: I came across this question on careercup: how do we go about finding whether the BSTs formed by the given input order would be

Re: [algogeeks] Spoj FARIDA

2013-05-22 Thread Shashwat Anand
On Wed, May 22, 2013 at 9:45 AM, emmy foramlakh...@gmail.com wrote: problem : http://www.spoj.com/problems/FARIDA/ what is wrong with this code? The algorithm is pretty straight forward Is it ? 1000 1 1 1000 Your code gives 1001 as output. Desired output should be 2000. -- You received

Re: [algogeeks] amazon f2f round question ..

2013-05-12 Thread atul anand
@karthikeyan : It is an acyclic graph not a binary tree. your solution will work if given graph is a binary tree. problem can be solved using dfs as suggested above On 5/11/13, Karthikeyan V.B kartmu...@gmail.com wrote: Since it is an acyclic graph, find the appropriate node that can be the

Re: [algogeeks] amazon f2f round question ..

2013-05-12 Thread atul anand
) or (a)-(c) which is wrong. On 5/12/13, Karthikeyan V.B kartmu...@gmail.com wrote: @atul anand : acyclic graph can be converted to a tree using prim/kruskal or by finding an appropriate node that can act like the root of a tree On Sun, May 12, 2013 at 5:55 PM, atul anand atul.87fri...@gmail.com

Re: [algogeeks] Re: Find the number of islands/connected components

2013-04-26 Thread atul anand
{*1*,* 1*, 0, 0, 0}, {0, *1*, 0, 0, *1*}, {*1*, 0, 0, *1*, *1*}, {0, 0, 0, 0, 0}, {*1*, 0, *1*, 0, *1*} above different set of color represent different island.Simple DFS is

Re: [algogeeks]

2013-04-24 Thread atul anand
//code sketch row_len=R; col_len=C; r_start=0,col_start=0; while (x R*C) { for i=r_start to col_len keep extracting value from 1D and add it to mat[r_start][i]=arr[p++]; r_start++; for i=r_start to row_len keep extracting value from 1D and add it to mat[i][col_len]=arr[p++];

Re: [algogeeks] Re: Amazon interview question

2013-04-13 Thread Shashwat Anand
coefficient of T is 0, to make it O(1) solution. That does not seems to be the case here. Say, for 4th iteration, what will be your answer ? I don't see any closed form here. On Wed, Apr 10, 2013 at 7:03 AM, Shashwat Anand m...@shashwat.me mailto:m...@shashwat.me wrote: On 4/10/13

Re: [algogeeks] Re: Amazon interview question

2013-04-09 Thread Shashwat Anand
On 4/10/13 12:13 AM, rahul sharma wrote: If you have any other solution ..please post that...i thnik recursion is ok with base case...we need to scan again after first iteration...?? First of all, the array size and number of iteration both won't be N or else the answer will always be 0. I take

Re: [algogeeks] [Algorithm] Get Target

2013-04-04 Thread atul anand
are we allowed to use operation only once or multilpe times? On Fri, Mar 22, 2013 at 6:27 AM, prankur gupta duke.lnm...@gmail.comwrote: Hi All, Could you help me this question. This was asked at Yelp Interview. Given 6 integers and 1 target value, write a function to get the target value

Re: [algogeeks] Re: how to solve this?

2013-04-04 Thread Shashwat Anand
@Dave solution is perfect. I prefer it over mind. However, here is an alternate solution. We know that this is an equation in 'x' with a degree of 1. It means it is a straight line and root is guaranteed unless of course the equation is of the form y = c. That is not the case here as it would

Re: [algogeeks] Re: Median in stream of running integers

2013-03-25 Thread atul anand
@rahul : yes On 3/24/13, rahul sharma rahul23111...@gmail.com wrote: So we need to implement prelocate down for deletion? On Sunday, March 24, 2013, atul anand atul.87fri...@gmail.com wrote: yeah implementation is wrong. On 3/24/13, tec technic@gmail.com wrote: The heap implementation

Re: [algogeeks] Least Common Ancestor in STL MAP

2013-03-22 Thread Shashwat Anand
On 3/21/13 5:02 PM, Avinash wrote: Given a STL map, say mapint, bool m1. Given two value a b that may or may not exists in m1. Find the Least Common Ancestor in STL MAP. Remember you don't have access to root, so you need to iterate using iterator. Use the methods/function of MAP forex begin,

Re: [algogeeks] Leaf nodes from inorder traversal

2013-03-16 Thread Shashwat Anand
Ambiguity lies in the heart of this question. If you are given a tree and you want to look for leaf nodes you can simply do an inorder traversa, and check for leaf nodes. Time complexity will be O(N) and space complexity will be O(log N). void getLeafNodes (node *root) { if (! root)

Re: [algogeeks] FInd unique element.

2013-02-21 Thread atul anand
use hashmap On Fri, Feb 22, 2013 at 12:58 AM, marti amritsa...@gmail.com wrote: How do I Find the Unique Element that Appears exactly k Times in an Array? the problem is given an integer array, only one integer appears* k* times, all the other integers appears *m* times in the array

Re: [algogeeks] Question

2013-02-17 Thread atul anand
related to this problem, link given below :- http://groups.google.com/group/algogeeks/browse_thread/thread/7cfb0a6f7d121d92/0adc692fad1bab40?hl=enlnk=gstq=DP+equation+for+interval+problem#0adc692fad1bab40 -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] Pointers Usage

2013-01-02 Thread atul anand
@shady : It allows us to allocate m/m dynamically ..which in itself is very big advantage. m/m consumption can be ignored , if you compare with the flexibility it provides. eg:- int *arr=(int *)malloc(sizeof(int) * 100); now m/m consumption here is 100*4+8;// extra 8 wont hurt if you compare

Re: [algogeeks] Trie Implementaion Issues

2012-12-27 Thread atul anand
executed your code..working fine by commenting cmnt2 and un-commenting cmnt1 --

Re: [algogeeks] Re: Coin denomination

2012-12-24 Thread atul anand
It can be solved using DP here is the recurrence eqn:- coin[ i ] = 1+coin[ i - denom( j ) ] if i =1 and 1 j ArrayLen(denom) base cases :- c[ i ]= inf if j 0 c[ i ] = 0 if j==0 On 12/23/12, Dave dave_and_da...@juno.com wrote: @Shady. That still didn't answer my

Re: [algogeeks] Re: Coin denomination

2012-12-24 Thread atul anand
correction above :- It can be solved using DP here is the recurrence eqn:- coin[ i ] = 1+ min{ coin[ i - denom( j ) ] } if i =1 and 1 j ArrayLen(denom) base cases :- c[ i ]= inf if i 0 c[ i ] = 0 if i==0 --

Re: [algogeeks] Sieve

2012-12-19 Thread atul anand
i had implemented Sieve of Eratosthenes long time back... what i did was the following :- say N is the range and we want to find all prime number within this range. take size of temp array[] to half = N/2...as we only care of odd numbers.Prime number 2 can be handled explicitly. run outer loop

Re: [algogeeks] reverse a string efficiently

2012-11-26 Thread atul anand
considering '+' , here will take Cn time . Here '+' is for concatenate , now this concatenation taking place in constant time?? , i dont think so..internally it will be adding elements to new m/m space and for that it need to traverse each character...so it will take cn time. so T(n) =T(n/2) + cn

Re: [algogeeks] fastest sequential access

2012-11-21 Thread atul anand
@shady : as subject says fastest sequential access , then if i am not getting it wrong.we only care of sequential access a value not modifying the linked list. so i guess double linked list would be helpful 1) bcozz it can move in both the direction , so if linked list is sorted then it would be

Re: [algogeeks] Repeating element with constraints

2012-11-19 Thread atul anand
rushi4...@gmail.comwrote: @atul : In the second for loop...temp will also contain one which is being missing along with the one which is being repeated. kindly check it once again. On Mon, Nov 19, 2012 at 11:44 AM, atul anand atul.87fri...@gmail.comwrote: array has all distinct

Re: [algogeeks] Repeating element with constraints

2012-11-18 Thread atul anand
array has all distinct elements ans lie b/w 1 to n , now bcozz they are all distinct except 1 element means it should have all element with range 1 to n...except 1 element , which can be any element b/w 1 to n. temp=arr[0] *for i=1 to n temp=temp^arr[i]; * //now temp will contain all distinct

Re: [algogeeks] Tree - sum problem

2012-11-17 Thread atul anand
from each node , make 4 recursive call 1) you consider this node as part of the solution i.e left=target - currentNode-data is passed , and consider current-left for next recursion 2)you consider this node as part of the solution i.e left=target - currentNode-data is passed , and consider

Re: [algogeeks] Advice needed

2012-11-15 Thread atul anand
use enum On Sat, Oct 27, 2012 at 3:21 AM, rahul sharma rahul23111...@gmail.comwrote: There is question asked like O/p of following in C(32 bit OS) #include iostream #includestdio.h using namespace std; bool IsEqual(char * a) { printf(abc); return true; } int main() {

Re: [algogeeks] Check if a binary tree is Binary Search Tree or not.

2012-11-06 Thread atul anand
@vishal : as discussed in previous post , your solution wont work for certain test cases...and i dont think so , checking tree in inorder way is complex .It is simple to implement , you just need to call tree recursively in Inorder way and keep track of prev node and compare prev node with

Re: [algogeeks] Check if a binary tree is Binary Search Tree or not.

2012-11-06 Thread atul anand
@vaibhav : by not using extra space...i guess you mean that you were not allowed to use one extra pointer.bcozz space complexity will remain constant for inorder approch. On Tue, Nov 6, 2012 at 1:07 AM, vaibhav shukla vaibhav200...@gmail.comwrote: yes ofcourse... dats the easiest i suppose...

Re: [algogeeks] Re: Check if a binary tree is Binary Search Tree or not.

2012-11-05 Thread atul anand
@Don : your algo wont work for following tree :- 30 / \ 20 31 / \ 9 41 above tree is not a BST bcozz here 41 should lie on the right side of the 30but it is not. so we need to keep track of max and min as we move left or right part of the tree.and each node

Re: [algogeeks] Time Complexity Analysis

2012-11-05 Thread atul anand
building tree will take O(n) time but for each node we need to find max i.e i = max (inorder, start, end); so complexity in worst case will we O(n^2). On Tue, Nov 6, 2012 at 12:26 AM, shady sinv...@gmail.com wrote: Sorting takes linear time, but it doesnt get repeated n times, it is like -

Re: [algogeeks] swap objects without temp variable

2012-11-04 Thread atul anand
a=a^b; b=a^b; a=a^b; need to check if a and b are equal or not , bcozz a^a =0 On Mon, Nov 5, 2012 at 2:02 AM, manish narayan.shiv...@gmail.com wrote: Swapping two objects (not integers/chars),without using temp...? my solution is using xor operation..is that right and ny other solutions ?

Re: [algogeeks] You are given two 32-bit numbers, N and M, and two bit positions, i and j.

2012-10-31 Thread atul anand
check out my comment ...i had posted it log time back on geekforgeeks...search for atull007 int the below link. let me know it does not work http://www.geeksforgeeks.org/forum/topic/adobe-interview-question-for-software-engineerdeveloper-fresher-about-bit-magic-1 On Thu, Nov 1, 2012 at 4:00 AM,

Re: [algogeeks] Informatica written que : C output

2012-10-30 Thread atul anand
its seem to me that output buffer is not flushing ..to do so you need to add \n while printing hello i.e printf(Hello\n); it was working for you when the else {} part was un-commented because you are using \n in this statement //printf( %d - %d \n , tmp[i], count); -- if you remove \n from

Re: [algogeeks] C Macro

2012-10-29 Thread atul anand
...@gmail.comwrote: its now doing swapping of pointers...plz explain On Sun, Oct 28, 2012 at 8:08 PM, atul anand atul.87fri...@gmail.comwrote: it should swap On 10/28/12, rahul sharma rahul23111...@gmail.com wrote: Why the following code is not able to swap two macros???although it is easily

Re: [algogeeks] C Macro

2012-10-29 Thread atul anand
() { float a,x; a=20.0; x=30.0; float *p,*q; p=a,q=x; swap(p,q,float*); printf(%f %f,a,x); getchar(); } o/p=20.000 30.000 why not swapped??? On Mon, Oct 29, 2012 at 11:01 PM, atul anand atul.87fri...@gmail.comwrote: if you think the your expanded version is incorrect.You are wrong

Re: [algogeeks] four umbers sum to given value

2012-10-28 Thread atul anand
becoz you are sorting the aux[] , it seems to fine by replacing it with i j On 10/28/12, rahul sharma rahul23111...@gmail.com wrote: I wana ask that ccan i replcae while condiion with the condition as follow while(ij) code reference :http://www.geeksforgeeks.org/archives/23338 void

Re: [algogeeks] C Macro

2012-10-28 Thread atul anand
it should swap On 10/28/12, rahul sharma rahul23111...@gmail.com wrote: Why the following code is not able to swap two macros???although it is easily swapping 2 variables #includestdio.h #define swap(a,b,c) c t;t=a,a=b,b=t int main int x=10,y=20; int *p,*q; swap(x,y,int);

Re: [algogeeks] C Macro

2012-10-28 Thread atul anand
didnt get you... first it was now working , now its working...!!! please write clearly about your doubts. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from

Re: [algogeeks] Design a method to find the frequency of occurrences of any given word in a book.

2012-10-24 Thread atul anand
Trie or hash map can b used On 10/24/12, rahul sharma rahul23111...@gmail.com 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

Re: [algogeeks] adobe questions

2012-10-23 Thread atul anand
use hash map...with key as original node and value as duplicate of this node duplicate node next and random pointer is set to NULL initially. now traverse whole linked list keep on adding node. after this do another traversal of orig linked list taking key as orig node ..duplicate=fetch

Re: [algogeeks] fibonicci recursive help

2012-10-21 Thread atul anand
http://www.geeksforgeeks.org/archives/10120 On 10/21/12, rahul sharma rahul23111...@gmail.com wrote: Guys i have read an article somewhere regarding optimization of recursive fibonicci so that we donot need to calculate the sum that we have already calculated... In case if factorial,we donot

Re: [algogeeks] Longest increasing subsequence

2012-10-21 Thread atul anand
@rahul : nope it wont work ..check for this input :- input = 1, 2,3,6,4 ,101, 6 by removing msis[i] msis[j] + arr[i] condition then you are excluding the max sub-sequence found from j=0 to i. On 10/21/12, rahul sharma rahul23111...@gmail.com wrote: but if there are -ve numbers then

Re: [algogeeks] fibonicci recursive help

2012-10-21 Thread atul anand
google searched it : geeksforgeeks + Fibonacci number ;) ;) On 10/21/12, rahul sharma rahul23111...@gmail.com wrote: thnx a lot atul...was looking for that only...can u plz tell me under which section u get this post On Sun, Oct 21, 2012 at 4:03 PM, atul anand atul.87fri...@gmail.com

Re: [algogeeks] Microsoft Interview Question

2012-10-16 Thread atul anand
][1] - M[1][1]- M[1][0]- M[0][0]- M[0][1] -- CYCLE how you will avoid these cycles... On Tue, Oct 16, 2012 at 8:58 AM, atul anand atul.87fri...@gmail.comwrote: http://www.geeksforgeeks.org/archives/13376 On Tue, Oct 16, 2012 at 8:56 AM, atul anand atul.87fri...@gmail.comwrote: can

Re: [algogeeks] Re: Microsoft Interview Question

2012-10-16 Thread atul anand
@jaspreet : i dont find much difference between using BFS or backtracking...which is doing similar to DFS. On Tue, Oct 16, 2012 at 4:28 AM, Jaspreet Singh jassajjassaj...@gmail.comwrote: BFS On Sun, Oct 14, 2012 at 4:21 PM, Rahul Kumar Patle patlerahulku...@gmail.com wrote: response

  1   2   3   4   5   6   7   8   9   >