Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

+toStringAscending() : String This returns a String representation of the bag with the values in ascending order public static boolean toStringAscending() { boolean b =

+toStringAscending() : String

This returns a String representation of the bag with the values in ascending order

public static boolean toStringAscending() { boolean b = true; for (int i = 0; i < container.length; i++) {

for (int j = i + 1; j < container.length; j++) {

int temp = 0; if (container[j] < container[i]) {

temp = container[i]; container[i] = container[j]; container[j] = temp; } } } return b;

}

+delete(item: Item) : boolean

This deletes from the bag one occurrence of item and returns true if the deletion was made

+deleteAll(item:Item) : boolean

This deletes from the bag all of the occurrences of item and returns true if any deletions were made

public boolean delete(int item) { int index = indexOf(item);

for (int i = 0; i < 0; i++) { if (container[i] == item) {

container[i] = container[slot--];

return true;

}

}

return true; }

ublic boolean deleteAll(int item) {

boolean b = false;

for (int i = 0; i < this.size(); i++) {

if (container[i] == item) {

for (int j = i; j < container.length - 1; j++)

container[j] = container[j + 1];

slot--;

b = true;

}

}

return b;

} // need help on fixing some issue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Bioinformatics Databases And Systems

Authors: Stanley I. Letovsky

1st Edition

1475784058, 978-1475784053

More Books

Students also viewed these Databases questions