Stack Java Class – Explained

Earlier we saw about Stack and its implementation using Linked List. Java has a built in class for Stack. In this article we will discuss about it in detail. First brief about Stack. What is Stack?? Stack is an abstract data type (ADT) and very useful in programming. In computer science, a stack is an abstract data type that serves … Read more Stack Java Class – Explained

Calculate Logn base r – Java Implementation

Objective: Given a number n and r, write a program to calculate Logrn Example: N = 32, r =2 Log232= 5 N = 64, r = 4 Log464= 3 Approach: Without using built-In function- Initialize result = 0. Keep dividing the given number by r till number is greater than 0 and add one to … Read more Calculate Logn base r – Java Implementation

Check if two Strings are equal without using built-in function – Java

Objective– Given two strings, find out if they are equal or not without using any built-in function (without using equals() function in java). Example: String x=’tutorial’ and String y=’tutorial’ are equal – true String x=’tutorial’ and String y=’tutorial ‘ are equal – false String x=’tutorial’ and String y=’ ‘ are equal – false Approach: If … Read more Check if two Strings are equal without using built-in function – Java

Deque Implementation – Java

Java Deque Interface – It’s a linear collection. The Deque interface is a subtype of the util.Queue interface. Deque is acronym of “Double Ended Queue” means it supports insertion and removal of data from both the ends. So it can be used as Stack OR Queue. Declaration public interface Deque extends Queue Methods: Return Type Method Description boolean add(E e)  Insert … Read more Deque Implementation – Java

Priority Queue in Data Structure

Earlier in we have seen Min-Heap and Max-Heap Implementation. Priority Queue is its built-in implementation in Java. In this article we will see how to perform Min-Heap and Max-Heap using Priority Queue. Brief: A priority queue is an abstract data type where each element has a “priority” assigned to it. So the element with the … Read more Priority Queue in Data Structure