recursive function
Hi
iam new to java .i need help on the recursive algorithm ..I have a hashmap where value is a array list for eg:
key value
a->b ,c,d,e,f
b->i,j,k,l,m
d->f,p,q
i->u,w,x
v-> z,l
r-> 1,2,3,4
t -> ma,ku,sa
input to the program is "a" i need to look whether "a" has any value if it does for each value i need to look in the hashmap and find whether is has any value ,i need to go recursively to get all the elements .
output when string "a" is
a =b,c,d,e,f
b= i,j,k,l,m
i=u,w,x
d= f,p,q
I don't need any code but any help with recursive algorithm would really help
thanks for the help
[716 byte] By [
kumsaaa] at [2007-11-26 16:00:27]

Let me make sure I get this, you look up a and get b,c,d,e,f. Then you want to look up the value list for each of those values b,c,d,e,f? Then repeat for each element in each result?
You've basically already described your recursive algorithm. Try coding it out now.
Note: you'll probably want to keep a set of "seen" keys, in case there are any loops from keys to values to keys, etc. (For example, if the key i had an a as one of its values.) There doesn't seem to be any loops now but I can imagine that it might in the future.
here's some pseudo code:void printValues(key, map)
'value' = map.get(key)
for(every element in 'value')
display "'key' has 'value[i]'"
end for
for(every element in 'value')
printValues(value[i], map)
end for
end
pls correct me if iam wrong this pseudo code will print only the values for bcdef but i need to get b's value which is ijklm now since i is a key i need to get i's valueswhich is uwx and u,w,x does not have any key so i need to stop here.thanks for the help