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 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

Problem Description Write a Java Program to Sort the Array in an Ascending Order. Problem Solution Enter the size of the array, and then enter all the elements of that array. Then, the program uses a for loop to sort the array in ascending order by comparing each element of the array with all 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

Java Program to Implement Grep, Egrep and Fgrep Commands

This is a java program to implement grep linux command. Here is the source code of the Java Program to Implement the Program Used in grep/egrep/fgrep. 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.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.Scanner;import java.util.regex.Matcher;import java.util.regex.Pattern; public class GrepCommandImplementation{ … 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 & discussions at Telegram SanfoundryClasses.