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...
-
What is spurious correlation? Provide a real or hypothetical example where two variables might exhibit such a relationship.
-
On December 31, 2011, Rollo Company held the following short-term investments in its portfolio of available-for-sale securities. Rollo had no short-term investments in its prior accounting periods....
-
After a series of celebrated accounting debacles, Congress enacted the Sarbanes-Oxley Act of 2002, which introduced tighter regulation of the accounting industry under a new Public Company Accounting...
-
Paul Scott has a 2008 Cadillac that he wants to update with a geo-tracker device so he will have access to road maps and directions. After-market equipment can be fitted for a flat fee of $500, and...
-
1. Your program asks the user how many bananas they want to buy, and what the price is. This information is then passed to getTotal to calculate the total cost. System.out.println("How many bananas...
-
Identify by letter the curve you would expect in the titration of a solution containing (a) Disodium maleate, Na 2 M, with standard acid. (b) Pyruvic acid, HP, with standard base. (c) Sodium...
-
On January 1, 2011, Barton Sinks purchased a metal-bending machine for $4,000,000 with an expected useful life of 10 years with no residual value. The machine is depreciated on a straight-line basis....
-
5- Capital Asset Management: A city has recently acquired a new public park. Describe the steps and considerations in accounting for the acquisition, maintenance, and depreciation of this capital...
-
You will examine the use of public/private partnerships (PPPs) in aiding an organization with a problem. Furthermore, you will argue either for or against using a PPP to address the problem.
-
Read one of the selected news articles to be posted, and wr-ite a brief reflection on the topics discussed. This should not merely be a summary. You should summarize briefly and then ask further...
-
USA FDA: Millions Of Pounds Of Rat Meat Sold As BonelessChicken Wings If you enjoy boneless chicken wings you may actually be eatingrat meat. The FDA says that as much as a million pounds of rat...
-
Two signals are spaced at 1,000 ft on an urban arterial. It is desired to establish the offset between these two signals, considering only the primary flow in one direction. The desired progression...
-
Discuss the Importance of the Medical Record and the Implications. Compare and contrast the initial differences you notice between the written Medical records and Electronic Medical records. Describe...
-
On January 1, 2018, Khalid Ltd., which follows IAS 17, entered into an eight-year lease agreement for three dryers. Annual lease payments for the equipment are $28,500 at the beginning of each lease...
-
Please reflect on and explain the role and usefulness of the concept of SD in relation to the protection of the environment.
-
Has the concept of SD achieved the balance between all three pillars: environmental protection; economic development; and social issues?
-
How many dimensions of the PSNR principle can you enumerate? To which one does UN Resolution 1803(1962) refer?
Churchills Adaptive Enterprise Lessons For Business Today 1st Edition - ISBN: 1895186196 - Free Book
Study smarter with the SolutionInn App