Bucket Sort Problems... Please Help!

This is a discussion on Bucket Sort Problems... Please Help! within the C++ Programming forums, part of the General Programming Boards category; What am I doing wrong here?? Am I reading the file in correctly? What if any thing is wrong with ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    6

    Red face Bucket Sort Problems... Please Help!

    What am I doing wrong here?? Am I reading the file in correctly? What if any thing is wrong with the Bucket Sort part? It is supposed to output what the array looks like after each pass and then again after the array is sorted making the minimum # of passes. Also, I am supposed to output what the largest # is and how many digits it is. Thanks again guys!


    #include #include #include int main() { ifstream infile ("/u3/svlasnik/values"); const int size = 6; int array[size] = { 0 }; for ( int x = 0; x < size ; x++ ) infile >> array[x]; int *bucketData; *bucketData = array[size - 1]; for(int i = 0; i < array[size - 1]; i++) { bucketData[i] = (rand() % 1000) / 1000.0; for ( int x = 0; x < size ; x++ ) cout << "Look, here's value " << x << ": " << array[x] << endl; } return 0; }

  2. #2
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266
    this is about all the help i can give you, maybe someone else will helpout. did you write the code in the block form like that? don't forget code tags next time.

    Code:
    #include <didyouforgetsomething.h>
    #include 
    #include 
    
    int main() 
    { 
    	ifstream infile ("/u3/svlasnik/values"); //is that really the filename
    	const int size = 6; 
    	int array[size] = { 0 }; 
    	for ( int x = 0; x < size ; x++ ) //a cerr used here
    		infile >> array[x]; 
    	int *bucketData; 
    	*bucketData = array[size - 1]; 
    	for(int i = 0; i < array[size - 1]; i++) 
    		{ bucketData[i] = (rand() % 1000) / 1000.0; //:confused:
    			for ( int x = 0; x < size ; x++ ) 
    		}		cout << "Look, here's value " << x << ": " << array[x] << endl;  
    	return 0; 
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sort two vectors in the same order
    By jw232 in forum C++ Programming
    Replies: 2
    Last Post: 03-08-2008, 05:49 PM
  2. Quick Sort
    By chriscolden in forum C Programming
    Replies: 3
    Last Post: 06-07-2006, 07:44 AM
  3. Bubble Sort, Qucik Sort
    By insomniak in forum C Programming
    Replies: 2
    Last Post: 03-15-2003, 04:54 PM
  4. Bucket Sort
    By bearcat19 in forum C++ Programming
    Replies: 0
    Last Post: 03-07-2003, 12:27 PM
  5. Sorting an array of structures with sort()
    By rmullen3 in forum C++ Programming
    Replies: 3
    Last Post: 01-03-2003, 03:02 PM

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