Computer Science, asked by sahiba7987, 9 months ago

Rile of stacks and queues in computer programming equation

Answers

Answered by rajwantkaur123
0

Explanation:

An array is a random access data structure, where each element can be accessed directly and in constant time. A typical illustration of random access is a book - each page of the book can be open independently of others. Random access is critical to many algorithms, for example binary search.

A linked list is a sequential access data structure, where each element can be accesed only in particular order. A typical illustration of sequential access is a roll of paper or tape - all prior material must be unrolled in order to get to data you want.

In this note we consider a subcase of sequential data structures, so-calledlimited access data sturctures.

Stacks

see

picture also

A stack is a container of objects that are inserted and removed according to the last-in first-out (LIFO) principle. In the pushdown stacks only two operations are allowed: push the item into the stack, and pop the item out of the stack.

A stack is a limited access data structure - elements can be added and removed from the stack only at the top. pushadds an item to the top of the stack, pop removes the item from the top. A helpful analogy is to think of a stack of books; you can remove only the top book, also you can add a new book on the top.

A stack is a recursive data structure. Here is a structural definition of a Stack:

a stack is either empty or

it consistes of a top and the rest which is a stack;

Queues

see picture 2 also

A queue is a container of objects (a linear collection) that are inserted and removed according to the first-in first-out (FIFO) principle. An excellent example of a queue is a line of students in the food court of the UC. New additions to a line made to the back of the queue, while removal (or serving) happens in the front. In the queue only two operations are allowed enqueue and dequeue. Enqueue means to insert an item into the back of the queue, dequeue means removing the front item. The picture demonstrates the FIFO access.

The difference between stacks and queues is in removing. In a stack we remove the item the most recently added; in a queue, we remove the item the least recently added.

 

Attachments:
Answered by shilpa85475
0

Stacks and queues are two different containers in a computer system.

Explanation:

  • They process the element based on their input to the system.  Stacks process the files in the order of Last in First out (LIFO) but queues follow the process of First in First out (FIFO).
  • Both the processes are used different scenarios. Stacks process and provide the output of the last entry provided as first input. However, queue process the first input data and provides its output first.
  • Stack and Queue are both used in the appropriate required cases.

To learn more:

1. Speech on ROBOTICS NOW AND IN THE FUTURE- IS IT HELPFUL:

https://brainly.in/question/4580659

2. Prepare a note on artificial intelligence and robotics:

https://brainly.in/question/15901625

Similar questions