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,
@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
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
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 :-
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
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
*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
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
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
+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
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
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
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
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
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
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
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 :
@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--)
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) =
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
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
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
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
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
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
25 matches
Mail list logo