Note that there are some explanatory texts on larger screens.

plurals
  1. POrecursion using a hashmap
    primarykey
    data
    text
    <p>I have an array that has the following numbers</p> <pre><code>int[] arr = {2,4,3,1,5,6,0,7,8,9,10,11,12,13,14,15}; </code></pre> <p>Or any other order for that matter. I need to make all the possible combinations for the numbers using a recursion but satisfying a condition that the next number clubbed with the present one can only be from specific numbers given by a hashmap: ex <strong>When the recursion takes 1 the next number can be from {0,4,5,2,6} (from the HaspMap),and then if i make 10,the next number can be from {1,4,5}</strong> and so on</p> <pre><code>static HashMap&lt;Integer,Integer[]&gt; possibleSeq = new HashMap&lt;Integer,Integer[] &gt;(); private static void initialize(HashMap&lt;Integer,Integer[]&gt; possibleSeq) { possibleSeq.put(0,new Integer[]{1,4,5}); possibleSeq.put(1,new Integer[]{0,4,5,2,6}); possibleSeq.put(2,new Integer[]{1,3,5,6,7}); possibleSeq.put(3,new Integer[]{2,6,7}); possibleSeq.put(4,new Integer[]{0,1,5,8,9}); possibleSeq.put(5,new Integer[]{0,1,2,4,6,8,9,10}); possibleSeq.put(6,new Integer[]{1,2,3,5,7,9,10,11}); possibleSeq.put(7,new Integer[]{2,3,6,10,11}); possibleSeq.put(8,new Integer[]{9,4,5,12,13}); possibleSeq.put(9,new Integer[]{10,4,5,8,6,12,13,14}); possibleSeq.put(10,new Integer[]{7,6,5,9,11,15,13,14}); possibleSeq.put(11,new Integer[]{6,7,10,14,15}); possibleSeq.put(12,new Integer[]{8,9,13}); possibleSeq.put(13,new Integer[]{8,9,10,12,14}); possibleSeq.put(14,new Integer[]{9,10,11,13,15}); possibleSeq.put(15,new Integer[]{10,11,14}); } </code></pre> <p>Note: I am required to make all the possible numbers beginning from digit length 1 to 10. Help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload