mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 09:45:04 +08:00
Fix package declarations (#2576)
This commit is contained in:

committed by
GitHub

parent
60a0c23544
commit
2b7a977cc8
@ -2,9 +2,8 @@
|
||||
Time Complexity = O(E), where E is equal to the number of edges
|
||||
*/
|
||||
|
||||
package Graphs;
|
||||
package DataStructures.Graphs;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.*;
|
||||
|
||||
public class A_Star {
|
||||
|
@ -4,9 +4,6 @@ for better understanding
|
||||
*/
|
||||
package DataStructures.Graphs;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
class dijkstras{
|
||||
|
||||
int k=9;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package Graphs;
|
||||
package DataStructures.Graphs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
@ -104,7 +104,6 @@ class TopologicalSort<E extends Comparable<E>>{
|
||||
*/
|
||||
ArrayList<E> topSortOrder(){
|
||||
calculateInDegree();
|
||||
int count = 0;
|
||||
Queue<E> q = new LinkedList<E>();
|
||||
|
||||
for(E vertex: inDegree.keySet()){
|
||||
|
@ -1,3 +1,5 @@
|
||||
package DataStructures.Graphs;
|
||||
|
||||
// Problem -> Connect all the edges with the minimum cost.
|
||||
// Possible Solution -> Kruskal Algorithm (KA), KA finds the minimum-spanning-tree, which means, the
|
||||
// group of edges with the minimum sum of their weights that connect the whole graph.
|
||||
|
@ -1,7 +1,5 @@
|
||||
package DataStructures.Lists;
|
||||
|
||||
import DataStructures.Lists.Node;
|
||||
|
||||
public class RemoveDuplicateNodes {
|
||||
|
||||
public Node deleteDuplicates(Node head) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
package DataStructures.Queues;
|
||||
|
||||
//This program implements the concept of CircularQueue in Java
|
||||
//Link to the concept: (https://en.wikipedia.org/wiki/Circular_buffer)
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
package DataStructures.Trees;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -1,3 +1,5 @@
|
||||
package DataStructures.Trees;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
package Trees;
|
||||
package DataStructures.Trees;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
@ -1,3 +1,5 @@
|
||||
package DivideAndConquer;
|
||||
|
||||
public class BinaryExponentiation {
|
||||
|
||||
public static void main(String args[]) {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package DivideAndConquer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* For a set of points in a coordinates system (10000 maximum), ClosestPair class calculates the two
|
||||
* closest points.
|
||||
|
@ -1,3 +1,5 @@
|
||||
package DivideAndConquer;
|
||||
|
||||
// Java Program to Implement Strassen Algorithm
|
||||
|
||||
// Class Strassen matrix multiplication
|
||||
|
@ -1,3 +1,5 @@
|
||||
package DynamicProgramming;
|
||||
|
||||
// Given N dice each with M faces, numbered from 1 to M, find the number of ways to get sum X.
|
||||
// X is the summation of values on each face when all the dice are thrown.
|
||||
|
||||
@ -14,9 +16,6 @@ Following is implementation of Dynamic Programming approach. */
|
||||
// Code ---->
|
||||
// Java program to find number of ways to get sum 'x' with 'n'
|
||||
// dice where every dice has 'm' faces
|
||||
import java.util.*;
|
||||
import java.lang.*;
|
||||
import java.io.*;
|
||||
|
||||
class DP {
|
||||
/* The main function that returns the number of ways to get sum 'x' with 'n' dice and 'm' with m faces. */
|
||||
|
@ -1,7 +1,4 @@
|
||||
package test;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
package DynamicProgramming;
|
||||
|
||||
/**
|
||||
* Algorithm explanation https://www.educative.io/edpresso/longest-palindromic-subsequence-algorithm
|
||||
|
@ -1,7 +1,4 @@
|
||||
package test;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
package DynamicProgramming;
|
||||
|
||||
/*
|
||||
* Algorithm explanation https://leetcode.com/problems/longest-palindromic-substring/
|
||||
|
@ -15,9 +15,6 @@ Subset1 = {7, 46} ; sum of Subset1 = 53
|
||||
Subset2 = {36, 40} ; sum of Subset2 = 76
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class MinimumSumPartition {
|
||||
public static int subSet(int[] arr) {
|
||||
int n = arr.length;
|
||||
|
@ -1,4 +1,7 @@
|
||||
package DynamicProgramming;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Implements [Palindrome
|
||||
@ -16,9 +19,6 @@ package DynamicProgramming;
|
||||
* "aba | b | bbabb | ababa"
|
||||
* @author [Syed] (https://github.com/roeticvampire)
|
||||
*/
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class PalindromicPartitioning {
|
||||
|
||||
public static int minimalpartitions(String word){
|
||||
@ -31,7 +31,7 @@ public class PalindromicPartitioning {
|
||||
int[] minCuts = new int[len];
|
||||
boolean[][] isPalindrome = new boolean[len][len];
|
||||
|
||||
int i, j, k, L; // different looping variables
|
||||
int i, j, L; // different looping variables
|
||||
|
||||
// Every substring of length 1 is a palindrome
|
||||
for (i = 0; i < len; i++) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
package DynamicProgramming;
|
||||
|
||||
// Java program to find length of the shortest supersequence
|
||||
class ShortestSuperSequence {
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
package DynamicProgramming;
|
||||
|
||||
public class Sum_Of_Subset {
|
||||
public static void main(String[] args){
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
package Maths;
|
||||
|
||||
/**
|
||||
* A number is said to be an Automorphic, if it is present in the last digit(s) of its square.
|
||||
* Example- Let the number be 25, its square is 625.
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.maths;
|
||||
package Maths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.maths;
|
||||
package Maths;
|
||||
|
||||
/**
|
||||
* Class for linear convolution of two discrete signals
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.maths;
|
||||
package Maths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.maths;
|
||||
package Maths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.maths;
|
||||
package Maths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
package Maths;
|
||||
|
||||
/*
|
||||
* Algorithm explanation: https://technotip.com/6774/c-program-to-find-generic-root-of-a-number/#:~:text=Generic%20Root%3A%20of%20a%20number,get%20a%20single%2Ddigit%20output.&text=For%20Example%3A%20If%20user%20input,%2B%204%20%2B%205%20%3D%2015.
|
||||
*/
|
||||
|
@ -1,4 +1,7 @@
|
||||
import java.util.*;
|
||||
package Maths;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class KeithNumber
|
||||
{
|
||||
//user-defined function that checks if the given number is Keith or not
|
||||
|
@ -1,4 +1,4 @@
|
||||
//package Maths;
|
||||
package Maths;
|
||||
|
||||
/* This is a program to check if a number is a Krishnamurthy number or not.
|
||||
A number is a Krishnamurthy number if the sum of the factorials of the digits of the number is equal to the number itself.
|
||||
|
@ -1,4 +1,7 @@
|
||||
package Maths;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/*A magic square of order n is an arrangement of distinct n^2 integers,in a square, such that the n numbers in all
|
||||
rows, all columns, and both diagonals sum to the same constant. A magic square contains the integers from 1 to n^2.*/
|
||||
public class MagicSquare {
|
||||
|
@ -1,3 +1,5 @@
|
||||
package Maths;
|
||||
|
||||
/**
|
||||
* Translates numbers into the Roman Numeral System.
|
||||
*
|
||||
|
@ -1,5 +1,8 @@
|
||||
package Misc;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TwoSumProblem {
|
||||
public static void main(String args[])
|
||||
{
|
||||
|
@ -1,3 +1,5 @@
|
||||
package Misc;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class WordBoggle {
|
||||
|
@ -1,13 +1,7 @@
|
||||
package Others;
|
||||
|
||||
|
||||
// Java Program to implement Auto-Complete
|
||||
// Feature using Trie
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.lang.*;
|
||||
|
||||
class Trieac {
|
||||
|
||||
// Alphabet size (# of symbols)
|
||||
|
@ -1,3 +1,5 @@
|
||||
package Others;
|
||||
|
||||
/** @author Prateek Kumar Oraon (https://github.com/prateekKrOraon) */
|
||||
import java.util.Scanner;
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
package Others.RestrictedTowerOfHanoi.Main;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
|
@ -1,3 +1,5 @@
|
||||
package Others;
|
||||
|
||||
/** @author Prateek Kumar Oraon (https://github.com/prateekKrOraon) */
|
||||
import java.util.Scanner;
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
package Searches;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/*
|
||||
Problem Statement:
|
||||
Given an array, find out how many times it has to been rotated
|
||||
@ -19,10 +23,7 @@
|
||||
1. [1,2,3,4] Number of rotations: 0 or 4(Both valid)
|
||||
2. [15,17,2,3,5] Number of rotations: 3
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class howManyTimesRotated
|
||||
class HowManyTimesRotated
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
@ -42,11 +43,11 @@ class howManyTimesRotated
|
||||
int low = 0;
|
||||
int high = a.length-1;
|
||||
int mid=0; // low + (high-low)/2 = (low + high)/2
|
||||
int i=0;
|
||||
|
||||
while(low<=high)
|
||||
{
|
||||
mid = low + (high-low)/2;
|
||||
i++;
|
||||
|
||||
if(a[mid]<a[mid-1] && a[mid]<a[mid+1])
|
||||
{
|
||||
break;
|
@ -1,7 +1,5 @@
|
||||
package Searches;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class PerfectBinarySearch {
|
||||
|
||||
static int binarySearch(int[] arr, int target) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
package Sorts;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package Strings;
|
||||
import java.util.*;
|
||||
import java.lang.*;
|
||||
import java.io.*;
|
||||
|
||||
public class List_all_Possible_Words_From_Phone_Digits {
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
package Strings;
|
||||
|
||||
// Longest Palindromic Substring
|
||||
import java.util.Scanner;;
|
||||
|
||||
|
||||
class LongestPalindromicSubstring {
|
||||
public static void main(String[] args) {
|
||||
Solution s = new Solution();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package Strings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
|
Reference in New Issue
Block a user