java - Return a void method using recursion -


I am trying to sort quick on the array of strings, but I did not know how to make an array of strings Returning to a zero method, PS: In the case only, I want to inform you that all other methods like swap and split have already been implemented and I do not think you have to see them. This is not the option to use any third party assistant libraries.

  public static string [] quicksort (string [] a) {int less = 0; Int high = a.length; Quicksort_lomuto (one, low, high); Return; // & lt; - This is the problem !!! What should I return? } Public static zero quicksort_lomuto (string [] a, int i, int j) {if (j-i & lt; 2) returns; Int k = partition_lomuto (a, i, j); Quartort_Lamoto (A, I, K); Quicksort_lomuto (A, K + 1, J); }  

If you have a zero return You can simply change the contents of the array while the array parameter has been passed from the value, this "value" is basically an indicator for the array, not the entire array of contents. An example:

  public static zero main (string [] args) {string [] arr = new string [] {"foo", "bar"}; ChangeMyArray (Arrival); System.out.println (arr [0] + "," + arr [1]); // output is: foo, baz} Private static zero change mayaire (string [] myArray) {myArray [1] = "baz"; }  

If you set the set array parameter to something ( a = mumble ), it will not be reflected when returning from that method . But if you set the content of the array to something ( a [i] = mumble ), then it will be.

You do not want to change the input array in that situation, you can get the same solution with the "output parameter". Public static zero quicksort_lomuto (string [] inputArray, int i, int j, string [] outputArray) {if (outputout == blank) {throw out new illegal order exception ("Output is not empty. can"); } If (outputArray.length! = Inputarray.length!) {Removing new invalid execution conclusions ("Output should be the same length as the input array"); } / * Sort input array, outputAir * /}


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -