# Category Archives: Core Java

This Category contains all the posts related to Core Java

## Classification of Sorting Algorithms

In this post, we will talk about different Classification of Sorting Algorithms. Classification of Sorting Algorithms: By Number of Comparisons In this method, Sorting algorithms are usually classified based on the number of comparisons. For comparison-based sorting algorithms best-case behavior is O(n log n) and worst-case behavior is O(n2). Comparison-based sorting algorithms evaluate the elements of… Read More »

## What is Sorting and why is Sorting Necessary?

In this post, We will try to understand What is Sorting and why is Sorting Necessary? What is Sorting? Sorting is an algorithm that arranges the elements of a collection in a certain order( either ascending or descending).  The output is a reordering of the input. Why is Sorting Necessary? Sorting is one of the important categories… Read More »

## What is Searching ?Why do we need Searching? Explain different Types of Searching ?

In this post, We will learn What is searching and what are the different types of searching algorithms we have in the data structure. What is Searching? In computer science, searching is the process of finding an item with the specified properties from a collection of items. The items may be stored as records in… Read More »

## Interpolation Search Program in Java

In this post, we will learn How to Implement the Interpolation search program in Java. Interpolation search is an algorithm which tries to improve the Binary search, I mean to say that it also follows the divide and conquer algorithm like binary search but how it differs is that rather than dividing the input array… Read More »

## Important Types of Graph Data Structure

In this post, We will discuss some important Types of Graph Data Structures 1.Directed Graph All the edges have directed Example: Route Network 2.Undirected Graph All the edges have undirected Example: Flight network 3.Weighted Graph In Weighted graphs, integers (weights) are assigned to each edge to represent (distance or cost)   You May Also Like:… Read More »

## How do you convert a binary tree to a binary search tree in Java?

In this post, We will learn How do you convert a binary tree to a binary search tree in Java? First of all, Let’s try to understand the difference between binary and binary search trees? Binary Tree  A tree is called a binary tree if each note has zero children, one child, or two children, an empty… Read More »

## Java Program to check if a given binary tree is BST or not?

In this post, We will talk and learn How to write a Java Program to check if a given binary tree is BST(Binary Search Tree) or not?  Binary Search Tree (BST) Data Structure Binary Search Tree or BST is a node-based binary tree data structure which are having the following properties: The left subtree of a… Read More »

## Write a Java program to find given two trees are mirror Image or not ?

In this post, We will Write a Java program to find given two trees are mirror image or not? This Problem is the extension of  Find a mirror image of a binary tree A mirror image of a binary tree is another binary tree with left and right children of all non-leaf nodes of the given… Read More »

## Find the sum of all elements in Binary Tree

In this post, We will learn How to write a Java program to find the sum of all elements in Binary Tree? For Example, the Sum of all elements in Binary Tree of below Image : 1+2+3+4+5+6+7 = 28 Recursive Approach: We call recursively, left subtree sum, right subtree sum, and add their values to the current… Read More »

## Write a Java program to find the height or depth of a binary tree?

In this post, We will learn How to write a Java program to find the height or depth of a binary tree?  Logic is Very Simple: The depth or height of a binary tree is the length of the longest path from the root to a leaf.  The depth of a binary tree with no… Read More »