@ akash
solution is complete. :P
first try to understand the solution.
--
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
Bipartite Graph..
On Sun, May 29, 2011 at 9:42 PM, ross jagadish1...@gmail.com wrote:
@anshu mishra:
Yeah. Thanks! :)
On May 30, 8:26 am, anshu mishra anshumishra6...@gmail.com wrote:
it is exactly a graph coloring problem. so it has no polynomial order
solution.
--
You received this
@anshuman sir: yes, I know you have completed the solution. I have just
added :)
On Sun, May 29, 2011 at 11:02 PM, anshu mishra anshumishra6...@gmail.comwrote:
@ akash
solution is complete. :P
first try to understand the solution.
--
You received this message because you are subscribed
@Anshu
If you do
add top bottom, left right element to the popped element in qeuue
should you need to do it for each element in the matrix.
So, will that not be O(n3)??
Clarify if i am wrong.
On May 30, 9:52 am, Aakash Johari aakashj@gmail.com wrote:
At the each level, traversed by BFS,
@ross : * if their flag is true and their value is equal to x*
On Sun, May 29, 2011 at 11:07 PM, ross jagadish1...@gmail.com wrote:
@Anshu
If you do
add top bottom, left right element to the popped element in qeuue
should you need to do it for each element in the matrix.
So, will that not
but ,when the arr is 78 3
to add 0
78 30
sort: 30 78
ans:378?
2011/5/27 Logic King crazy.logic.k...@gmail.com
i agree with piyush...can't find the countercase...satisfied with the algo.
On Fri, May 27, 2011 at 6:58 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
how about adding zeroes at
@ross no, a particular element has to read only 5 times maximum.
1 reading (i,j) (if its flag is already false skip)
2 read by top element
3. read by bottom element
4 read by left element
5 read by right element
coz atleast one of the this operation its flag will be unset(false), then we
have to
biaprtie graph is special case when we can color the whole graph just by
two colors.
--
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
yes, sorry.. i misunderstood the problem.
On Sun, May 29, 2011 at 11:24 PM, anshu mishra anshumishra6...@gmail.comwrote:
biaprtie graph is special case when we can color the whole graph just by
two colors.
--
You received this message because you are subscribed to the Google Groups
Can this solution work?
Create adjacency matrix where adj[i][j] representing person i doesnt like
person j. Now toggle the relations (means now the adj[i][j] will represent
person i and person j can live with each other) and find the no. of
connected components. No. of connected components
No, won't work. :(
On Sun, May 29, 2011 at 11:39 PM, Aakash Johari aakashj@gmail.comwrote:
Can this solution work?
Create adjacency matrix where adj[i][j] representing person i doesnt like
person j. Now toggle the relations (means now the adj[i][j] will represent
person i and person j
@anshu mishra:
Hi, kindly clarify on this small doubt of mine.
Your algo is
while (!q.empty())
{
x = q.top();
q.pop();
if(node notvisited already adjacent to x value = x)
add to queue
}
For the graph,
1 1 2
1 3 1
2 3 4
first,
queue = 1 (at 0,0)
then you would add the 2 1s at (0,1) and (1,0)
main()
{
for (i = 0; i n; i++)
{
for (j = 0; j n; j++)
{
if (flag[i][[j])
{
bfs(mat, flag, i, j);
count++;
}
}
}
}
bfs(mat[][], flag[][], i, j)
while (!q.empty())
{
x = q.top();
q.pop();
if(node notvisited already
@ shubham
Your solution need some changes at step 2
step 1:
sort the given numbers in the decreasing order based on their first
digit(left most).
step 2:
if two numbers come out to be equal in the above case both of their
next digit exist then sort on the basis of their next
@anshu mithra:
Hi,
Thanks for clarifying! :)
On May 30, 11:06 am, anshu mishra anshumishra6...@gmail.com wrote:
main()
{
for (i = 0; i n; i++)
{
for (j = 0; j n; j++)
{
if (flag[i][[j])
{
bfs(mat, flag, i, j);
count++;
here's efficient oneliner without any string manipulation
divide every number by 10^(log10(x).ceil)
sort
convert back to original numbers
join array into string
there are edge-cases where this doesn't work but they can be dealt with
easily - have to go back to work :)
--
You received this
@Nave :: nice solution :) Phoda
Sambyal
On Mon, May 30, 2011 at 12:13 AM, Naveen Agrawal nav.coo...@gmail.comwrote:
@ shubham
Your solution need some changes at step 2
step 1:
sort the given numbers in the decreasing order based on their first
digit(left most).
step
Given a binary tree(not a BST) find the 2 nodes of the binary tree
which are separated by maximum distance.
By distance, we mean no. of edges in the path from node1 to node2.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
give some explanation
--
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,
There can be two cases to it
Case 1 - The maximum distance passes through the root node.
1
/ \
2 3
/ \
45
Maximum distance is between 4 and 5 i.e. 4
Case 2 - The maximum distance lies
That is same as finding the diameter of the tree.
On Mon, May 30, 2011 at 1:44 PM, Piyush Sinha ecstasy.piy...@gmail.com wrote:
There can be two cases to it
Case 1 - The maximum distance passes through the root node.
1
/ \
2 3
yes, it is the diameter of the tree.
On Mon, May 30, 2011 at 1:17 AM, Vipul Kumar vipul.k.r...@gmail.com wrote:
That is same as finding the diameter of the tree.
On Mon, May 30, 2011 at 1:44 PM, Piyush Sinha ecstasy.piy...@gmail.com
wrote:
There can be two cases to it
Case 1 - The
Here's the crude algo :
First find the node having the max depth in the left sub tree and then find
the node having the max depth in the right sub tree. Ties are broken
arbitrarily.
These will be the 2 nodes separated by the maximum distance. The sum of
their depths will give us the distance
@piyush,
Hi, thanks alot for the solution,
Thats to find the diameter of a tree. :)
But, how would you obtain the 2 nodes which have the max. distance
betwn them?
On May 30, 1:17 pm, Vipul Kumar vipul.k.r...@gmail.com wrote:
That is same as finding the diameter of the tree.
On Mon, May
wont work for this tree:
x
/\
x x
/\
x x
/ \
xy
/ \
xx
/
simplest algo: find a node with max depth M and go up tree calculating max
depth of all upper branches that do not contain M until reaching root node
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@ross...I think it can be done by taking a queue/stack...I am working on the
code...Please comment if there is any error in my approach..
On Mon, May 30, 2011 at 2:19 PM, Maksym Melnychok keym...@gmail.com wrote:
simplest algo: find a node with max depth M and go up tree calculating max
depth
this is a very standard problem :D
start with any node(x) find the node which is at maximum distance.
now start with x travese the tree and find the node(y) which is at maximum
distance.
so finally answer wil be (x, y)
traversing the tree two times. so the order for finiding the such nodes
little modification
start with any node(r) find the node(x) which is at maximum distance.
--
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
i guess Sunny has already mentioned (concatenating the two numbers and
comparing) this technique before, i liked and tried coding it ... it works
perfectly without comparing the second digit incase the first is same. the
algorithm can run in O(nlogn) taking the best sorting technique , though i
some explanation
say we have numbers 2 3 5 78
divide all by something to get 0.2, 0.3, 0.5, 0.78
simple sort will give you 0.78, 0.5, 0.3, 0.2
multiply all numbers to get original ones 78 5 3 2
join 78532
--
You received this message because you are subscribed to the Google Groups
Algorithm
@anshu:thats means you say that pthreads are either kernel -level or
hybrid in nature
@lalit:mapping dependsfor user-level kernel isn't aware of
threads,m-m is for kernel-level ,m-n for hybrid
kinda
does anbody knows whether pthreads are user-level or
@ Maksym Melnychok
Fails i think
some explanation
say we have numbers 1 , 101
divide all by something to get 0.1, 0.101
simple sort will give you 0.101, 0.1
multiply all numbers to get original ones 101,1
join 1011
but correct answer should be 1101, isn't it ??
correct me if i m wrong ??
--
possible fix for 100 10 edgecases would be to simply array.map{|x| x*10+1}
and then get rid of that after sorting
--
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
I think following algo will work..I haven't tested it plus its in its crude
form...Kindly correct me if i am wrong..
*typedef struct queue
{
struct node *q[2];
int h1,h2;
}queue;*
**
*queue max_dist(struct node * tree)
{
if (tree == NULL)
return;
queue q1,q2,q3;
q1.h1 =
The hijacker was the pilot.
On Mon, May 30, 2011 at 12:34 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote:
*Aeroplane Hijack puzzle SOLUTION
*
*
*
**
*A man hijacks an aeroplane transporting both passengers(8 of them) and
valuable cargo. After taking the cargo, the man demands nine
solution may be
array ={ 3 ,21 ,9 ,93,17 ,178 ,1,101} (i think i have covered all exceptions
)
then ,change this array like 3 , 21222, 9, 93999, 17111, 17811,
1 , 10111 ( make each number of 5 digit with rest digits same as Ist
digit )
then sort this array
9, 93999,3
@Bhavesh...
for the inputs 18,187.. apply your method..
18 -- 188
187-- 187
18187 - ur method
18718 - actual
On Mon, May 30, 2011 at 3:28 PM, Bhavesh agrawal agr.bhav...@gmail.comwrote:
solution may be
array ={ 3 ,21 ,9 ,93,17 ,178 ,1,101} (i think i have covered all
exceptions )
then
@Sunny i explained how to deal with edgecases right after my post
1, 101 - 11, 1011
11, 1011 - 0.11, 0.1011
sort - 0.11, 0.1011
restore - 1, 101
join - 1101
i can't think of any fail examples anymore
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
@Maksym
what if we have 90 and 9
they become .9 and .9
now what to do to get result as 990 and not 909.
correct me if i am going somewhere wrong?
On Mon, May 30, 2011 at 3:55 PM, Maksym Melnychok keym...@gmail.com wrote:
@Sunny i explained how to deal with edgecases right after my post
1,
@halo check my previous messages
we multiply every element by 10 and add 1
90, 9 - 901, 91
901, 91 - 0.901, 0.91
sort - 0.91, 0.901
revert - 9, 90
join - 990
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
ok ... got it thanks ... :)
On Mon, May 30, 2011 at 5:25 PM, Maksym Melnychok keym...@gmail.com wrote:
@halo check my previous messages
we multiply every element by 10 and add 1
90, 9 - 901, 91
901, 91 - 0.901, 0.91
sort - 0.91, 0.901
revert - 9, 90
join - 990
--
You received this
so here's oneliner code in ruby:
a.map{|x| x=x*10+1; -x/10.0**Math.log10(x).ceil}.sort.map{|x|
(-x).to_s[2..-2]}.join
--
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
http://www.tavistockwood.com/find11.html
--
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.
@piyush :
hey buddy, check out carefully i think you missed something.
my solution says it's 18 -18111
187-18711
and i think you will count it carefully...
plz let me know in any case if my solution goes wrong anywhere .
--
You received this message because
+1
On Thu, May 26, 2011 at 9:31 PM, Ashish Patel ashishpatel1...@gmail.comwrote:
+1000 ..dont count this as SPAM! :D
On Thu, May 26, 2011 at 9:29 PM, radha krishnan
radhakrishnance...@gmail.com wrote:
+100
On Thu, May 26, 2011 at 9:26 PM, pacific :-) pacific4...@gmail.comwrote:
+1
i had this qn in a previous qpaper for my semeter exams in design and
anlysis of algorithems
draw an optimal merge pattern tree for the srting abracadabra
thnks in advance
pls solve this asap i have the xam tomorow
--
Ehab Abdul Rahman Shariff
--
You received this message because you are
@vishal: Floats and doubles are stored in different formats, so
looking at the first 8 hex digits of the two numbers isn't really
helpful.
The expression f 0.8 is evaluated as (double)f 0.8, so it would be
more useful to print all 16 hex digits of (double)0.8f and 0.8. Then
it would be easy to
thnaq
On Mon, May 30, 2011 at 8:00 PM, nagajyothi gunti
nagajyothi.gu...@gmail.com wrote:
Hi Shariff
I thought this document would be a help to you. There is an example with
this string.
On Mon, May 30, 2011 at 10:16 AM, Abdul Rahman Shariff ears7...@gmail.com
wrote:
i had this qn in
Code::Blocks
On Sun, May 29, 2011 at 1:59 AM, Akash Mukherjee akash...@gmail.com wrote:
devcpp
On Sat, May 28, 2011 at 11:17 PM, sravanreddy001 sravanreddy...@gmail.com
wrote:
Hi all. Can some one provide a good C editor.. preferable GUI one, that
works on windows 7.
I'm good with
You are given a sequence of jobs. The no. of days which each job takes
to complete is also provided.
You are also given the penalty amount to be paid per day each day a
job left done. Give an optimal ordering
among jobs to minimize penalty. There are no concurrent jobs.
eg:
Jobs:
guys wake up
On Fri, May 27, 2011 at 9:24 PM, himanshu kansal
himanshukansal...@gmail.com wrote:
a king has two sons eric and bob.he wants to divide his
islands
the islands are in a queue.eric being elder gets the first
chancethey both can pick d island alternatively
won't this simple algo work ??
start from root node, say it has value 0
at any time if a node has a value v
pass v-1 to left subtree and v+1 to right subtree
keep track of max and min
final answer will be max -min = Diameter of tree.
correct me if i m wrong.
--
You received this message
nope, it will not work :(
got a case
On Mon, May 30, 2011 at 11:57 PM, sunny agrawal sunny816.i...@gmail.comwrote:
won't this simple algo work ??
start from root node, say it has value 0
at any time if a node has a value v
pass v-1 to left subtree and v+1 to right subtree
keep track of max
Right!! that is pretty standard problem but the solution u have given
is for undirected graphs and intuitively binary trees are directed.
Piyush solution will work for binary tree.
On May 30, 2:04 am, anshu mishra anshumishra6...@gmail.com wrote:
this is a very standard problem :D
start with
It's been posted quite a few times recently. Just check the mailing list.
On 30 May 2011 18:46, himanshu kansal himanshukansal...@gmail.com wrote:
guys wake up
On Fri, May 27, 2011 at 9:24 PM, himanshu kansal
himanshukansal...@gmail.com wrote:
a king has two sons eric and bob.he
http://anandtechblog.blogspot.com/2010/10/directi-interview-question_3183.html
On Mon, May 30, 2011 at 3:54 PM, Carl Barton odysseus.ulys...@gmail.comwrote:
It's been posted quite a few times recently. Just check the mailing list.
On 30 May 2011 18:46, himanshu kansal
57 matches
Mail list logo