Posts

SPOJ Problem - CPTTRN5 - Character Patterns (Act 5)

This is a problem from SPOJ. We have to print a character pattern according to the input given.

We have input 

33 1 24 4 12 5 2

C++: Huffman Coding using STL

Image
Huffman Code compress data very effectively: saving of 20% to 90% are typical, depending on the characteristics of the data being compressed.Huffman's greedy algorithm uses a table giving how often each character occurs (i.e., its frequency) to build up an optimal way of representing each character as a binary string. This algorithm constructs an optimal prefix code called a Huffman Code.

C++: Maximum Priority Queue

Image
In a Priority Queue, an element with high priority is served before an element with low priority. If two elements have the same priority, they are served according to their order in the queue.

While priority queues are often implemented with heaps, they are conceptually distinct from heaps. [Wikipedia]

C++: Selection sort using STL

Image
Selection sort is an sorting algorithm. It has O(n2) time complexity. It has performance advantages over more complicated algorithms in certain situations, particularly where auxiliary memory is limited.

It divides the input list or the array in two parts:
1. Sorted array
2. Unsorted array

The minimum element from the unsorted array is picked and placed at the end of sorted array in each iteration.

C++: Program to find smallest element is an array which is repeated exactly 'k' times

Image
This is a problem from GeeksForGeeks. I have tried to write different code for the problem.

The problem says we have an array of elements . We have to find the smallest element which is repeated exactly k times.

Popular Posts

C++: Selection sort using STL

Top 10 Web Sites Every Programmer Should Visit Daily