## Heap Sort – Java Implementation

What is Heap Sort?? Heap sort is comparison based sorting algorithm. Heap sort is considered as improved selection sort, it divides the input into sorted and unsorted region. The improvement from selection sort is...

What is Heap Sort?? Heap sort is comparison based sorting algorithm. Heap sort is considered as improved selection sort, it divides the input into sorted and unsorted region. The improvement from selection sort is...

Objective: Write a program to print first n numbers in Fibonacci series. Fibonacci number: First two Fibonacci numbers are defined as 0 and 1 and every number after the first two is the sum...

A rectangle is a quadrilateral with four right angles. Say rectangle is given with side’s length A and B Area of Rectangle = A * B Perimeter of rectangle = 2(A+B) Code: Run This Code Output: Area of Rectangle:...

Objective: Given an array of integers A[] which is sorted in two parts (both parts are individually sorted), find no of reverse pairs means no of (i, j) pairs where i belongs to the...

Objective: Given a String, write a java program to reverse the string using Stack Example: Input: “tutorial horizon” Output: “noziroh lairotut” Recommended: Please read Stack Data Structure before continue to read. Approach: Initialize a...

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 as a collection of elements. Majorly all the operations are done at only one...

Earlier we have seen what Dijkstra’s algorithm is and how it works. In this article we will see its implementation using adjacency list and Priority Queue. Prerequisites: Adjacency List Priority Queue Dijkstra’s Algorithm basics...

In this article we will discuss about what is bubble sort, why it is considered as one of the simplest sorting algorithm, what its complexity, how we can improve the bubble sort algorithm. What...

Objective: Given the base and height of a triangle, using math formula for calculating the area of triangle, write an java program to calculate the triangle area. Area of a Triangle: (Base * Height)/2...

Objective – Given a number, Write a program to get the sum of digits in a number till it become a single digit. Example: N = 999 -> 9+9+9 = 27-> 2+7 = 9...

Objective: Given a number n, write a program to calculate Log2n without using built-in function. Example: N = 32 Log232 = 5 N = 64 Log264 = 6 Approach: Initialize result = 0. Keep...

Objective: Given a number, write a program to check if the number is prime or not. Prime Number: A number is called a prime number when number is not divisible by 1 or by...

Objective: Given a number N, write a program to print first N prime numbers. What is Prime number:?? A prime number (or a prime) is a natural number greater than 1 that cannot be...

Objective: Write a java program to print your IP address. Approach: Get the local host address of your system using getLocalHost() method. Use getHostAddress() method to get the IP address from local host address. Code:Run This Code...

Area of a circumference = 2πR Where π = 3.14 and R = radius of circle Example: Radius = 4.0 Area = 2*π*radius = 2*3.14*4 = 25.12 Java Code:Run This Code Output: Area of...