Tag: Hash

LZW Compression Method

LZW Algorithm: Introduction It is beyond our imagination to specify a ceiling for the amount of information that an individual or a group of people potentially need to store and/or exchange. Using computer systems, almost all kinds of information can be digitized and therefore saved to storage media or sent across channels all over the

Perl Struct Example

Problem Provide example code in Perl to implement an array of C like structs Solution Use a hash table. The hash key is recommended to be a unique identifier and the hash value is a reference to an array. The idea is simple and the rest is just using the correct Perl syntax Code Here

Array Missing Number

Problem Given an array of n-1 unique integers. Each element in the array is an integer between 1 and n. Write a program to print the missing number in the array Solution To clarify this problem let us take a simple example. Assume n = 3 so the array consists from two elements only. Here

Perl Sort Hash by Value

Problem Given a log file similar to Linux syslog format as in the following example: Jan 4 03:15:01 pla kernel:pla: Some error message Write a Perl script to print the top 5 most repeated error messages. Solution Read the file line by line then split each line using ":" as separator then use the error