Category: Basic

Stack implementation in Java

  This article covers the stack implementation in Java. A stack is a linear data structure which follows the LIFO (last-in first-out) principle. That means the objects can be inserted or removed only at one end of it also called as top.

Sieve of Eratosthenes

Sieve of Eratosthenes is a very efficient algorithm that can be used in most coding competitions involving prime numbers in the range of a given number n.   The algorithm starts off by assuming that all the numbers in the range 2 to n are prime. Now we traverse the list starting from 2 to …

Program to find n’th Fibonacci number

Write a program to calculate n’th Fibonacci number where n is a given positive number.   Fibonacci sequence is characterized by the fact that every number after the first two is the sum of the two preceding ones. For example, consider below sequence – 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, …

Queue implementation in java

  A queue is a linear data structure which follows the FIFO (first-in first-out) principle. That means the object which is inserted first will be the first one out, followed by the object which was inserted next. The queue supports below core operations –

Queue implementation using Templates in C++

In previous post, we have discussed C++ implementation of queue data structure using class and standard libraries. In this article, we will make the class code generic by using C++ templates to support all data-types.

Queue implementation in C++

  A queue is a linear data structure that serves as a container of objects that are inserted & removed according to the FIFO (first-in first-out) principle. It has three main operations: enqueue, dequeue and peek. We have discussed about these operations in previous post and also covered C implementation of queue data structure using an array …

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.  

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. It has three main operations: push, pop and peek. We have discussed about these operations in previous post and covered array and linked list implementation of stack data structure in …

Queue implementation using linked list

  A queue is an linear data structure that serves as a collection of elements, with three main operations: enqueue, dequeue and peek. We have discussed about these operations in previous post and covered array implementation of queue data structure. In this post, linked list implementation of queue is discussed.