Introduction Today, I am going to dive into the awesome world of sorting. It reminds me with entry level computer science courses and algorithm design. The goal of this article is to summarize popular sorting algorithms and put it in …

# Tag Archives: Sort

## Combining and Merging Two Arrays

Merging Two Arrays Problem Given two sorted arrays A and B of different sizes m and n. Describe an algorithm to combine the two arrays into one array. The output array must not have duplicates. The output array must maintain …

## 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 …

## 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 …

## Iterative Binary Search Function

Problem Given an array of positive integers. Write an iterative version of binary search to find an element in the array Solution Binary search can be easily implemented using recursion due to the divide and conquer nature of the algorithm …

## kth Largest Element in an Array

Problem Given an array of positive integers. Find the n(th) largest element in the array. Solution Sort the array in decreasing order then loop through the sorted array while counting unique elements then stop when the count is equal to …