EBK COMPUTER SCIENCE: AN OVERVIEW
12th Edition
ISBN: 8220102744196
Author: BRYLOW
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 8, Problem 18CRP
Explanation of Solution
Function to eliminate bottom entry:
Procedure RemoveBottomElem()
{
if(original stack non empty) then
{
while(original stack non empty) do
{
Pop entry from original stack
Push it to auxiliary stack;
}
}
Pop entry from auxiliary stack;
while(auxiliary stack non empty) do
{
Pop entry from auxiliary stack
Push it to original stack;
}
}
Explanation:
- The code first checks whether original stack is empty or not.
- If stack is non-empty, it enters the loop until it becomes empty.
- An entry is popped from original stack, it is been pushed into auxiliary stack
- The operation is repeated until original stack becomes empty.
- Once original stack becomes empty, auxiliary stack has elements in reverse order of original stack.
- The element at bottom of original stack will be at top of auxiliary and hence required element is at top of auxiliary stack...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A set of instructions may be used to show the return address of a function. Remember that any changes to the stack must not prevent the procedure's return to its caller.
A sequence of instructions may be used to see the function's return address. Any modifications to the stack must be made with the return of the method to its caller in mind.
Complete the following ():a. A stack is used by the system when a function call is madeb. A stack can become full during program execution
Chapter 8 Solutions
EBK COMPUTER SCIENCE: AN OVERVIEW
Ch. 8.1 - Give examples (outside of computer science) of...Ch. 8.1 - Prob. 2QECh. 8.1 - Prob. 3QECh. 8.1 - Prob. 4QECh. 8.1 - Prob. 5QECh. 8.2 - In what sense are data structures such as arrays,...Ch. 8.2 - Prob. 2QECh. 8.2 - Prob. 3QECh. 8.3 - Prob. 1QECh. 8.3 - Prob. 2QE
Ch. 8.3 - Prob. 3QECh. 8.3 - Prob. 4QECh. 8.3 - Modify the function in Figure 8.19 so that it...Ch. 8.3 - Prob. 7QECh. 8.3 - Prob. 8QECh. 8.3 - Draw a diagram representing how the tree below...Ch. 8.4 - Prob. 1QECh. 8.4 - Prob. 2QECh. 8.4 - Prob. 3QECh. 8.4 - Prob. 4QECh. 8.5 - Prob. 1QECh. 8.5 - Prob. 3QECh. 8.5 - Prob. 4QECh. 8.6 - In what ways are abstract data types and classes...Ch. 8.6 - What is the difference between a class and an...Ch. 8.6 - Prob. 3QECh. 8.7 - Suppose the Vole machine language (Appendix C) has...Ch. 8.7 - Prob. 2QECh. 8.7 - Using the extensions described at the end of this...Ch. 8.7 - In the chapter, we introduced a machine...Ch. 8 - Prob. 1CRPCh. 8 - Prob. 2CRPCh. 8 - (Asterisked problems are associated with optional...Ch. 8 - Prob. 4CRPCh. 8 - (Asterisked problems are associated with optional...Ch. 8 - Prob. 6CRPCh. 8 - Prob. 7CRPCh. 8 - Prob. 8CRPCh. 8 - Prob. 9CRPCh. 8 - Prob. 10CRPCh. 8 - Prob. 11CRPCh. 8 - Prob. 12CRPCh. 8 - Prob. 13CRPCh. 8 - Prob. 14CRPCh. 8 - Prob. 15CRPCh. 8 - Prob. 16CRPCh. 8 - Prob. 17CRPCh. 8 - Prob. 18CRPCh. 8 - Design a function to compare the contents of two...Ch. 8 - (Asterisked problems are associated with optional...Ch. 8 - (Asterisked problems are associated with optional...Ch. 8 - Prob. 22CRPCh. 8 - Prob. 23CRPCh. 8 - Prob. 24CRPCh. 8 - (Asterisked problems are associated with optional...Ch. 8 - Prob. 26CRPCh. 8 - Prob. 27CRPCh. 8 - Prob. 28CRPCh. 8 - Prob. 29CRPCh. 8 - Prob. 30CRPCh. 8 - Design a nonrecursive algorithm to replace the...Ch. 8 - Prob. 32CRPCh. 8 - Prob. 33CRPCh. 8 - Prob. 34CRPCh. 8 - Draw a diagram showing how the binary tree below...Ch. 8 - Prob. 36CRPCh. 8 - Prob. 37CRPCh. 8 - Prob. 38CRPCh. 8 - Prob. 39CRPCh. 8 - Prob. 40CRPCh. 8 - Modify the function in Figure 8.24 print the list...Ch. 8 - Prob. 42CRPCh. 8 - Prob. 43CRPCh. 8 - Prob. 44CRPCh. 8 - Prob. 45CRPCh. 8 - Prob. 46CRPCh. 8 - Using pseudocode similar to the Java class syntax...Ch. 8 - Prob. 48CRPCh. 8 - Identify the data structures and procedures that...Ch. 8 - Prob. 51CRPCh. 8 - In what way is a class more general than a...Ch. 8 - Prob. 53CRPCh. 8 - Prob. 54CRPCh. 8 - Prob. 55CRPCh. 8 - Prob. 1SICh. 8 - Prob. 2SICh. 8 - In many application programs, the size to which a...Ch. 8 - Prob. 4SICh. 8 - Prob. 5SICh. 8 - Prob. 6SICh. 8 - Prob. 7SICh. 8 - Prob. 8SI
Knowledge Booster
Similar questions
- It is possible to demonstrate the return address of a function by using a series of instructions. Keep in mind that any modifications to the stack must not prohibit the process from returning control to the person who called it.arrow_forwardDetermine the stack's effectiveness when allowed to function independently.arrow_forwardIt is possible to show the return address of a function by executing a set of instructions in sequence. Be mindful that any changes you make to the stack must not hinder the procedure's ability to restore control to the entity that called it.arrow_forward
- Determine the stack's performance when permitted to be itself.arrow_forwardEach function has local memory associated with it to hold incoming parameters, local variables, and (in some cases) temporary variables. This region of memory is called a stack frame. Question 7 options: True Falsearrow_forwardUse C++ Programming Language. Objective Define a circular buffer data structure and test it. Problem Description: A circular buffer (also called a circular queue) is circular list of nodes where data items are added on one end of the buffer and removed from the other end. Because the nodes form a circular list, the list has no end or beginning: the tail node points to the head node, creating a ring of nodes. You may think of the nodes as containers or slots that are all initially empty but can be assigned a value in their data field info. Every time a new data item is inserted (inserting to a buffer is often referred as Writing), one slot is filled and the buffer has one less empty slot. Every time a data item is removed (referred to as Reading), the buffer has one more empty slot. Since the list has no beginning and no end, a pointer (writeIndex) is used to mark the next empty slot to write to and a second pointer (readIndex) is used to mark the next node to read from. The…arrow_forward
- To what degree does the stack operate most effectively when left to its own devices?arrow_forwardQuestion 2. Draw/Show the contents of the stack for the following data during each step through using the word: сирсаkes a. During input b. During outputarrow_forwardA stack is very useful in situations when data have to be stored and then retrieved in the —- order. A) same B) reverse C) ascending D) descendingarrow_forward
- Data Structure & Algorithm: Write a program to perform the following operations on a stack. a) Create functions for push and pop operations of the stack.b) Write a function to convert an infix expression to a postfix expression. Pass a one-dimensional character array P to the function as input (infix exp) and return character array Q (postfix exp). Test your program for the following input P : ( A – (B / C ) * D + E ) * F % G c) Write a function for the evaluation of a given postfix expression. For testing pass the postfix expression Q of part b and supply the following set of values. A = 90, B = 50, C = 2, D = 3, E = 1, F = 2, G = 5arrow_forwardPlease do it with C++arrow_forwardDevelop an application using java language that store characters A, B and C in a stack array and then displays both the size and the last-in element of the stack. The application should then remove the last element of the stack and then display again both the size and the last-in element of the stack. Appropriate stack methods should be used to add, delete and display characters.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning