I am making a double link in which a node is first inserted into the list of links, and each node contains three properties, called question_id(int), Skip_logic(Boolean)and nextnode(int). Now, if skip_logictrue, node checks for nextnode Q_id and goes to that node with a specific identifier. Here is an example.
-------- <--- ---------- <---- --------- <----- ---------
| Node1 | ----> | Node 2 | -----> | Node 3 | -----> | Node 4 |
-------- ---------- --------- ---------
Now the stream is the same after insertion. Now, if node 1 contains skip_logic=true. It checks the value of nextnode. Say, for example, it's 4, the stream becomes like that.
-------- ---------- <---- --------- ---------
| Node1 | <---- | Node 2 | -----> | Node 3 | -----> | Node 4 |
-------- ---------- --------- ---------
^ ^
| |
------------------------------------------------------------
Now say, for example, that the user wants to switch from node 1 to node 2. Again, the user must first find the node with this specific question ID from the entire list. Now itβs not so expensive in this scenerio, but if we need to switch from node 1 to node 1000, it will require a lot of search costs, and the link is broken, and you created the link too. another pointer that contains a link to both paths, but the cost of the search still exists. I have implemented this part, but the cost of the search is what I want to avoid. I am going to save the linked list in hashmap, so if the user wants to go to a specific node, he can just enter node and he will go to a specific node. But the problem is that I need to connect the nodes inside the hash map with other nodes, and I think it will take some more memory. So any ideashow should i do this and if this approach is ok and should i go with it? And no, this is not homework.