Duplicate removal

Discussion in 'C Programming' started by raja, Feb 4, 2006.

  1. raja

    raja Guest

    Design and implement an efficient algorithm to remove consecutive
    1char, 2char, 3 char... so on recurrences in dictionary words.
    For example, "abbabccbc" first will become "ababcbc", then become
    "abc". Similarly, "abcaab" will become "abcab" and but stays as it is
    after that.
    raja, Feb 4, 2006
    #1
    1. Advertising

  2. "raja" <> writes:
    > Design and implement an efficient algorithm to remove consecutive
    > 1char, 2char, 3 char... so on recurrences in dictionary words.
    > For example, "abbabccbc" first will become "ababcbc", then become
    > "abc". Similarly, "abcaab" will become "abcab" and but stays as it is
    > after that.


    And why exactly would we want to do that?

    This looks like a homework assignment. If so, try to solve the
    problem yourself; if you run into trouble, show us what you have and
    exactly what problems your having, and we might be able to give you
    some hints.

    Either that, or give us your instructor's e-mail address so we can
    submit our solutions directly.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Feb 4, 2006
    #2
    1. Advertising

  3. raja

    Malcolm Guest

    "raja" <> wrote in message
    > Design and implement an efficient algorithm to remove consecutive
    > 1char, 2char, 3 char... so on recurrences in dictionary words.
    > For example, "abbabccbc" first will become "ababcbc", then become
    > "abc". Similarly, "abcaab" will become "abcab" and but stays as it is
    > after that.
    >

    Start by specifying the problem as a function.

    /*
    remove consecutive repeated characters from a string
    Parmas: dest - pointer to destination
    src - source string
    */
    void removerepeats(char *dest, const char *src)

    The algorithm should be pretty trivial to write. You just need one pass
    through the source string.

    Once you have written the function, test it, and then apply it to your
    problem.
    Malcolm, Feb 4, 2006
    #3
  4. raja

    Thad Smith Guest

    raja wrote:
    >
    > Design and implement an efficient algorithm to remove consecutive
    > 1char, 2char, 3 char... so on recurrences in dictionary words.
    > For example, "abbabccbc" first will become "ababcbc", then become
    > "abc". Similarly, "abcaab" will become "abcab" and but stays as it is
    > after that.


    Before you do that, consider whether it makes a difference in what
    order the replacements are done. If so, what order will you do them?
    If not, can you prove it?

    --
    Thad
    Thad Smith, Feb 4, 2006
    #4
  5. raja

    Default User Guest

    raja wrote:

    > Design and implement an efficient algorithm to remove consecutive
    > 1char, 2char, 3 char...



    Sorry, I have better things to do.


    Brian
    Default User, Feb 5, 2006
    #5
  6. "raja" <> writes:
    > Design and implement an efficient algorithm to remove consecutive
    > 1char, 2char, 3 char... so on recurrences in dictionary words.
    > For example, "abbabccbc" first will become "ababcbc", then become
    > "abc". Similarly, "abcaab" will become "abcab" and but stays as it is
    > after that.


    I'm probably unusually thick this morning, but I don't understand the
    specification.
    Arndt Jonasson, Feb 7, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    558
  2. Guest

    Gridview Duplicate removal.

    Guest, Feb 7, 2006, in forum: ASP .Net
    Replies:
    12
    Views:
    6,748
    Yuan Ren[MSFT]
    Feb 15, 2006
  3. lucy
    Replies:
    6
    Views:
    1,284
    Carl Howells
    Sep 2, 2004
  4. Roedy Green

    break removal

    Roedy Green, Jul 2, 2005, in forum: Java
    Replies:
    9
    Views:
    422
  5. David Unric
    Replies:
    14
    Views:
    313
    Robert Klemme
    Mar 18, 2011
Loading...

Share This Page