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?
Question 1: Stacks Given below are variables declared to implement integer stack: int size = 4; int top = -1; int [] int
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am