The Artima Developer Community
Sponsored Link

Java Answers Forum
Trouble with using recursive function on vector

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jian Chen

Posts: 1
Nickname: jian
Registered: Apr, 2003

Trouble with using recursive function on vector Posted: Apr 4, 2003 5:15 AM
Reply to this message Reply
Advertisement
I try to convert following algorithm to java code, but have trouble with the object reference. Thanks very much if any of you can help me.

proc generate([c], m, k, list)
if (m > M) then
list.insert([c])
else
for i :=1 to min(k+1, K)
generate([c].prepend(i), m+1, max(i, k), list)
endfor
endif
endproc

proc main
list();
generate([1], 1, 1, list)
endproc

where c is a vector.

The output of the programe, for example for K = 2, M=4, will be:
1111 2111 1211 2211 1121 1212 1221 2221

Topic: File Properties Previous Topic   Next Topic Topic: e books on jsp /java/servlets

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use