View Single Post
Old Aug 24th, 2006, 7:32 PM   #3
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 290
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
cpp Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. int main()
  5. {
  6. int array[] = {9, 7, 5, 4, 1, 7, 3, 2, 8, 0};
  7. const int size = sizeof(array)/sizeof(int);
  8.  
  9. std::sort(array, array+size);
  10.  
  11. for (int i = 0; i < size; i++)
  12. std::cout << array[i];
  13.  
  14. return 0;
  15. }

O(n log N) - I think I read that std::sort uses introsort nowadays...


EDIT: did some reading, it looks like just the SGI C++ STL uses introsort, I guess the regular C++ STL still uses quicksort...
andro is offline   Reply With Quote