How to write code to realize binary search and bubble sorting
This article mainly introduces "how to write code to achieve binary search and bubble sorting". In daily operations, I believe many people have doubts about how to write code to achieve binary search and bubble sorting. I have consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "how to write code to achieve binary search and bubble sorting". Next, please follow the editor to study!
Public class BinarySearch {/ * * @ param arr ascending array * @ param start * @ param end * @ return * / public static int binarySearch (int [] arr,int start,int end,int findVal) {int mid = (start+end) / 2; int midVal= arr [mid]; if (midVal==findVal) {return mid } else if (midVal arr [j + 1]) {int temp = arr [j]; arr [j] = arr [j + 1]; arr [j + 1] = temp }} public static void main (String [] args) {int [] arr = {2,1,2,10,7,5}; bubbleSortAsc (arr); for (int I = 0; I < arr.length; iTunes +) {System.out.print (arr [I] + ") At this point, the study on "how to write code to achieve binary search and bubble sorting" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!