Tag Archives: 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 …

Read more »

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 …

Read more »

Perl Script to Parse Log File

Problem You have a log file on UNIX operating system. Each line in the log file contains an IP address in the 10th column where columns (or fields) are separated by a space. Write a Perl program to parse the …

Read more »

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 …

Read more »

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 …

Read more »

Find the most repeated character in a string

Most repeated character string Given a string of characters find the character that is repeated the most. Solution This is almost the same as the First None Repeating Char problem. We are going to borrow the same code however we …

Read more »

Sql unique distinct select

Problem Write code to simulate the SQL statement “Select unique emp_name from employees” Solution Assuming we have an array of employee names we need to write a function that prints the unique employee names in the array. We can use …

Read more »

Page 1 of 212