RLE Encoding And Decoding using C..plz help.

Status
Not open for further replies.

garv84

Broken In
Run length Encoding And Decoding

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

QwertyManiac

Commander in Chief
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. :)
 
OP
G

garv84

Broken In
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..??
 

QwertyManiac

Commander in Chief
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:
Code:
LOOOOOOOOOOOOOOOOOOOOL

Total size: 22 Bytes
Thus using RLE compression technique, we can shorten it as:
Code:
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
 

QwertyManiac

Commander in Chief
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'.
 
OP
G

garv84

Broken In
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

Commander in Chief
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.
 
Status
Not open for further replies.
Top Bottom