Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given following recursive selection sort program and the array (it is called list in the main method), show a hand trace of following variables until

Given following recursive selection sort program and the array (it is called list in the main method), show a hand trace of following variables until the whole list is sorted. Initial values of the hand trace are already given. (10 points) low high indexOfMin min 0 8 0 22 public class RecursiveSelectionSort { public static void sort(double[] list) { sort(list, 0, list.length - 1); // Sort the entire list }

public static void sort(double[] list, int low, int high) { if (low < high) { // Find the smallest number and its index in list(low .. high) int indexOfMin = low; double min = list[low]; for (int i = low + 1; i <= high; i++) { if (list[i] < min) { min = list[i]; indexOfMin = i; } } // Swap the smallest in list(low .. high) with list(low) list[indexOfMin] = list[low]; list[low] = min; // Sort the remaining list(low+1 .. high) sort(list, low + 1, high); } } public static void main(String[] args) { double[] list = {22, 13, 17, 51, 22, -14, 30}; sort(list); for (int i = 0; i < list.length; i++) System.out.print(list[i] + " "); } }

Write a Java method using following method header to count and return the number of times a particular character appears in a text file. (10 points) public int charCount(char ch) Hint: following Java statements may help. File f = new File (filename); FileInputStream inf = new FileInputStream(f); char let; int n = 0; while ((n = inf.read()) != -1){ let = (char)n;

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

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago