In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "java bubble sorting algorithm how to use", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "java bubble sorting algorithm how to use" it!
Bubble sorting is a simple sorting algorithm. It repeatedly visits the sequence to be sorted, compares two elements at a time, and swaps them if they are in the wrong order. The work of visiting the sequence is repeated until there is no need for swapping, that is, the sequence has been sorted. The algorithm gets its name because smaller elements slowly "float" to the top of the sequence by swapping.
1.1 algorithm description
Compare adjacent elements. If the first one is bigger than the second, exchange them for two.
Do the same for each pair of adjacent elements, from the first pair to the last pair, so that the last element should be the largest number.
Repeat the above steps for all elements except the last one
Repeat steps 1-3 until the sorting is complete.
1Candle *
2 * @ description: bubble sort
3 * Bubble sorting only manipulates two adjacent data. Each bubbling operation compares the two adjacent elements to see if they meet the size requirements.
4 * if you are not satisfied, let them swap. A bubble moves at least one element to where it should be, repeating it n times
5 * the sorting of n pieces of data is completed.
6 * /
7public class BubbleSort {
8 public void bubbleSort (Integer [] arr, int n) {
9 if (n
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.