# RLE Encoding And Decoding using C..plz help.



## garv84 (Jan 7, 2008)

*Run length Encoding And Decoding*

Example input: 123334455555AAA
Output for above input: 1\12\13\34\25\5A\3


----------



## QwertyManiac (Jan 7, 2008)

[edited as requested]


----------



## garv84 (Jan 8, 2008)

thats great bro.


----------



## mehulved (Jan 8, 2008)

How about him giving your exams?


----------



## Faun (Jan 8, 2008)

mehulved said:


> How about him giving your exams?


lol...


----------



## QwertyManiac (Jan 8, 2008)

garv84 said:


> thats great bro.cn u plz post the decoding code too..thanxx a lot dudes..


No, I need 50$ for that please.


----------



## garv84 (Jan 8, 2008)

QwertyManiac said:


> No, I need 50$ for that please.



Lol.. 
Really..?


----------



## QwertyManiac (Jan 8, 2008)

Yeh, decoding is a piece of cake thats why. Try making something up and post it here if it doesn't work out. We'll help from there on.


----------



## Faun (Jan 8, 2008)

QwertyManiac said:


>


why dont u try topcoder and freelance.

I hope u will make enuff for ur work.


----------



## QwertyManiac (Jan 8, 2008)

Whoa, people pay for getting their homeworks done? Am rich then! $$$$-)


----------



## garv84 (Jan 8, 2008)

QwertyManiac said:


> Yeh, decoding is a piece of cake thats why. Try making something up and post it here if it doesn't work out. We'll help from there on.



ok bro..i'll try it up.


----------



## QwertyManiac (Jan 8, 2008)

Yeah try and post the problem you face along with what you did here.


----------



## garv84 (Jan 10, 2008)

plz tell me something..

say for ex : 1\125

all thses are characters.we are to print 1 125 tyms.how can we conver characters 125 into integar..??


----------



## ayush_chh (Jan 11, 2008)

i am not getting this question, can anyone help me understand it?


----------



## QwertyManiac (Jan 11, 2008)

garv84 said:


> plz tell me something..
> 
> say for ex : 1\125
> 
> all thses are characters.we are to print 1 125 tyms.how can we conver characters 125 into integar..??


Use the atoi() function.

@ayush_chh - Run-Length Encoding is used to compress files in which a particular character is repeated several times in succession. Like say we have a file with the content:

```
LOOOOOOOOOOOOOOOOOOOOL

Total size: 22 Bytes
```
Thus using RLE compression technique, we can shorten it as:

```
L[B]O[/B][B]\20[/B]L

Comment: [B]O\20[/B] means O repeated 20 times. A decoder would look for the \ and the value after it and while expanding it, it'd print it that many times to get the output back in the actual form.

Total size: 6 Bytes
```


----------



## garv84 (Jan 11, 2008)

ya.got it.thanx QM..


----------



## QwertyManiac (Jan 11, 2008)

Great, so your solution is ready?


----------



## QwertyManiac (Jan 11, 2008)

Scalability would mean basically some kind of increase. Maybe you can add an option of including more than one file into the program for compression in one go and that would make it scalable.

Optimizing the program for more power at less CPU cost would also mean the same in certain cases.

Modularity would mean dividing the program into sub-programs (read as: functions). So make a function for encoding, decoding, 255 chop, and so on. Just split them so that if there is a new function to be added, it can make use of certain feature of this entire RLE exclusively. 

Basically speaking, divide your program into sub programs. One function for decode, another for encode and so on. And collectively call them in main() to do a task thus accomplishing 'modularity'.


----------



## garv84 (Jan 11, 2008)

But i have implemented the encoding and the decoding in two different programs.will it be possible to call them as seperate functions in the main() method of a single program ..? or you mean to say calling a func encode() from main() in one and the other from the other prgrm..?

and hw to find the performance..do i need to calculate the complexity..?


----------



## QwertyManiac (Jan 11, 2008)

Two programs is fine too. But you can make it more easier by combining it into one can't you? You can detect the type of input file and perform the necessary execution (Encode or Decode) appropriately? Thats just my idea. But having 2 different programs is fine too, in modularity terms.

You can try increasing performance by modifying certain parts of your program. Its your style dependent. A small example (Unrelated to RLE perhaps) would be to replace that if-else ladder with a more optimized switch-case block. Things like that.


----------



## ayush_chh (Jan 15, 2008)

thank you for explaining me the stuff.....


----------

