anurag wrote:
> write a function to print all permutations of a string.can anyone
> please help me
hey i please know only c and c++.kindly tell me the code in them.i do
know anything about java.please.try to write in pure c.please
--~--~-~--~~~---~--~~
You recei
Just to reword:
n- handle length
l - loop length
x - total length
p = q = head;
move p by l+1 nodes
then move both p and q 1 node till they meet They will meet at the end
of the handle.
Thanks Vinod.
--~--~-~--~~~---~--~~
You received this message because you ar
This is in Java
==
public class Permute {
public static void main(String[] args) {
permute("", "ABCD");
}
public static void permute(String parent, String s) {
if (s.length() == 2) {
System.out.println(parent + s);
Hi.
goal is to find the length of linked list...
there may be cycle in that
my idea is directly trying to find the length instead of finding cycle and doing processing...to find length
traverse the list and hash the addresses..and increment the count untill either u find a null or same a
The loop is at the end as you have said.
--~--~-~--~~~---~--~~
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 e
I am not sure I got it.
Is the list :
1,2,3,4,5,6,7,8,9,10,11,12,13,8 - i.e the loop is at the end which has
to be the case since node 3 cannot have 2 out links?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Alg
To find the length of the loop:1)You know the node where the two pointers have met.(say NodeX)2)Now make one pointer alone traverse through the loop.(Have a counter which increments for every move)3)It will come back to the same node (NodeX) after making 'length of the loop' jumps
ie the counter g
1. I know there is a cycle
2. Since via the "Hare Tortoise Algo" when the list is detected, the
fast pointer is caught in the loop, we can run it around the loop to
find the length of the cycle.
I don't know the node that has two in-pointers/element that points
backwards
Any ideas now??
I have
How about concentating all your strings into a single long string and
then constructing a suffix tree?
The strings will be seperated using a special character that does not
belong to any of them (let's say that they will be null seperated).
Using this suffix tree to find the longest common sub-wor
or just use lib function next_permutation() in c++ std lib would be
what you need?
2006/7/21, Mukul Gandhi <[EMAIL PROTECTED]>:
>
> anurag wrote:
> > write a function to print all permutations of a string.can anyone
> > please help me
>
> Here is a generic program (written in Java) which does thi
Did you detect the exact element that points backwards, or you just
know that there is a cycle somewhere in the list?
(There is a simple and efficient algorithm to know that there is a
cycle without detecting the exact element that points backwards)
--~--~-~--~~~---~-
anurag wrote:
> write a function to print all permutations of a string.can anyone
> please help me
Here is a generic program (written in Java) which does this for a
collection of objects. You can easily adapt it for a string.
import java.util.List;
import java.util.Iterator;
import java.util.Col
How do I find the length of a linked list that has a cycle, after
having detected the cycle?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@go
13 matches
Mail list logo