Bubbling ordering of Java data structures

Source: Internet
Author: User

arraybub{    []  (max) {        = [max]=  }     (value) {        [] = value++}      () {         (j=j<j++) {             system. Print ([j]+) System: println ()}    }     () {         Outinlong tem (out = -out>out--) {              (in = in<outin++) {                  ([in] > [in+]) {                     tem = [in+][in+] =  [in][in] = tem}            }        }     }}


Bubblesort {(string[] args) {maxSize = Arraybub arr = Arraybub (maxSize) Arr.insert () Arr.insert () arr.inse RT () Arr.insert () Arr.insert () Arr.insert () Arr.insert () Arr.insert () Arr.insert () Arr.insert () Arr.insert () Arr.insert () Arr.insert () Arr.display () Arr.bubblesort () Arr.display ()} () {}}


First look at the above code, bubble sort core is: Bubblesort () method, for loop nesting, the outer layer of each row minus one, the inner contrast to the outer value of out.

The bubble sorting algorithm makes N (N-1)/2 comparisons, that is, O (n*n), which removes the minus and ignores the constant 2 to derive the secondary result.


This article is from the "Yao Sea" blog, please be sure to keep this source http://tl2011.blog.51cto.com/6006611/1884031

Bubbling ordering of Java data structures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.