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...
-
Early results on the Lexus, Toyota's upscale car, showed it was taking the most business from customers changing from BMW (15%), Mercedes (14%), Toyota (14%), General Motors' Cadillac (12%), and...
-
Wesley Roberts, the Human Resources director at Elwes Limited, was concerned about the lack of commitment he perceived in many of the company employees. Employee turnover was high, as were...
-
Can a company have more than one type of first-level statement in segment reporting?
-
1. Income and Substitution Effects. Sabrina works for a workers cooperative that initially pays her a lump sum of $200 per week (as long as she works at least 15 hours per week) and a wage of $20 per...
-
2. Determine the parametric equations of a line passing through the point P(3,2,-1) and with a direction vector perpendicular to the line - (2.-3.4)+s(1.1.-2). s SER. [3 marks]
-
Holmes Corporation is a leading designer and manufacturer of material handling and processing equipment for heavy industry in the United States and abroad. Its sales have more than doubled, and its...
-
Determine the margin of error, , for a 99% confidence interval when the sample size is and the sample standard deviation is Give your answer precise to three decimal places. = 19 = 10. =
-
On January 1, 2022, Hum Company purchased 10,000 ordinary shares of Yippy Company, P100 par for P750,000. On March 10, it received 20% stock dividend. The company exchanged 4,000 ordinary shares of...
-
Cool Sips Company traded in a manual ideal machine for an automated ideal machine an gave $4,000 cash. The old machine.cost $46,500 and had a net book value of $35,500. Th old machine had a fair...
-
Complete the table given below 14.24 Complete the available-to-promise table below Period 1 Forecast 50 CO 56 257 3 4 5 6 50 50 50 50 50 17 75 50 16 14 MPS 100 100 100 ATP ? ? ?
-
The following data pertain to XYZ Company. Net income is assumed to be 8% of sales and the dividend payout ratio is 40%. The company expects its sales to increase its sales from 400,000 in 20X1 to...
-
1.3 Write a matlab program When a resistor (R), capacitor (C) and battery (V) are connected in series, a charge Q builds up on the capacitor according to the formula Q(t) = CV (1-e-t/RC) if there is...
-
Singing Fish Fine Foods has a current annual cash dividend policy of $3.25. The price of the stock is set to yield a return of 14%. What is the price of this stock if the dividend will be paid for 12...
-
Determine the optimal use of Applichem's plant capacity using the Solver in Excel.
-
Identify possible causes for (1) a favorable materials price variance; (2) an unfavorable materials price variance; (3) a favorable materials quantity variance; and (4) an unfavorable materials...
-
Standard cost variances can usually be broken down into two basic types of variances. Identify and describe these two types of variances.
-
Explain the net sales volume variance and list its components.
Study smarter with the SolutionInn App