Bubble Sort with Arrays

This is a discussion on Bubble Sort with Arrays within the C++ Programming forums, part of the General Programming Boards category; What I have to do is create a fxn called bubbleSort and a helper fxn called swap. bubbleSort takes two ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    29

    Arrow Bubble Sort with Arrays

    What I have to do is create a fxn called bubbleSort and a helper fxn called swap. bubbleSort takes two parameters, an array of doubles and a size, and puts the list in descending order. Swap takes two reference parameters. Here is what I have so far what seems to be wrong? I know they want the swap as a reference but I thought arrays coudnt be referenced...

    Code:
    void swap(double array[], double array1[])
    {
    
      double hold;
      double index;
    
      hold=array[index];
      array[index]=array[index+1];
      array[index+1]=hold;
    }
    
    
    
    
    
    
    
    void bubbleSort(double array[], int count)
    {
    
      for(int index = 0; index < count -1; index++)
        {
          if (array[index]<array[index+1])
    		swap(array[index],array[index+1]);
    
        }
    }

  2. #2
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bubble sort error
    By swgh in forum C Programming
    Replies: 2
    Last Post: 08-05-2007, 12:13 PM
  2. help, bubble sort function
    By Crcullen3916 in forum C++ Programming
    Replies: 8
    Last Post: 05-01-2007, 08:00 AM
  3. Psuedo random numbers in a bubble sort.
    By Sir Andus in forum C++ Programming
    Replies: 10
    Last Post: 04-09-2007, 09:25 PM
  4. bubble sort not working with struct...
    By Jenica in forum C++ Programming
    Replies: 1
    Last Post: 10-12-2004, 01:54 PM
  5. Problem with Bubble Sort code
    By lisa1234 in forum C++ Programming
    Replies: 7
    Last Post: 01-13-2004, 03:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21