Java Program to Sort Array Elements using Heap Sort

This is the Java Program to Implement Heap Sort on an Array of n Elements. Problem Description Given an array of integers, sort the array using heap sort algorithm. Problem Solution The idea is to create a max heap of the array elements. Then, obtain the maximum element from the heap, interchange it with the … Read more

advertisement

Java Program to Find the Sub-Arrays whose Sum is Equal to a Given Number

This is the Java Program to Find the Sub-Arrays whose Sum is Equal to a Given Number. Problem Description Given an array of integers and a value say m, find out the contiguous subarray the sum of whose elements, is equal to m. Example: Array = [1, 2, 3, 4, 5, -1] m = 8 … Read more

advertisement

Java Program to Sort Names in an Alphabetical Order

This is a Java Program to Sort Names in an Alphabetical Order. Enter size of array and then enter all the names in that array. Now with the help of compareTo operator we can easily sort names in Alphabetical Order. Here is the source code of the Java Program to Sort Names in an Alphabetical … Read more

advertisement

Java Program to Sort an Array in Descending Order

This is a Java Program to Sort the Array in Descending Order. Enter size of array and then enter all the elements of that array. Now with the help of for loop and temp variable we sort the array in descending order. Here is the source code of the Java Program to Sort the Array … Read more

advertisement

Java Program to Sort an Array in Ascending Order

This is a Java Program to Sort the Array in an Ascending Order. Enter size of array and then enter all the elements of that array. Now with the help of for loop and temp variable we sort the array in ascending order. Here is the source code of the Java Program to Sort the … Read more

advertisement

Java Program to Find Majority Element in a Sorted Array

This is a Java Program to Find if a given Integer X appears more than N/2 times in a Sorted Array of N Integers. Enter size of array and then enter all the elements of that array. Now enter the element you want to check. With the help of for loop now we check if … Read more

advertisement

Java Program to Solve Set Cover Problem

This is a java program to solve set cover problem. The set covering problem (SCP) is a classical question in combinatorics, computer science and complexity theory.Given a set of elements \{1,2,…,m\} (called the universe) and a set S of n sets whose union equals the universe, the set cover problem is to identify the smallest … Read more

advertisement

Java Program to Implement String Search Algorithm for Short Text Sizes

This is a java program to search string using simple algorithm BoyerMoore. Here is the source code of the Java Program to Implement the String Search Algorithm for Short Text Sizes. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.  package com.sanfoundry.setandstring; import java.util.Scanner; class BoyerMoore{ private … Read more

advertisement

Java Program to Repeatedly Search the Same Text

This is a java program to repeatedly search a string from the sample string. Here is the source code of the Java Program to Repeatedly Search the Same Text (such as Bible by building a Data Structure). The Java program is successfully compiled and run on a Windows system. The program output is also shown … Read more

advertisement

Java Program to Implement Aho Corasick Algorithm for Pattern Searching

This is a java program to implement Aho-Corasick Algorithm. It is a kind of dictionary-matching algorithm that locates elements of a finite set of strings (the “dictionary”) within an input text. It matches all patterns simultaneously. The complexity of the algorithm is linear in the length of the patterns plus the length of the searched … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.