Thread: Alphabetizing n words.

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    23

    Alphabetizing n words.

    My question is:
    What is the best algorithm for alphabetizing strings of chars in C?

  2. #2
    Registered User
    Join Date
    Jan 2006
    Posts
    23
    I know bubble sort has O(n^2) and that is really bad, anyone have an extremely fast way of going about this? (sorting LOTS of strings)

  3. #3
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    See http://en.wikipedia.org/wiki/Quick_sort.

    The C standard library has a qsort which can be used in conjunction with strcmp for this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 01:22 PM
  3. Problem with malloc() and sorting words from text file
    By goron350 in forum C Programming
    Replies: 11
    Last Post: 11-30-2004, 10:01 AM
  4. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM