• Home
  • University of the People
  • Data Structures (proctored course) CS 3303
  • Data Structures - Stack and Queue

Data Structures - Stack and Queue

In your own words, describe the structure and func on of both the stack and queue data structure and discuss how they are di erent from the perspec ve of how they are used. Just as how in English we talk about stacking plates atop each other, a stack data structure stacks data atop each other. With stacks, data is inserted at the top of whatever data is already available in the stack It is crucial to know that although the data is inserted at the top of the stack, for stacks, this process is known as "pushing" (Sha er, 2011). Dele on also only happens at the top of the stack. The principle in which informa on is handled in a stack is called LIFO (Last In, First Out). Last In, First Out entails that data is removed from the stack at the top of the stack. The last data point to be added to the stack is the rst one to be accessed and popped out. A queue uses the FIFO (First In, First Out) principle. In a queue, data is inserted into the data structure from the rear and popped out from the front of the data structure. This principle follows that of a physical queue in real life situa ons. Therst person to be served by a bank is the one who got in rst. The last person to be served by the bank is the one at the end of the queue. This process is called enqueuing in data structures. New people join the queue at its "rear". When we access data in a queue, we dequeue it, unlike with stacks where we pop out the data. References Sha er, C. (2011). A Prac cal Introduc on to Data Structures and Algorithm Analysis. Blacksburg: Virginia. Tec