Question: public class StringBag { // the array to hold the data private String [] bag; // the number of elements being held (also the next

public class StringBag {

// the array to hold the data

private String [] bag;

// the number of elements being held (also the next index where a new

// String can be put).

private int count;

public StringBag(int length) {

bag = new String[length];

count = 0;

}

}

Write a function that sorts the Strings (StringBag class) in ascending alphabetical order. Identify your algorithm in the comments in the code Please use insertion sort

1) Write your test case for this method

@Test

public void testSortAscending() {

StringBag bag = new StringBag();

// add() and indexOf() are methods of previous HW

}

2) Write your method Please use insertion sort

public void sortAscending() {

// an insertion sort, but bubble or selection also work

}

___________________________________________________________________________________

Write a function that sorts the Strings in descending alphabetical order. Identify your algorithm in the comments in the code Please use selection sort, insertion sort, or bubble sort

1) Write your test case for this method

@Test

public void testSortDescending() {

}

2) Write your method

public void sortDescending() {

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!