Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. Bubble sort was not what I thought it was.

Bubble sort was not what I thought it was.

Scheduled Pinned Locked Moved Algorithms
3 Posts 3 Posters 79 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User-15754677
    wrote last edited by
    #1

    I used to think bubble sort like this:

    i=0 to array.length
    	j=i+1 to array.length
    		if(array[i]>arr[j]
    			swap them
    

    I have been thinking like that for a long amount of time. Where did I go wrong? Which type of sorting algorithm am I talking about?

    1 Reply Last reply
    0
    • CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote last edited by
      #2

      It looks bubble sort, to me.

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • Mircea NeacsuM Offline
        Mircea NeacsuM Offline
        Mircea Neacsu
        wrote last edited by Mircea Neacsu
        #3

        It is "exchange sort" https://en.wikipedia.org/wiki/Sorting_algorithm#Exchange_sort

        1 Reply Last reply
        1
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups