Hi Guys,
There are some questions asked to me:
1. How do you print the SLL in reverse order. List should not be changed.
2. Two SLLs are merging at one point, how can you find out efficiently.
Thanks
--
Dinesh Bansal
The Law of Win says, Let's not do it your way or my way; let's do it the
best
Hi, I'm new here and looking to learn more on algos and participate in
discussions.
@juver++, Recursion solution to the 1st problem implicitly using
stack. No?
print (list l)
{
if(i-next) print(l-next);
print l;
}
On Jan 6, 4:55 pm, juver++ avpostni...@gmail.com wrote:
1. Recursive
On Thu, Jan 6, 2011 at 5:25 PM, juver++ avpostni...@gmail.com wrote:
1. Recursive function. Print node's element after processing next link of
the current node. Also this can be achieved using stack.
2. Please clarify the question.
--
You received this message because you are subscribed to
Yes, but recursion stack's size is limited instead of iterative version.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
@sourabh,
In addition to your solution, If there is any cycle(loop) exist in the link
list your algo will fail.
To solve this problem first detect this cycle if there is any and count the
element in the cycle, and then you can do the mathematics.
On Thu, Jan 6, 2011 at 6:51 PM, sourabh jakhar
@aditya,
Who said it's a Y shaped structure, It can very well has a cycle.
Assume the case when the last node is not pointing to NULL but to a node in
the list.
On Thu, Jan 6, 2011 at 7:45 PM, ADITYA KUMAR aditya...@gmail.com wrote:
@vishal
saurabh is right
its merging at only one point its
@ Vishal,
I think question says that its merging at a point.
But anyway can you tell me how to detect cycle in this case.
On Thu, Jan 6, 2011 at 7:57 PM, vishal raja vishal.ge...@gmail.com wrote:
@aditya,
Who said it's a Y shaped structure, It can very well has a cycle.
Assume the case when
Maybe the code has lot of dynamic updations..So for each kind of i/
p there can be different places where the updated value is used.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Hii
@ Question 2 -
1. Just count the no of nodes in each link list lets say N1 and N2 are the
number of the nodes in first and second linklist respectively.
2. Now calculate the difference of the Nodes like as
p = {N1~N2)
3. Now take 2 pointers say P1 and P2.
4.
a. If N1 N2 then put
I have written a program to search for a file in C in UNIX.
But it doesn't loop recursively if the starting path is /
Could it be because of permissions? But I am the root while executing the
program and I have also changed the permissions of all the files in the
folder correspondingly.
Please
You can use some techniques to improve quicksort:
- randomized pivot
- use insertion sort for small vector ~10
- use non recursive approach
- median of some element chosed randomized
- when you have many duplicate keys, you can use 3-way
hi,
for 1 question, use stack to display elements in reverse order.
can you elaborate your 2nd question ?
-- Prashant Kulkarni
On Thu, Jan 6, 2011 at 4:56 PM, dinesh bansal bansal...@gmail.com wrote:
Hi Guys,
There are some questions asked to me:
1. How do you print the SLL in reverse
I have written a program to search for a file in C in UNIX.
But it doesn't loop recursively if the starting path is /
Could it be because of permissions? But I am the root while executing the
program and I have also changed the permissions of all the files in the
folder correspondingly.
Please
There are two aspects here for second question.
1. to find if the common node exist (ie the lists are merging) with out
the limitation of length available.
2. To find the merging node.
On 1/6/2011 8:49 PM, Naveen Kumar wrote:
@ Vishal,
I think question says that its merging at a point.
But
Is it necessary that the two lists are merging at their ends??
Do we have to find whether they merge at the end into same lists or wheter
they are just intersecting??
On Thu, Jan 6, 2011 at 10:04 PM, Aditya adit.sh...@gmail.com wrote:
There are two aspects here for second question.
1. to
How can two list just intersect, each node can have one pointer to the next.
So, if they intersect they will definitely be merging.
On Thu, Jan 6, 2011 at 11:01 PM, Tushar Bindal tushicom...@gmail.comwrote:
Is it necessary that the two lists are merging at their ends??
Do we have to find
I agree
But my doubt is that whether we have to find that they just have their last
node as common or they can have many nodes common(which I was calling
intersecting)
On Thu, Jan 6, 2011 at 11:07 PM, Naveen Kumar naveenkumarve...@gmail.comwrote:
How can two list just intersect, each node can
in a C++ program ,
when we have something like this
double p=37.0;
int k;
k=(int)p;
why is k!=p ?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this
for 2nd question.
Let m1,m2 be the length of sll1 and sll2..
now we know that after the merge no of nodes are same in both the slls.
So take the difference , k= m1 - m2
skip k nodes frm the longer lists, then increment both sll1 and sll2 till
you find a match.
The matched node is the
Problem hav been solved u all giving same answers..!
On Thu, Jan 6, 2011 at 11:30 PM, nishaanth nishaant...@gmail.com wrote:
for 2nd question.
Let m1,m2 be the length of sll1 and sll2..
now we know that after the merge no of nodes are same in both the slls.
So take the difference , k=
@Sanchit..sorry i didnt see the replies :P
On Thu, Jan 6, 2011 at 11:32 PM, sanchit mittal sm14it...@gmail.com wrote:
Problem hav been solved u all giving same answers..!
On Thu, Jan 6, 2011 at 11:30 PM, nishaanth nishaant...@gmail.com wrote:
for 2nd question.
Let m1,m2 be the length
On my computer k == p.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options,
About?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group
There is a binary tree(Not a BST) in which you are given three nodes
x,y,z .Write a function which finds whether y lies in the path b/w x
and z.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
I meant any test cases you think I haven't covered in my solution.
Although I have run this solution and checked answer manually .
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
Find node A = LCA(x, z). If y lies on the path x-z (or reverse), then A
should be either on the path A-x, or A-z.
Also this can be find while searching LCA, it depends on the used algorithm
for this.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
You may check the exact solution found here:
http://users.eecs.northwestern.edu/~dda902/336/hw6-sol.pdf
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this
Thanks
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group
not always. well , i got some problem using that approachwhen the output is
coming out of some library function , this doesn't qualify always i wlll
find an example by tomorrow.
On Thu, Jan 6, 2011 at 11:48 PM, juver++ avpostni...@gmail.com wrote:
On my computer k == p.
--
You received this
Good solution but what would be the time complexity ??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
Numbers without fractional parts are represented exactly (in a range
supported by double).
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send
Hey,
Remembered of my OS assignment and wanted to fix it :). Though do not
appreciate the design of the program :D, and not having the enthu to
redesign it, I have fixed the program with minimal possible changes. Please
reply in case of any issues. Thnx for posting :)
#include iostream
#include
Just to mention, floating point numbers r always compared *for equality*
like
double d1 = 90.0;
double d2 = 90.0;
assert(d1 == d2); // might fail, and Wrong way to do !!
assert(d1 - d2 1e-5); // given u assume precision of 1e-5, is the correct
and recommended way.
Programmers should realize
I don't think your example with == would ever fail. According to the
IEEE floating point standard, integers within the dynamic range of the
number type must be represented exactly and must compare as equal.
Furthermore, the four basic operations on integers within the dynamic
range of the
Please write the recursive DP formula for this question .
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
Given an array of integers, each element represents the max number of
jumps can make forward. What is the minimum number of element
selections to reach the end of the array (starting from the first
element).
Example: arr = 1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9
Here the min # of selections is : 3
with
Given an array of integers, each element represents the max number of
jumps can make forward. What is the minimum number of element
selections to reach the end of the array (starting from the first
element).
Example: arr = 1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9
Here the min # of selections is : 3
with
37 matches
Mail list logo