Stack Implementation using Templates in C++

In previous post, we have discussed C++ implementation of stack data structure using classes. In this article, we will make code generic for all data-types by using C++ templates.  

Generate Random Numbers in Java

In this post, we will see how to generate random numbers between 0 to n, both inclusive, in Java using Random class, Math.random(), ThreadLocalRandom class, SecureRandom class, and Apache Commons.

Stack Implementation in C++

A stack is a linear data structure that serves as a container of objects that are inserted and removed according to the LIFO (last-in first-out) rule.

Sort a K-Sorted Array

Given a k-sorted array that is almost sorted such that each of the N elements may be misplaced by no more than k positions from the correct sorted order. Find a space-and-time efficient algorithm to sort the array.