subject

Suppose we have a Java class named IntArraystack which uses an array to implement a Stack that holds integers. (a) Write a new method void count PosNeg (IntArrayStack intArrayStackobj) to count and display the number of positive integers and number of negative integers in object intArrayStackobj. In addition, the intArrayStackobj object must be restored to its original state after counting.
(b) Describe the worst-case time complexity of the countPosneg method in Big-Oh notation.
(c) Write a RECURSIVE (NOT iterative) method Boolean sameStack(IntArrayStack stacki, IntArrayStack stack2) to check whether the two stack objects stack1 and stack2 contain the same elements (element order does MATTER). The sameStack method return true if the two input stacks contain the same elements and false otherwise. Note: You can ONLY call push, pop, and peek methods to perform operations on IntArrayStack object. Use o (1) as complexities for push, pop, and peek methods of Stack operations when performing analysis.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 10:50
The volume v and paper surface area a of a conical paper cup are given by where r is the radius of the base of the cone and h is the height of the cone. a. by eliminating h, obtain the expression for a as a function of r and v. b. create a user-de ned function that accepts r as the only argument and computes a for a given value of v. declare v to be global within the function. c. for v ! 10 in.3 , use the function with the fminbnd function to compute the value of r that minimizes the area a. what is the corresponding value of the height h? investigate the sensitivity of the solution by plotting v versus r. how much can r vary about its optimal value before the area increases 10 percent above its minimum value?
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
To check whether your writing is clear , you can
Answers: 2
question
Computers and Technology, 24.06.2019 07:00
You are most likely to automatically encode information about
Answers: 1
question
Computers and Technology, 24.06.2019 16:30
The database design steps are listed below in the incorrect order. choose the correct order number next to each step. determine the information to be stored in the database. determine the fields needed to record the data determine if there will be any repetition of data entered, and separate the fields into tables to normalize the data. create relationships to connect the tables.
Answers: 3
You know the right answer?
Suppose we have a Java class named IntArraystack which uses an array to implement a Stack that holds...
Questions
question
Mathematics, 11.03.2021 05:30
question
English, 11.03.2021 05:30
question
Mathematics, 11.03.2021 05:30
question
Mathematics, 11.03.2021 05:30
Questions on the website: 13722363