- #1
sukalp
- 53
- 2
is there any tutorial which covers stack and queue in c++.
i am not able to understand it is getting difficult for me .
i am not able to understand it is getting difficult for me .
wel thanks i already searched them but is there any videoNidum said:
thank youNidum said:Just put ' C++ queue video ' and ' C++ stack video ' into Google . My search generated many results .
Personal observation : I have always found learning things from textbooks and textbook style websites far easier and certainly more reliable than trying to learn anything from video tutorials .
thank youjedishrfu said:The problem with video tutorials is seeing the code being executed and then trying to use the code means stopping the video and typing in what you see or jumping to some URL the video might reference to get the code.
sukalp said:is there any tutorial which covers stack and queue in c++.
i am not able to understand it is getting difficult for me .
thanksQuantumQuest said:Definitely agree with Nidum and jedishrfu about video tutorials. I also highly recommend more thorough reading from a textbook. Robert Sedgewick's "Algorithms in C++" https://www.amazon.com/dp/0201350882/?tag=pfamazon01-20, is a great resource.
thankscpscdave said:Not to flog a dead horse here...
But textbooks is the way to go. What worked best for me was to take the examples from the books. Run them as described, see how they run. Then tinker with the code, change things and see the result.
But you'll need to find your own way to learn :)
A stack in C++ is a linear data structure that follows the Last In First Out (LIFO) principle. This means that the last element inserted into the stack is the first one to be removed. It is a collection of elements that are added or removed from only one end, known as the top of the stack.
A queue in C++ is a linear data structure that follows the First In First Out (FIFO) principle. This means that the first element inserted into the queue is the first one to be removed. It is a collection of elements that are added to the back and removed from the front.
A stack in C++ can be implemented using an array or a linked list. In the array implementation, a fixed size array is used to store the elements, and a variable keeps track of the top element. In the linked list implementation, each element is represented as a node and a pointer points to the top node of the stack.
A queue in C++ can be implemented using an array or a linked list. In the array implementation, a fixed size array is used to store the elements, and two variables keep track of the front and rear elements. In the linked list implementation, each element is represented as a node and two pointers point to the front and rear nodes of the queue.
The common operations on a stack include push (add an element to the top of the stack), pop (remove the top element), peek (retrieve the top element without removing it), and isEmpty (check if the stack is empty). For a queue, the common operations include enqueue (add an element to the back of the queue), dequeue (remove the front element), peek (retrieve the front element without removing it), and isEmpty (check if the queue is empty).