Data Structure question, decision tree

rog_rickert

Member
Joined
Dec 17, 2020
Messages
11
Programming Experience
Beginner
Hello,

I need to make a simple app for a decision tree. This is sort of a choose your own adventure thing for kids. The user will start with a question and then depending on their answer it will take them to their next question or to and end point. The tree should be fully traversable also, so if the user wanted to go back from where they are to the previous question and see where the other answer takes them, they could. I've just started to map out the story questions, answers and end points. I was just curious on what type of data structure would be best to implement something like this. I'm not looking for any code, just possible suggestions for what path I should research.

Decision Tree.png
 
Sounds like a tree structure where each node has back pointers to the parent node would be appropriate. As I recall with some of the Choose-Your-Own-Adventure books, there are some places where you have more than just two choices, and there are also some places where there is no going back.
 
Back
Top Bottom