Answer:
1. The LZ coding scheme is especially suited to data which has a high degree of repetition, and makes back references to these repeated parts. Typically a flag is normally used to identify coded and unencoded parts, where the flag creates back references to the repeated sequence. With the LZ table given below, solve the following: 'P', 'i', 'c', 'k', 'y', ' ', 'p', 'e', 'o', 'p', 'l', 'e', 261, 257, 'k', ' ', 'P', 'e', 't', 'e', 'r', 271, 'a', 'n', 271, 'e', 278, 'u', 't', '-', 'B', 283, 274, 'r', ',', ' ', 't', 'i', 's', 291, 'h', 267, 262, 282, 284, 'b', 287, 275, 294, 'p', 269, 260, 262, 264, 266, 268, 258 (use Table 2 below)
Additional information:
The following is the LZ Coding Table 1: [256] Co [257] ow [258] ws [259] s [260] g [261] gr [262] ra [263] az [264] ze [265] e [266] i [267] in [268] n [269] gr [270] ro [271] ov [272] ve [273] es [274] s o [275] on [276] n g [277] gra [278] as [279] ss [280] s w [281] wh [282] hi [283] ic [284] ch [285] h [286] gro [287] ows [288] s i [289] in [290] groo [291] ove [292] es [293] a [294] an [295] n gr [296] rov [297] ves The following is LZ Coding Table 2: [256] Pi [257] ic [258] ck [259] ky [260] y [261] p [262] pe [263] eo [264] op [265] pl [266] le [267] e [268] pi [269] ick [270] k [271] P [272] Pe [273] et [274] te [275] er [276] r [277] Pa [278] an [279] n [280] Pe [281] ea [282] anu [283] ut [284] t- [285] -B [286] Bu [287] utt [288] ter [289] r, [290] , [291] t [292] ti [293] is [294] s [295] th [296] he [297] e p [298] pea [299] anut [300] t-b [301] bu [302] utte [303] ers [304] s p [305] pi [306] icky [307] y p [308] peo [309] opl [310] le [311] pic Example In he example above, we have: Input: Cows graze in groves on grass which grows in grooves in groves Compressed: ['C', 'o', 'w', 's', ' ', 'g', 'r', 'a', 'z', 'e', ' ', 'i', 'n', 260, 'r', 'o', 'v', 'e', 259, 'o', 268, 261, 'a', 's', 259, 'w', 'h', 'i', 'c', 'h', 269, 257, 259, 267, 286, 271, 273, 266, 276, 270, 272, 's'] Deompressed: Cows graze in groves on grass which grows in grooves in groves The first entry in the dictionary add position 256 will be 'Co', next it will be 'ow'. We can see that the following index values have been defined: The code ' g' has been defined with an index of 260. The code 's ' has been defined with an index of 259. 268, 261 represents 'n ' and 'gr', representively. The resulting dictionary entries that are added: Adding: [256] Co Adding: [257] ow Adding: [258] ws Adding: [259] s Adding: [260] g Adding: [261] gr Adding: [262] ra Adding: [263] az Adding: [264] ze Adding: [265] e Adding: [266] i Adding: [267] in Adding: [268] n Adding: [269] gr Adding: [270] ro Adding: [271] ov Adding: [272] ve Adding: [273] es Adding: [274] s o Adding: [275] on Adding: [276] n g Adding: [277] gra Adding: [278] as Adding: [279] ss Adding: [280] s w Adding: [281] wh Adding: [282] hi Adding: [283] ic Adding: [284] ch Adding: [285] h Adding: [286] gro Adding: [287] ows Adding: [288] s i Adding: [289] in Adding: [290] groo Adding: [291] ove Adding: [292] es Adding: [293] in Adding: [294] n gr Adding: [295] rov Adding: [296] ves
Ans: Picky people pick Peter Pan Peanut-Butter, tis the peanut-butters picky people pick