Stack Using Linked List

Stack Using Linked List package datastructure.algorithms.Stack; /** * * @author GOKUL */ public class StackUsingLinkedList { private Node head; public StackUsingLinkedList() { this.head=null; } public void push(int data) { head=new Node(data,head); } public int pop()…

Stack Using Array

Stack Using Array /** * * @author GOKUL */ public class StackUsingArray { private int[] array; private int size; private int top = -1; public StackUsingArray(int size) { this.size = size; array = new int[size];…

Dynamic Array

Dynamic Array class  package datastructure.algorithms.ArrayList; /** * * @author GOKUL */ public class ArrayList<T> { private Object[] array; private int size; private int index = -1; public ArrayList() { this.size = 5; array = new…

Linked List

Node class /** * * @author GOKUL */ public class Node { private int data; private Node next; public Node(int data,Node next) { this.data=data; this.next=next; } public int getData() { return data; } public void…

Greatest Common Divisior

Program for finding the greatest common divisor or Highest common factor for two numbers. public class Gcd { public static void main(String args[]) { int gcd = gcd(2336, 1314); System.out.println(gcd); } private static int gcd(int…

Decimal To Binary

Converting Decimal to Binary can be done from various ways , but lets check the easiest and the best way with minimum time complexity. public class BinaryRepersentation { public static void main(String args[]) { int…

BinarySearch

Binary Search is used to find an element in an array of element in logarithmic time. The time complexity of Binary Search is O(log n).Which is very fast in comparision to linear search. Features Binary…

Searching an Element in Array

Searching an element in array is very easy, we just need to iterate through every element in the array and if we find the element just prints its location otherwise just print "the element not…

Get Started With Java

Let's get started with a hello world java program and see how programming with java is fun. A Simple program printing "hello world" in java.   class Hello{ private static String s="hello world"; public static…

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!