CS301 Data Structures GDB Fall 2020 Solution / Discussion
Share the GDB Question & Discuss Here....
Stay touched with this discussion, Solution idea will be uploaded as soon as possible in replies here before the due date.
CS301 GDB 1 Fall 2020 solution idea:
Queue Data Structure (FIFO) First In First Out
In my opinion queue data structure is best because of queue FIFO (first in first out). The queue is a line of items waiting to be served in sequential order. A queue is an ordered list in which insertions are done at one end (rear) and deletions are done at other ends (front). Working principle is First in First out (FIFO).
Stack Data Structure (LIFO) last in First Out
The stack is a linear data structure where the insertion of elements or deletions of elements is done from only one side/end which is called the top of the stack.
Stack allows access to only the last element inserted hence, an item can be inserted or removed from the stack from one end called the top of the stack.
Cs 301 GDB solution fall 2020
I would suggest stack data structure over Queue. This is because in solving a maze problem .we need to explore all expected path Along with that, we ales need to follow the paths visited.
If we were to use Queue only supports deletion form the front, this would not be beneficial for our case. As we need to follow back the unsuccessful path until we find another way. using stack what we do, while moving into the maze we can push the index of the last visited cell and when reached the end of the maze we can push the index of the last visited cell and when reached the end point, just keep popping element from the stack until the cell at stack top has another way to move using the particular stack you can find the correct path in the shortest possible time.