Thread: Character frequency counting

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    168

    Character frequency counting

    << split from http://cboard.cprogramming.com/c-pro...-%2A%2Att.html >>
    To analysing a string, then finding the char whose counts of appearing in string is max.
    how to solve this question?

    for example:
    Code:
    char *string = "ab---ebbbe";
    the appearing counts of char 'b'  is max. It is 3.
    I now think two method.
    one is :
    Code:
    sort(string);
    statisticalCountofChar(string);
    the other is
    Code:
    char *individualofChar;
    for ( string )
    {
          for ( *individualofChar )
          {
                caculateCountofChar();
          }
    }
    is there even more better method to solve this question?
    how to solve this question using HASHING TABLE? how to design hashing function ?

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Hijacking your own thread. Now that's funny.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Should've deleted the chuffin thing
    how to solve this question?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Character frequency table
    By raidkridley in forum C Programming
    Replies: 1
    Last Post: 02-12-2009, 06:31 AM
  2. need help with 'character counting from a .txt file'
    By master_vst in forum C Programming
    Replies: 5
    Last Post: 11-09-2008, 02:17 PM
  3. get wide character and multibyte character value
    By George2 in forum C++ Programming
    Replies: 27
    Last Post: 01-27-2008, 05:10 AM
  4. about program that counts a character frequency
    By Unregistered in forum C++ Programming
    Replies: 15
    Last Post: 04-23-2002, 01:21 PM
  5. Character counting program
    By TankCDR in forum C++ Programming
    Replies: 5
    Last Post: 04-05-2002, 10:01 PM