Creating possible ways for a tree-like structure

Hi guys,
I am challanging with creating all the possible ways for an array which has builded up with numbers. Let me explain in a more detailed way;
I have an array that A = [1 2 3 4 5 6 7 8 9 10]. Between each number there is a transition value which is 1 or 0. For example if transition value 1 is defined for passing from 1 to 2, I will get 1 and 2 both but if it is 0 I will pick 1 and 3 by skipping number 2. I have created all the possibilites by using transition array, for example T = [0 1 1 0 1 0 0 1 1]. I have created a structure which holds the each number from array A and possibilities for each number respectively.
I am completed the code so far but creating all the possible ways starting from number 1 is really challanging for me and could not do that. I just tried some techniques but they did not work at all. I am not software specialist so I hope you can help me.

5 个评论

@Orhan Celikkaya: please show the expected solution for the A and T that you show in your question.
Do you have multiple T arrays with different values? If so, do they all produce the output arrays with the same number of elements?
I have one A and one T array for one solution. Different T array points out another solution for the same A. In addition, length of array A, thereby T, can change.
Output should be a matrice which consist of possible ways. If one of the possibilities have 7 steps and another one has 6, then a 0 should be added at the end of the second one.
@Orhan Celikkaya: please show the expected solution for the A and T that you show in your question.
For instance there is 8 possible solutions and the solution which has maximum steps has 6 steps, output should be 8x6 matrice.
S = [1 3 4 5 7 8; 1 2 4 6 8 0; ....]
You will have to explain better how with:
A = [1 2 3 4 5 6 7 8 9 10]
T = [0 1 1 0 1 0 0 1 1]
you get
S = [1 3 4 5 7 8;
1 2 4 6 8 0;
....]
It's really not clear to me. In fact, I have no idea what the next row of S could be.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by