Question

Give a real world CS problem that can be solved using stacks or queues faster or easier. Please explain how the problem can b
0 0
Add a comment Improve this question Transcribed image text
Answer #1

One of the real world problem that can solved using Stack is Checking whether the paranthesis is balanced or not in a Code editor.

For example "{}" this is an example of a balanced paranthesis.Since the stack is last in First out Data structure.This property is used to solve the above problem as in the case of balanced parantheses opening parantheses is followed by its closing counterpart.If that is not the case then the Parantheses is not balanced.

To solve this problem using stack we will insert the opening parantheses into the stack and when the closing parantheses is encountered we will check the top of the stack if that corresponds to the same opening parantheses then we will pop the stack.

else we will return false.

At the end of parsing the document we will see if the stack is empty or not,If it is not empty then that means parantheses is not balanced.

If stack is not used for this problem then this would become tedious as we have to keep track of individual opening parantheses and when ever closing parantheses is encountered then we have to check the previous parantheses.This can be done using arrays also.But the computation would become bit complicated.

Add a comment
Know the answer?
Add Answer to:
Give a real world CS problem that can be solved using stacks or queues faster or...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 5. (34 pts) Stacks and Queues a. Stacks and queues are similar and different. For each of stack a...

    5. (34 pts) Stacks and Queues a. Stacks and queues are similar and different. For each of stack and queue, give a drawing showing how each would be stored in an array and a linked list. Use your first name (or usual nickname) as the data put into the container as an example for your pictures. Label the accessible element. (4 pictures; 16 pts) the text and lecture. (10 pts) You will not receive full credit without appropriate stack pictures....

  • Overview For this assignment, we will practice using stacks and queues. In this exercise, you will...

    Overview For this assignment, we will practice using stacks and queues. In this exercise, you will create two stacks and a queue to keep track of cars using a parking lot. We will use the nature of the stacks and queues to solve the problem. Specifications Rules FIU has opened a new valet parking lot next to the PC building that requires a special decal to park. If the car does not have the correct parking decal, the driver should...

  • Overview For this assignment, we will practice using stacks and queues. In this exercise, you will...

    Overview For this assignment, we will practice using stacks and queues. In this exercise, you will create two stacks and a queue to keep track of cars using a parking lot. We will use the nature of the stacks and queues to solve the problem. Specifications Rules FIU has opened a new valet parking lot next to the PC building that requires a special decal to park. If the car does not have the correct parking decal, the driver should...

  • 3) Stacks vs Queues: a) A Circular Array is a common data structure for a buffer...

    3) Stacks vs Queues: a) A Circular Array is a common data structure for a buffer (a type of queue). Why is this advantageous over a regular array? (Hint: think about common queue operations and what they do to an array). b) Show a traversal of the following tree using a stack: 26 1 25 2 17 3 2. (19 7 1 (The numbers under the bubbles are a node number, not the data. ) c) Why would using a...

  • Create a real world scenario that would involve a vector field and create a problem to...

    Create a real world scenario that would involve a vector field and create a problem to be solved involving the vector field and the real world scenario. You must give a formula for the vector field, describe the various variables involved, and explain what the solution to your problem would be finding. Do NOT actually solve the problem you create.

  • Explain the topological ordering problem and show how it can be solved for directed acyclic graphs....

    Explain the topological ordering problem and show how it can be solved for directed acyclic graphs. Give an example to illustrate it. ~Can you explain clearly and with A LOT of information. Thanks. Hi, cs summer students

  • HI USING C++ CAN YOU PLEASE PROGRAM THIS ASSIGNMENT AND ADD COMMENTS: stackARRAY: #include<iostream> #define SIZE...

    HI USING C++ CAN YOU PLEASE PROGRAM THIS ASSIGNMENT AND ADD COMMENTS: stackARRAY: #include<iostream> #define SIZE 100 #define NO_ELEMENT -999999 using namespace std; class Stack { int arr[SIZE]; // array to store Stack elements int top; public: Stack() { top = -1; } void push(int); // push an element into Stack int pop(); // pop the top element from Stack int topElement(); // get the top element void display(); // display Stack elements from top to bottom }; void Stack...

  • Describe two approaches to implementing stacks or queues. Some advantages and disadvantages of one over the...

    Describe two approaches to implementing stacks or queues. Some advantages and disadvantages of one over the other? What it the array position of the root of a binary tree? If m is the position of the parent of a complete binary tree what is the position of the left son? State the binary search tree condition. Show how the nodes of a binary search tree Implemented by a linked list look if the following nodes are inserted sequentially: 43, 17,...

  • This a lab for C++ using visual studio 2017 Lab 10 Total 50 points Stacks and...

    This a lab for C++ using visual studio 2017 Lab 10 Total 50 points Stacks and Queues - Part A (40 points) Finish the code for Lab10aStacksAndQueues.cpp . You will write code for the same function which will return true if the values of the elements of the vector that is passed to it are the same read both forwards and backwards. If they are not the same in both directions, it will return false. Don’t change anything in the...

  • Unrolling Recursion The objective of this problem is to simulate recursion using stacks and loops...

    Unrolling Recursion The objective of this problem is to simulate recursion using stacks and loops. A synthetic linear recursive procedure for this problem is provided in Code Fragment 1. A recursive function such as the one described is intuitive and easily understandable. On calling myRecursion(input), the execution first checks for the stopping condition. If the stopping condition is not met, then operations inside the recursive call are performed. This can include operations on local variables. The operations inside the function...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT