Is it possible to create a fifo 'stack' in C without using 2 stacks?
Thank you!
(Sorry for the people who answered the last time. I was thinking Lippo and was saying Fifa.)
It is very easy to implement a double-linked list, holding the index to the last item in the list.
To add to the queue, create a new node in the beginning, before linking at the beginning (insert general list)
To remove from the queue, Remove the pointer to the previous item pointer, and return the last item ... (This is the reason for the double linked list. The second option is a list with a single link and the last list is repeated to get the last two elements to get pointers. Is.)
Comments
Post a Comment