Question 1: Stacks Given below are variables declared to implement integer stack: int size = 4; int top = -1; int [] int

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Question 1: Stacks Given below are variables declared to implement integer stack: int size = 4; int top = -1; int [] int

Post by answerhappygod »

Question 1: Stacks
Given below are variables declared to implement integerstack:int size = 4;int top = -1;int [] intStack = new int [size];a.) Assuming the stack intStack was initially empty, draw a stackafter the following operations are completed.
intStack.push (41);intStack.push (6);intStack.pop ( );intStack.pop ( );intStack.push (78);intStack.push (5);intStack.push (79);intStack.pop ( );intStack.push (5);
b.) Write a method in java to push an integer value in thestack.
Question 2: Queues
Assuming the queue intQueue of type integer is declared andseveral items are already enqueued, the value of rear is 3.a.) What will be the value of rear after adding an element tointQueue?b.) What will be the value of rear after removing an element fromintQueue?c.) Write a method in java to check if the queue is empty?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply