Velocity Reviews > Duplicate removal

# Duplicate removal

raja
Guest
Posts: n/a

 02-04-2006
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.

Keith Thompson
Guest
Posts: n/a

 02-04-2006
"raja" <(E-Mail Removed)> 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.velocityreviews.com/forums/(E-Mail Removed) <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.

Malcolm
Guest
Posts: n/a

 02-04-2006

"raja" <(E-Mail Removed)> 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.

Guest
Posts: n/a

 02-04-2006
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?

--

Default User
Guest
Posts: n/a

 02-05-2006
raja wrote:

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

Sorry, I have better things to do.

Brian

Arndt Jonasson
Guest
Posts: n/a

 02-07-2006

"raja" <(E-Mail Removed)> 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.