KnowledgeBoat Logo

Computer Science

What is the working principle of data structures stack and queues ?

Linear Lists

1 Like

Answer

The working principle of a stack follows the Last In First Out (LIFO) technique, where insertions and deletions occur at one end, known as the top. Elements are added to and removed from the top of the stack, allowing the most recently added item to be accessed first.

The working principle of a queue follows the First In First Out (FIFO) technique, where insertions are made at one end, known as the rear, and deletions occur at the other end, known as the front. This ensures that the oldest elements in the queue are processed first, similar to waiting in a line or queue.

Answered By

1 Like


Related Questions