1. Take a string from the user and print it in the reverse order using stack...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Take a string from the user and print it in the reverse order using stack data structure. Also prints the unicode of each character Input: WATERMELON Output: NOLEMRETAW Hint: Use the property of stack to reverse the string 2. Given a string of brackets, determine whether each sequence of brackets is balanced. If a string is balanced, print True on a new line; otherwise, print False on a new line. Input: Output 0 True 8 True [] True {0} True {(D]} False (0 False {[C]} False 3. Suppose, you have a stack class. You have 5 utility functions: isempty(), push(), pop(). peek() and size(). Write a program keepLargestOnTop(stack) in a way that the largest value in that stack would be in the TOP position always. Return the stack. Hints: You should use a helpingStack and its functions helping StackPush(), helping StackPop(), helpingStackisEmpty(), helpingStacksize(). Assume: these are already implemented. You need to use them properly. Current stack 23 53 56 19 44 TOP 22 99 After your 44 Program keepLargestOnTop(stack): Stack looks like below: 23 53 56 19 44 22 TOP 44 99 4. Given two stacks with integer values, balance the sum of integer values present in each of the stack by adding a new element in any of the stack. For example, if stack A contains 1, 5, 11 and 4 and stack B contains 4,32,- 1 and 1 then by adding 15 in stack A will balance the sum of values of both the stacks. Input: 1 4 32 11 1 4 -1 Stack A Stack B Output: 1 4 1. Take a string from the user and print it in the reverse order using stack data structure. Also prints the unicode of each character Input: WATERMELON Output: NOLEMRETAW Hint: Use the property of stack to reverse the string 2. Given a string of brackets, determine whether each sequence of brackets is balanced. If a string is balanced, print True on a new line; otherwise, print False on a new line. Input: Output 0 True 8 True [] True {0} True {(D]} False (0 False {[C]} False 3. Suppose, you have a stack class. You have 5 utility functions: isempty(), push(), pop(). peek() and size(). Write a program keepLargestOnTop(stack) in a way that the largest value in that stack would be in the TOP position always. Return the stack. Hints: You should use a helpingStack and its functions helping StackPush(), helping StackPop(), helpingStackisEmpty(), helpingStacksize(). Assume: these are already implemented. You need to use them properly. Current stack 23 53 56 19 44 TOP 22 99 After your 44 Program keepLargestOnTop(stack): Stack looks like below: 23 53 56 19 44 22 TOP 44 99 4. Given two stacks with integer values, balance the sum of integer values present in each of the stack by adding a new element in any of the stack. For example, if stack A contains 1, 5, 11 and 4 and stack B contains 4,32,- 1 and 1 then by adding 15 in stack A will balance the sum of values of both the stacks. Input: 1 4 32 11 1 4 -1 Stack A Stack B Output: 1 4
Expert Answer:
Answer rating: 100% (QA)
Ans 1 Lets implement the given problem in the Python programming language with comments to understand the code easily Define the function push to stor... View the full answer
Related Book For
Principles Of Information Security
ISBN: 9780357506431
7th Edition
Authors: Michael E. Whitman, Herbert J. Mattord
Posted Date:
Students also viewed these programming questions
-
The topology of the buck-boost circuit is shown in Fig. 4. The converter operates in CCM. The input voltage is Vin and duty ratio is D. (25 points) (a) Using inductor current iz and capacitor voltage...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The income statement for Performance Limited is given below along with some supplementary information. Performance Limited Income Statement for the year ended December 30, 2020 (in $000s) Division A...
-
A hot fluid at 35C is to be transported through a tube horizontally positioned in quiescent air at 25C. Which of the tube shapes, each of equal cross-sectional area, would you use in order to...
-
Winning all three Triple Crown races is considered the greatest feat of a pedigree race horse. After a successful Kentucky Derby, Corn on the Cob is a heavy favorite at 2 to 1 odds to win the...
-
Consider the following cash flow profile and assume MARR is 10 percent/year. a. Determine the IRR(s) for this project. b. Is this project economically attractive? EOY 0 1 2 3 4 5 6 NCF -$101 $411...
-
Knockoffs Unlimited, a nationwide distributor of low-cost imitation designer necklaces, has an exclusive franchise on the distribution of the necklaces, and sales have grown so rapidly over the past...
-
How do i make a ER digram like similar to the following using my relational model My Relational model is the following Has Applications ID Applications Applicant ID Job positions ID Employer ID Apply...
-
It is the end of 2019, and you have been asked to create financial statements for the year. Your manager has given you the trial balance on the left.
-
Presented below are the 2018 income statement and comparative balance sheets for Santana Industries. SANTANA INDUSTRIES Income Statement For the Year Ended December 31, 2018 ($ in thousands) Sales...
-
Consider the following rates of return for the period from 1970 through 1975 (taken from Table 12.1 in your textbook): Year Large-Company Stocks U.S. Treasury Bills 1970 3.94% 6.50% 1971 14.30 4.36...
-
At present the currency with the people and their demand deposits with banks contribute 2 0 0 million to the economy. This value is derived from the people s behavior where they used to deposit 8 0...
-
2. For the system with nonlinear spring described by the equation of motion 3x + 0.2x -x+x = 0 a. Find the equilibrium positions. b. Linearize the equations of motion about each equilibrium, find the...
-
A firm purchases $4,562,500 in goods over a 1-year period from its sole supplier. The supplier offers trade credit under the following terms: 2/15, net 50 days. Davis finally chooses to pay on time...
-
The Australian Blueberry Growers Association recently reported findings that blueberry flowers provide a good source of nectar to the beekeepers to help produce more honey. (a) Using an appropriate...
-
Q6. Market 6-1. How is the financial performance priced in the financial markets? Price-book ratio = [price per share] / [book value per share] Price-earnings ratios = [price per share] / [earnings...
-
As water moves through the hydrologic cycle, water quality changes are common because of natural phenomena or anthropogenic pollution. Using Figure 11.1, describe how water-quality changes occur...
-
I. Explain that a signature-based IDPS (also known as a knowledge-based IDPS or misuse detection) examines data traffic in search of patterns that match known signatures: preconfigured, predetermined...
-
Which of the following is NOT a stage as described in NISTs SP 800-34, Rev. 1? a. Determine mission/business process and recovery critically. b. Identify resource requirements. c. Identify recovery...
-
Examine the overview of different types of security architectures that can help with blueprint construction, implementation, and maintenance. These include spheres of security, levels of controls,...
-
Based on the photographs in Figure 26.13, in which segment(s) is the Antp gene normally expressed? Figure 26.13: (a) Normal fly (b) Antennapedia mutant
-
The bush baby, a small African mammal, is a remarkable jumper. Although only about 8 inches long, it can jump, from a standing start, straight up to a height of over 7 feet! Use the particle model to...
-
Hicham El Guerrouj of Morocco holds the world record in the 1500 m running race. He ran the final 400 m in a time of 51.9 s. What was his average speed in mph over the last 400 m? A. 14.2 mph B. 15.5...
Study smarter with the SolutionInn App