Re: [algogeeks] CODECHEF FLIP COIN problem

2011-02-08 Thread Gaurav Saxena
If we make segments of the range of coins which are heads then in some case the result will become alternate which could be more inefficient. Any idea what time complexity will suffice ? Could you please elaborate your reply . On Tue, Feb 8, 2011 at 1:08 PM, sunny agrawal

Re: [algogeeks] CODECHEF FLIP COIN problem

2011-02-08 Thread sunny agrawal
i think time complexity of the O(nlgn) for an avg case will suffice no it will not be inefficient if we keep sufficient information at each node each node will keep information of all its childs(headCount) and using some optimizations such as if two flips on same range occur simultaneously, then

Re: [algogeeks] CODECHEF FLIP COIN problem

2011-02-08 Thread Gaurav Saxena
Actually I could not figure out any good way of doing this . [?][?] Could you please suggest me something or give some idea . Thanks for helping On Tue, Feb 8, 2011 at 1:51 PM, sunny agrawal sunny816.i...@gmail.comwrote: i think time complexity of the O(nlgn) for an avg case will suffice no

Re: [algogeeks] CODECHEF FLIP COIN problem

2011-02-08 Thread sunny agrawal
make a tree where each node have the following structure 1. rangeLow 2. rangeHigh 3. headCount of its complete subTree 4. boolean variable change, if true means all nodes of that subtree need to be flipped but we are not flipping in the hope if again a flip occur we can reset the flag and we can

[algogeeks] Re: Find all the subset of an array whose sum is equal to some number

2011-02-08 Thread bittu
isn't the problem of of genrating all subset e.g. power set in that power set we have check which subset has the sum value equal to given sum thats it... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] Re: fedora 12

2011-02-08 Thread mittal
search on google for unetbootin. this will help you to create a bootable pen drive from the iso file for any linux distribution. Mohit Mittal -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: array(amazon microsoft)

2011-02-08 Thread September5th
How do you handle this condition??? 1 2 3 2 4 5 3 6 7 3 is smaller than 4~ On Feb 8, 2:48 am, arpit busy in novels arpitbhatnagarm...@gmail.com wrote: after a bit analysis i stick strongly to my soln : 0 1 2 3                        since element of last row column will always be

[algogeeks] Re: array(amazon microsoft)

2011-02-08 Thread September5th
Merge sort with divide and conquer: suppose n by n array, Method 1. 1- Get sorted top half and sorted bottom half, (To get sorted top half and sorted bottom half, recursively using this process) 2- and merge them together. Time complexity: T(n * n) = 2 * T(n/2 * n) + n * n [until only 2 rows

Re: [algogeeks] Re: array(amazon microsoft)

2011-02-08 Thread arpit busy in novels
take 1st as 763 2nd as 753 merge them k[]=76533 take 42 as 1st 42 as 2nd merge as l[] 422 now merge k l as 7654332 add 2 ie a[00] always lowest On Tue, Feb 8, 2011 at 5:47 PM, September5th hi.ming...@gmail.com wrote: How do you handle this

[algogeeks] Re: array(amazon microsoft)

2011-02-08 Thread Dave
@Jalaj: An efficient algorithm follows: 1. Using a data structure (int value, int row, int col), place the first column of the array into a minheap. Because the columns are sorted, the data can simply be copied in order, with row and column numbers appended; no heap ordering operations will be

Re: [algogeeks] Re: array(amazon microsoft)

2011-02-08 Thread yv paramesh
as per my analisys sort elements diagonally in the 2d arry. we can define diagonals by a[0,i] to a[i,0] is a[0,i],a[1,i-1],a[2,i-2],.. a[i-1,1],a[i,0], sort the elements if i col_size then diagonal is a[0,i] is define as a[0,i],a[1,i-1],a[2,i-2]...a[x,i-x] where

Re: [algogeeks] Re: array(amazon microsoft)

2011-02-08 Thread jalaj jaiswal
using merge sort takes lot of space complexity. alternaticely we can solve it using a min- heap let the array be 0 1 2 0 2 3 1 3 4 then first of all insert top left elemnt in heap(guranteed to be minimum) heap contans {0} then and insert elements just greater then i.e to the right and below to

Re: [algogeeks] CODECHEF FLIP COIN problem

2011-02-08 Thread Gaurav Saxena
Hey thanks for your help I have written a code using range trees but I am still getting TLE [?][?][?] Please suggest me something Here is my code /* * File: main1.c * Author: gs * * Created on 8 February, 2011, 7:46 PM */ #include stdio.h #include stdlib.h #define MAX 30 #define

Re: [algogeeks] CODECHEF FLIP COIN problem

2011-02-08 Thread Ankur Khurana
try lazy propogation On Tue, Feb 8, 2011 at 8:14 PM, Gaurav Saxena grvsaxena...@gmail.comwrote: Hey thanks for your help I have written a code using range trees but I am still getting TLE [?][?][?] Please suggest me something Here is my code /* * File: main1.c * Author: gs * *

Re: [algogeeks] Re: fedora 12

2011-02-08 Thread SUDHIR MISHRA
o k---thanks mittal -- Thanks Regards...* *Sudhir Mishra *IT 3rd YEAR* *Motilal Nehru National institute Of Technology-ALLAHABAD. * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: one more from amazon

2011-02-08 Thread Gajendra Dadheech
@shashank i think there are some duplicate outputs by this algorithm (112,211)... Thanks and regards, Gajendra Dadheech On Mon, Feb 7, 2011 at 2:29 PM, bittu shashank7andr...@gmail.com wrote: @gajendra i found that its basically combination problem we have to print all combination of all

[algogeeks] required .net developer

2011-02-08 Thread stive dwlabs
*please send matching profile to st...@dwlabs.com* Need . net developer Location: Syracuse, NY Duration:6+months Skills: . Must have prior experience developing within C# 3.5 and/or 4.0 framework. Must also have experience developing desktop applications (WPF). -- You received this

[algogeeks] Re: array(amazon microsoft)

2011-02-08 Thread algoseeker
I am not very sure about the correctness of this procedure. But my approach would be as follows: Concept: Maintain a set of numbers in which you maintain the values along with its array indices, such that the next number in the sorted output will be a part of this set. Consider the set

[algogeeks] Re: array(amazon microsoft)

2011-02-08 Thread algoseeker
Just coded the solution, it worked on all the test cases described here in this thread using the algo i described above :) The code is available at https://github.com/algoseeker/Interview/tree/master/sorting -- You received this message because you are subscribed to the Google Groups

[algogeeks] Puzzle For Puzzled Minds

2011-02-08 Thread bittu
This is an altogether different one in the same scenario. You have to make 125 packets of sugar with first one weighing 1 kg, second 2 kg, third 3 kg etc ...and 125th one weighing 125kg.You can only use one pan of the common balance for measurement for weighing sugar, the other pan had to be used

[algogeeks] Puzzle Will Stuck

2011-02-08 Thread bittu
There are N doors in a row numbered from 1 to N. Initially all are closed. Then you make N passes by the N doors. In pass 1 you toggle the all the doors (1,2,3,4)starting from the first door. In the second pass you toggle every second door(2,4,6,8,...). In the third pass you toggle all third

Re: [algogeeks] Puzzle Will Stuck

2011-02-08 Thread sunny agrawal
finally all square number gates will be open On Wed, Feb 9, 2011 at 2:10 AM, bittu shashank7andr...@gmail.com wrote: There are N doors in a row numbered from 1 to N. Initially all are closed. Then you make N passes by the N doors. In pass 1 you toggle the all the doors (1,2,3,4)starting

Re: [algogeeks] Puzzle Will Stuck

2011-02-08 Thread Rajeev Kumar
u can find more explanation here: http://www.techinterview.org/post/526370758/100-doors-in-a-row On Tue, Feb 8, 2011 at 12:52 PM, sunny agrawal sunny816.i...@gmail.comwrote: finally all square number gates will be open On Wed, Feb 9, 2011 at 2:10 AM, bittu shashank7andr...@gmail.com wrote:

Re: [algogeeks] Re: array(amazon microsoft)

2011-02-08 Thread Ujjwal Raj
I see a scope of optimization in the algo. In step 2. Before inserting the element a[i][j], you can make sure that a[i][j-1] and a[i-1][j] are in the set. If not then do no insert a[i][j] in the heap. (considering the boundary condition, if j-1 0 or i-1 0 then assume it is true) Correct me if I

[algogeeks] Re: Puzzle For Puzzled Minds

2011-02-08 Thread Dave
@Bittu: Since you didn't say what the weights are, I presume that I can choose the weights. So I simply choose 125 1 kg weights. Then I can weigh the required sugar packets with 125 weight movements: simply add a 1 kg weight for each subsequent sugar packet. Further presuming that this is not the

[algogeeks] Meetings puzzle

2011-02-08 Thread Sachin Agarwal
Suppose I have a room and I want to schedule meetings in it. You're given a list of meeting start and end times. Find a way to schedule the maximum number of meetings in the room. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] amazon

2011-02-08 Thread jalaj jaiswal
Place N number from 1 to N, in 2N positions in such a way so that there are Exactly “a” number of cells between two placed locations of number “a”. Write a program to display numbers placed in this way. Example:- (1) One of the possible placement for 7 numbers in 14 positions is : 5 7 2 3 6 2 5

Re: [algogeeks] Meetings puzzle

2011-02-08 Thread Ujjwal Raj
Use dynamic programming: 1) Sort the events in order of finishing time. f1, f2, f3, f4, ... fn E(fn) = E(sn) + 1; Solve the above recursion sn is start time of event n On Wed, Feb 9, 2011 at 11:30 AM, Sachin Agarwal sachinagarwa...@gmail.comwrote: Suppose I have a room and I want to schedule

[algogeeks] Re: Meetings puzzle

2011-02-08 Thread Sachin Agarwal
didn't quite get it, can you please elaborate. thanks On Feb 8, 10:38 pm, Ujjwal Raj ujjwal@gmail.com wrote: Use dynamic programming: 1) Sort the events in order of finishing time. f1, f2, f3, f4, ... fn E(fn) = E(sn) + 1; Solve the above recursion sn is start time of event n On Wed,

Re: [algogeeks] Re: array(amazon microsoft)

2011-02-08 Thread Manmeet Singh
U using extra space, if you using extra space, simple C++ implementation will be use a priority queue and do BFS. On Wed, Feb 9, 2011 at 10:47 AM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: @algoseeker mine approach is also the same but m inserting the elements in a min heap and you in a

Re: [algogeeks] amazon

2011-02-08 Thread Jitesh Kumar
Can you give me solution for N=1 and N=2? I don't think that it is possible for every N. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send

[algogeeks] extendible hashing

2011-02-08 Thread jagannath
i want to implement extendible hashing for may major project.so the crux of the problem is to directly access the disk block without using the undelying os file system interface.one idea which comes to my mind is to build a virtual file system interface for my project but currently i want to avoid