Re: [algogeeks] What Data Structure to use ?

2011-10-30 Thread Aamir Khan
On Sun, Oct 30, 2011 at 1:17 AM, Aamir Khan ak4u2...@gmail.com wrote: In a university, students can enroll in different courses. A student may enroll for more than one course. Both students and courses can be identified by IDs given to them. Design a data structure to store students,

Re: [algogeeks] Re: Searching In a large file

2011-10-30 Thread ravindra patel
@Dave yes Dave, you got it right. I assumed that the problem is to find a missing number out of given 300 million consecutive (but not neccessarily ordered) 9 digit numbers. And so my algo looks strictly in the given range. Thanks, - Ravindra On Sun, Oct 30, 2011 at 2:30 AM, Dave

[algogeeks] coding round question

2011-10-30 Thread vikas kumar
There are a number of integer ranges say [ L, R]i denoting left and right of segment i, lets says we are given K such segments and we define one operation as move which makes our chosen segment to move either +1 or -1 so after move(i, +1) segment i will be [L+1, R+1]. There are some particular

[algogeeks] Unique partition

2011-10-30 Thread SAMMM
An array is given consisting of real integers , can hav repeatative elements , Now u need to find K partitions whose union will hav all the elements of the array , but the intersection of any pair of cannot hav K elements in common. Exam:- Array- 1 1 2 2 3 1 4 3 5 For K=3 the partition are :-

[algogeeks] Re: What Data Structure to use ?

2011-10-30 Thread WgpShashank
We Will Use Closed Addressing or Open hashing based approach which called saperate chaining and i think it will be sufficient solve it .isn't it Here is Approach. Let we have m students n course . Each student course have unique ID identified by it as well.we can use Associate data

Re: [algogeeks] coding round question

2011-10-30 Thread Siddhartha Banerjee
could you please explain the question in a bit more detail? especially the partThere are some particular numbers which are made using 4 or 7 : any combination of 4 and 7 are accepted. from what i understand of the question, there are some intervals given... we can move the intervals left or right

Re: [algogeeks] Unique partition

2011-10-30 Thread teja bala
*STEP-1* Construct a self balancing Binary Search Tree where in the nodes represents the elements of the given set.. *STEP-2* Depending on the K (no. of partitions) keep a counter k *STEP_3* * * If BST not empty continue to Step-4 else exit with failure.. *STEP-4* And while doing any

[algogeeks] Re: Unique partition

2011-10-30 Thread SAMMM
But how does it ensure tht the elements been removed wouldnot give the same set again -- You received this message because you are subscribed 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] Re: coding round question

2011-10-30 Thread vikas kumar
The question was from startup company verego (may be misspelled), you understood it in correct way. We are given 'k' number of ranges in the fashion L, R they are all integers in big ranges , (assume long long for the case) then we are given move operation defined as move( i, +1/-1) : so range

Re: [algogeeks] coding round question

2011-10-30 Thread aniket chatterjee
+1 On Sun, Oct 30, 2011 at 6:53 AM, Siddhartha Banerjee thefourrup...@gmail.com wrote: could you please explain the question in a bit more detail? especially the partThere are some particular numbers which are made using 4 or 7 : any combination of 4 and 7 are accepted. from what i

Re: [algogeeks] Re: Minimize bins

2011-10-30 Thread SAMM
I think DP approach with bounded knapsack algorithm can be used to ensure tht the first Bin of filled optimally then the second bin to be filled until no elements remains. On 10/29/11, ravindra patel ravindra.it...@gmail.com wrote: I dont think the greedy approach gives the optimal solution

[algogeeks] Maximize Subsquare

2011-10-30 Thread SAMMM
Suppose u have a square matrix, where every cell is filled with 0 or 1 . U need to find the maximum subsquare such that all four borders are filled with all 1s. Ex:- 1 0 0 1 1 0 1 0 1 1 1 0 0 0 1 0 1 1 0 1 1 1 1 0 1 0 0 1 1 1 Here the maximum square (3X3) possible is from the TOP LEFT (2 3) TO

Re: [algogeeks] Re: Unique partition

2011-10-30 Thread sunny agrawal
Is there any condition like all sets should have same no. Of elements On 10/30/11, SAMMM somnath.nit...@gmail.com wrote: But how does it ensure tht the elements been removed wouldnot give the same set again -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: Unique partition

2011-10-30 Thread SAMM
No there is no such condition ...just hav to make sure all the partitions are unique . The partitions can hav some elements ( K) in common but not the entire elements in a partition (Should be UNIQUE) . On 10/30/11, sunny agrawal sunny816.i...@gmail.com wrote: Is there any condition like all

Re: [algogeeks] Re: Unique partition

2011-10-30 Thread mohit verma
sort the array : O(nlogn) keep an array/map containing frequency of each element in sorted array : O(n) v[n/k][k] - 2-D array of ints containing final partitions. for i=1 to n/k { int count=0; for(j=0;jn count k;j++) { if( freq(a[i])==0) continue; //say array is used

[algogeeks] Dp solution for this problem?

2011-10-30 Thread mohit verma
Given a matrix you have to find the shortest path from one point to another within the matrix. The cost of path is all the matrix entries on the way. You can move in any direction (up, down, left, right, diagonally) e.g. 5 9 10 1 3 7 4 4 8 2 1 9 So shortest path from (0,0) to (2,2) is

Re: [algogeeks] Re: Unique partition

2011-10-30 Thread SAMM
Ur algo will not work for this case :- 1 1 1 1 1 1 3 5 6 For the array .. And for K=3 Ur algo will give (1 1 1) (1 1 1 ) (3 5 6) On 10/30/11, mohit verma mohit89m...@gmail.com wrote: sort the array : O(nlogn) keep an array/map containing frequency of each element in sorted array :

Re: [algogeeks] choosing numbers

2011-10-30 Thread Prakash D
@Piyush kapoor: i don't get it.. could u plz explain a lil more? On Mon, Oct 24, 2011 at 8:19 PM, praveen raj praveen0...@gmail.com wrote: for 3 set .. set value stored in array a[3] and p is the sum for( i=0;i=a[0];i++) { for(j=0;j=a[1];j++) { for(k=a[2];k=0;k--)

[algogeeks] Re: Dp solution for this problem?

2011-10-30 Thread Gene
You can convert this into a regular SP problem on a graph and use a classical SP algorithm. In this graph, the nodes are labeled with pairs (i,j). If M[A,B] is your matrix, then the graph's adjacency matrix C[A,B] is just C[ (iA, jA), (iB, jB) ] = { M[ iB, jB ] if abs(iA-iB) = 1 abs(jA-jB) =

Re: [algogeeks] Dp solution for this problem?

2011-10-30 Thread shiva@Algo
Min Cost Path: http://www.geeksforgeeks.org/archives/14943 On Mon, Oct 31, 2011 at 12:52 AM, mohit verma mohit89m...@gmail.com wrote: Given a matrix you have to find the shortest path from one point to another within the matrix. The cost of path is all the matrix entries on the way. You can

Re: [algogeeks] Dp solution for this problem?

2011-10-30 Thread SAMM
This can be done using the Dijkstra's algorithm , Start frm the source frm the Destination (In this example from (2 2)) . You need to consider the index of the array as the the vertices and the weigjht as the the value for the movement from the present vertex to it's connecting neighbour .. On

Re: [algogeeks] Dp solution for this problem?

2011-10-30 Thread Anup Ghatage
How about this one... 5 9 10 1 3 7 4 4 8 2 1 9 Check the immediate neighbors / 8 (or less) neighbors of your given cell.. Here for 5 the neighbors are 9,7,3 for 9 they are 5,3,7,4,10 for 7 they are 5,9,10,4,1,2,8,3 etc For every cell calculate the sum of it an its neighbors, find the

Re: [algogeeks] Dp solution for this problem?

2011-10-30 Thread Prakash D
if all possible diagonal movements are allowed i guess we must check all the possibilities On Mon, Oct 31, 2011 at 12:52 AM, mohit verma mohit89m...@gmail.com wrote: Given a matrix you have to find the shortest path from one point to another within the matrix. The cost of path is all the

Re: [algogeeks] Dp solution for this problem?

2011-10-30 Thread Vandana Bachani
Consider each element of the matrix as a node of a graph. Connect the nodes to the adjacent nodes (up, down, left, right or diagonal) using directed edges having weight equal to the weight of the node it is incident on, eg. any edge coming into (0,0) with have weight 5. Given the starting point to

[algogeeks] printK Distance Nodes

2011-10-30 Thread Ankuj Gupta
You are given a function printK Distance Nodes which takes in a root node of a binary tree, a start node and an integer K. Complete the function to print the value of all the nodes (one-per-line) which are a K distance from the given start node in sorted order. Distance can be upwards or