Objective: The objective of this lab is to provide basic concept of stack. At the end...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Objective: The objective of this lab is to provide basic concept of stack. At the end of the lab, students are able: > To learn how to create a stack > To learn how to perform push and pop operation in stack > To learn how to use stack for parsing unmatched parenthesis in an algebraic expression > To learn how to use stack for reversing data. Stack: A stack is an Abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a real-world stack, for example - a deck of cards or a pile of plates, etc. A real-world stack allows operations at one end only. This feature makes it LIFO data structure. In stack terminology, insertion operation is called PUSH operation and removal operation is called POP operation. Data pement Last In - First Out Push Pop Data Eement Data Element Data Clement Data Element Data Element Data Elerment Data Dement Data Element Data Element Data Element Stack Stack Now you have to perform the following lab task on stack: Exercise 1: Create a Menu Create a menu that will display all the exercises given below (Exercise 2 to Exercise 5) as a list and prompt user to select any desired option. The menu can be designed in below format. 1. Insert data/ push stack 2. Print stack 3. Pop stack Create a menu that will display all the exercises given below (Exercise 2 to Exercise 5) as a list and prompt user to select any desired option. The menu can be designed in below format. 1. Insert data/ push stack 2. Print stack 3. Pop stack Exercise 2: Push Operation Adding a new data/node in stack is a more than one step activity. First, create a node using structure and find the location where it has to be inserted. Then input the data and store it in the allocated memory space. Insert the node at the beginning of the previously inserted node. Exercise 3: Pop Operation After completing exercise 1 you have a newly created stack. Now perform the pop operation on it. Exercise 4: Parsing Unmatched Parenthesis One of the most important applications of stack is parsing. Parsing is any logic that breaks data into independent piece for further processing. So parsing unmatched parenthesis is a common problem of parsing. When parentheses are unmatched then there will be two types of error: the opening parenthesis is unmatched or the closing parenthesis is missing. Write a program using stack that will make sure that all parentheses are well paried. For example, Input Output ((A+B)/C Opening parentheses not end (A+B)/C) Closing parentheses not matched Exercise 5: Reversing Data Reversing data requires that a given set of data be reordered so that the first and last elements are exchanged. The idea of reversing data can be used in solving classical problem such as converting a decimal number to a binary number. Now write a program using stack that will convert decimal number to binary number. For example: Input Output 45 101101 4. 100 Objective: The objective of this lab is to provide basic concept of stack. At the end of the lab, students are able: > To learn how to create a stack > To learn how to perform push and pop operation in stack > To learn how to use stack for parsing unmatched parenthesis in an algebraic expression > To learn how to use stack for reversing data. Stack: A stack is an Abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a real-world stack, for example - a deck of cards or a pile of plates, etc. A real-world stack allows operations at one end only. This feature makes it LIFO data structure. In stack terminology, insertion operation is called PUSH operation and removal operation is called POP operation. Data pement Last In - First Out Push Pop Data Eement Data Element Data Clement Data Element Data Element Data Elerment Data Dement Data Element Data Element Data Element Stack Stack Now you have to perform the following lab task on stack: Exercise 1: Create a Menu Create a menu that will display all the exercises given below (Exercise 2 to Exercise 5) as a list and prompt user to select any desired option. The menu can be designed in below format. 1. Insert data/ push stack 2. Print stack 3. Pop stack Create a menu that will display all the exercises given below (Exercise 2 to Exercise 5) as a list and prompt user to select any desired option. The menu can be designed in below format. 1. Insert data/ push stack 2. Print stack 3. Pop stack Exercise 2: Push Operation Adding a new data/node in stack is a more than one step activity. First, create a node using structure and find the location where it has to be inserted. Then input the data and store it in the allocated memory space. Insert the node at the beginning of the previously inserted node. Exercise 3: Pop Operation After completing exercise 1 you have a newly created stack. Now perform the pop operation on it. Exercise 4: Parsing Unmatched Parenthesis One of the most important applications of stack is parsing. Parsing is any logic that breaks data into independent piece for further processing. So parsing unmatched parenthesis is a common problem of parsing. When parentheses are unmatched then there will be two types of error: the opening parenthesis is unmatched or the closing parenthesis is missing. Write a program using stack that will make sure that all parentheses are well paried. For example, Input Output ((A+B)/C Opening parentheses not end (A+B)/C) Closing parentheses not matched Exercise 5: Reversing Data Reversing data requires that a given set of data be reordered so that the first and last elements are exchanged. The idea of reversing data can be used in solving classical problem such as converting a decimal number to a binary number. Now write a program using stack that will convert decimal number to binary number. For example: Input Output 45 101101 4. 100
Expert Answer:
Answer rating: 100% (QA)
C code for Stack include include using namespace std cla... View the full answer
Posted Date:
Students also viewed these programming questions
-
P Co acquired a 90% ownership interest in Y Co on 1 January 20x3. At the date of acquisition, the share capital of Y Co was $1,000,000, and the retained earnings balance was $500,000. The book values...
-
1. Show how the function f(w, W, W) = m(1,2,3,5,6) can be implemented using3-to-8 2> binary decoder and an OR gate.(5 point) W W W EN 3-To-8 Decoder Yo Y Y Y Y Y
-
The purpose of this lab is to experimentally determine the equilibrium constant, Kc. for the following chemical reaction: Fe+ (aq) + SCN- (aq) FeSCN (aq) iron(III) thiocyanate thiocyanoiron(III)...
-
You have extracted a trial balance and drawn up accounts for the year ended 31 December 20X7. There was a shortage of 78 on the credit side of the trial balance, a suspense account being opened for...
-
Ledfords is a chain of home improvement stores. Suppose Ledfords is trying to de-cide whether to produce its own line of Formica countertops, cabinets, and picnic tables. Assume Ledford would incur...
-
Your boss has discussed implementing a level controller on a troublesome process tank that contains a boiling liquid. Someone told him that a level transmitter used with such a system has a very...
-
How a user conceptually organizes and understands data is referred to as the a. physical view c. data model view b. logical view d. data organization view
-
Nadia Khalif is the office manager for the Conyers Law Offices in Dallas, Texas. The firm is planning to move its computer network into the cloud so that everyone working on a case can access...
-
In this unit we investigated whether officials might give favorable treatment to home teams in stressful situations. Do baseball teams strike out less in home games than in road games? Here are the...
-
Sarah Smith is the marketing manager for Activa. She decides to run a sales promotion to boost the brand's business and is interested in evaluating the success of the promotion. The following is key...
-
The reason for the importance of evaluating government performance can vary across stakeholders; however, having open and transparent financial information that allows for evaluation is critical...
-
At May 3 1 , 2 0 2 2 , the accounts of Blossom Manufacturing Company show the following. May 1 inventories - finished go ds $ 1 5 , 6 2 4 , work in process $ 1 8 , 2 2 8 , and raw materials $ 1 0 , 1...
-
The sales of a company grow from $450 to $730 over 8 years. What is the percentage growth per annum, r?
-
John Reardon purchased 100 shares of Tomco Corporation in December 2019, at a total cost of $1,782. He held the shares for 15 months and then sold them, netting $2,535. During the period he held the...
-
Consider Sam and Jo, two pet owners. Every week, both Sam and Jo spend $24 on cat food. Cat food comes in two types, dry food and wet food. Dry food costs $1 per lb. while wet food costs $2 per lb....
-
Zoom Tech Ltd investigates all variances above 10 percent of the flexible budget. The flexible budget for direct labour is $50,000. The direct labour rate variance is $4 000 unfavourable, and the...
-
lim x 2 ( 3 x + x 2 - 4 x - 2 )
-
Determine the optimal use of Applichem's plant capacity using the Solver in Excel.
-
Like any retail company, Costco knows that some customers will return merchandise after the sale. When a June sale is returned in July, both the sale and the sales return are recorded in the same...
-
John and Candy Moody operate Western Ski Centers, a small retail ski store in southwest Colorado. The couple is concerned that, despite increasing sales, they appear to be making less money each...
-
The McGee Company purchased a specialized machine five years ago for \($250,000\) and has taken & \($175,000\) of depreciation to date. Suppose the company sells the machine for \($50,000\)....
Study smarter with the SolutionInn App