MCPcopy Create free account

hub / github.com/TheAlgorithms/Java / functions

Functions8,444 in github.com/TheAlgorithms/Java

↓ 8 callersMethodisPangram
Checks if a String is considered a Pangram @param s The String to check @return {@code true} if s is a Pangram, otherwise {@code false}
src/main/java/com/thealgorithms/strings/Pangram.java:46
↓ 8 callersMethodisSorted
(int[] p, int option)
src/main/java/com/thealgorithms/sorts/LinkListSort.java:10
↓ 8 callersMethodisVampireNumber
(int a, int b, boolean ignorePseudoVampireNumbers)
src/main/java/com/thealgorithms/maths/VampireNumber.java:20
↓ 8 callersMethodknapSack
Solves the 0-1 Knapsack problem using a recursive brute-force approach. @param w the total capacity of the knapsack @param wt an array where wt[i]
src/main/java/com/thealgorithms/dynamicprogramming/BruteForceKnapsack.java:56
↓ 8 callersMethodlps
Returns the longest palindromic subsequence of the given string. @param original the input string @return the longest palindromic subsequence @throws
src/main/java/com/thealgorithms/dynamicprogramming/LongestPalindromicSubsequence.java:22
↓ 8 callersMethodmajority
Returns a list of majority element(s) from the given array of integers. @param nums an array of integers @return a list containing the majority eleme
src/main/java/com/thealgorithms/datastructures/hashmap/hashing/MajorityElement.java:25
↓ 8 callersMethodmaxFlow
Computes the maximum flow from {@code source} to {@code sink} in the provided capacity matrix. @param capacity the capacity matrix representing the d
src/main/java/com/thealgorithms/graph/EdmondsKarp.java:35
↓ 8 callersMethodpop
Removes and returns the element from the top of the stack. Shrinks the stack if its size is below a quarter of its capacity, but not below the default
src/main/java/com/thealgorithms/datastructures/stacks/StackArray.java:66
↓ 8 callersMethodsearch
Test if the value key is present in the list. @param key the value to be searched. @return {@code true} if key is present in the list, otherwise {@co
src/main/java/com/thealgorithms/datastructures/lists/SinglyLinkedList.java:233
↓ 8 callersMethodsetWaitingTime
(int waitingTime)
src/main/java/com/thealgorithms/scheduling/EDFScheduling.java:87
↓ 8 callersMethodsolveRangeSumQueries
Solves range sum queries using Mo's Algorithm @param arr the input array @param queries array of queries to process @return array of results correspo
src/main/java/com/thealgorithms/others/MosAlgorithm.java:50
↓ 8 callersMethodsort
(T[] array)
src/main/java/com/thealgorithms/sorts/DutchNationalFlagSort.java:14
↓ 8 callersMethodupdate
Recursively updates a point in the 2D grid.
src/main/java/com/thealgorithms/datastructures/trees/SegmentTree2D.java:136
↓ 8 callersMethodxor
This method returns a string obtained by XOR-ing two strings of same length passed a method parameters @param String a and b are string objects which
src/main/java/com/thealgorithms/ciphers/Blowfish.java:1121
↓ 7 callersMethodalign
Computes the Needleman–Wunsch global alignment score between two strings. @param s1 the first string @param s2 the second string @param matchScore sc
src/main/java/com/thealgorithms/dynamicprogramming/NeedlemanWunsch.java:27
↓ 7 callersMethodbruteForce
Solves the Traveling Salesman Problem (TSP) using brute-force approach. This method generates all possible permutations of cities, calculates the tota
src/main/java/com/thealgorithms/graph/TravelingSalesman.java:27
↓ 7 callersMethodbuildPrefixSum
Computes the prefix sum array for efficient range queries. @param nums The input integer array. @return Prefix sum array where prefixSum[i+1] = sum o
src/main/java/com/thealgorithms/prefixsum/RangeSumQuery.java:41
↓ 7 callersMethodcalculateEnergy
Calculates the total energy of the pendulum. E = (1/2) m L^2 omega^2 + m g L (1 - cos(theta)) We use m = 1 for simplicity. @param state the current s
src/main/java/com/thealgorithms/physics/SimplePendulumRK4.java:111
↓ 7 callersMethodcalculateProbabilities
Calculates the frequency and probability range for each character in the input string in a deterministic order. @param text The input string. @return
src/main/java/com/thealgorithms/compression/ArithmeticCoding.java:128
↓ 7 callersMethodcalculateTurnAroundTime
Calculates the Turn Around Time (TAT) for each process. <p>Turn Around Time is calculated as the total time a process spends in the system from arriv
src/main/java/com/thealgorithms/scheduling/HighestResponseRatioNextScheduling.java:71
↓ 7 callersMethodcoinChangeProblem
Returns the list of coins used to make the given amount using a greedy algorithm with standard denominations. <p>Time Complexity: O(n log n) where n
src/main/java/com/thealgorithms/greedyalgorithms/CoinChange.java:33
↓ 7 callersMethodcompress
Compresses a string using the LZW algorithm. @param uncompressed The string to be compressed. Can be null. @return A list of integers representing th
src/main/java/com/thealgorithms/compression/LZW.java:57
↓ 7 callersMethodcompute
Solves the 0-1 Knapsack problem using the bottom-up tabulation technique. @param values the values of the items @param weights the weights of the item
src/main/java/com/thealgorithms/dynamicprogramming/KnapsackZeroOneTabulation.java:36
↓ 7 callersMethodconvert
Converts a value from one unit to another. @param inputUnit the unit of the input value. @param outputUnit the unit to convert the value into. @param
src/main/java/com/thealgorithms/conversions/UnitsConverter.java:131
↓ 7 callersMethodcountBitsFlip
Counts the number of bits that need to be flipped to convert a to b Algorithm: 1. XOR a and b to get positions where bits differ 2. Count the number
src/main/java/com/thealgorithms/bitmanipulation/CountBitsFlip.java:38
↓ 7 callersMethodcountBitsFlipAlternative
Alternative implementation using Long.bitCount(). @param a the source number @param b the target number @return the number of bits to flip to convert
src/main/java/com/thealgorithms/bitmanipulation/CountBitsFlip.java:60
↓ 7 callersMethodcountDistinctColors
(int[] colors)
src/test/java/com/thealgorithms/datastructures/graphs/WelshPowellTest.java:131
↓ 7 callersMethodcountSubarrays
Counts the number of subarrays whose sum equals k. @param nums The input integer array. @param k The target sum. @return The number of continuous
src/main/java/com/thealgorithms/prefixsum/SubarraySumEqualsK.java:50
↓ 7 callersMethoddecimalToOctal
Converts a Decimal number to an Octal number. @param decimal The Decimal number as an integer. @return The Octal equivalent as an integer.
src/main/java/com/thealgorithms/conversions/HexToOct.java:38
↓ 7 callersMethoddecrypt
Decrypts the given ciphertext (in hexadecimal format) using the XOR cipher with the specified key. The result is the original plaintext. @param ciphe
src/main/java/com/thealgorithms/ciphers/XORCipher.java:85
↓ 7 callersMethoddecrypt
Decrypts a ciphertext using the private key. @param cipher The CipherText (a, b). @param x The private key. @param p The prime modulus. @re
src/main/java/com/thealgorithms/ciphers/ElGamalCipher.java:142
↓ 7 callersMethoddetectLoop
Detects the presence of a loop in the linked list using Floyd's cycle-finding algorithm, also known as the "tortoise and hare" method. @param head th
src/main/java/com/thealgorithms/datastructures/lists/CreateAndDetectLoop.java:79
↓ 7 callersMethoddisplayBackwards
Prints the contents of the list in reverse order
src/main/java/com/thealgorithms/datastructures/lists/DoublyLinkedList.java:78
↓ 7 callersMethoddivide
(int dividend, int divisor)
src/main/java/com/thealgorithms/maths/LongDivision.java:14
↓ 7 callersMethoddynamicProgramming
Solves the Traveling Salesman Problem (TSP) using dynamic programming with the Held-Karp algorithm. @param distanceMatrix A square matrix where eleme
src/main/java/com/thealgorithms/graph/TravelingSalesman.java:112
↓ 7 callersMethodencrypt
Encrypts the given plaintext using the XOR cipher with the specified key. The result is a hexadecimal-encoded string representing the ciphertext. @pa
src/main/java/com/thealgorithms/ciphers/XORCipher.java:65
↓ 7 callersMethodfind
Jump Search algorithm implementation. @param array the sorted array containing elements (must be sorted in ascending order) @param key the element
src/main/java/com/thealgorithms/searches/JumpSearch.java:68
↓ 7 callersMethodfind
This method performs Saddleback Search @param arr The Sorted array in which we will search the element. @param row the current row. @param col the
src/main/java/com/thealgorithms/searches/SaddlebackSearch.java:32
↓ 7 callersMethodfind
@param array is an array where the LowerBound value is to be found @param key is an element for which the LowerBound is to be found @param <T> is any
src/main/java/com/thealgorithms/searches/LowerBound.java:31
↓ 7 callersMethodfind
@param arr The Sorted array in which we will search the element. @param value The value that we want to search for. @return The index of the element
src/main/java/com/thealgorithms/searches/TernarySearch.java:27
↓ 7 callersMethodfindColoring
Finds the coloring of the given graph using the Welsh-Powell algorithm. @param graph the input graph to color @return an array of integers where each
src/main/java/com/thealgorithms/datastructures/graphs/WelshPowell.java:127
↓ 7 callersMethodfindHamiltonianCycle
Finds a Hamiltonian Cycle for the given graph. @param graph Adjacency matrix representing the graph G(V, E), where V is the set of verti
src/main/java/com/thealgorithms/datastructures/graphs/HamiltonianCycle.java:30
↓ 7 callersMethodfindMinCut
Finds the minimum cut in the given undirected, weighted graph. @param graph An adjacency matrix representing the graph. graph[i][j] is the weight of
src/main/java/com/thealgorithms/graph/StoerWagner.java:19
↓ 7 callersMethodfindWays
(int m, int n, int x)
src/main/java/com/thealgorithms/dynamicprogramming/DiceThrow.java:23
↓ 7 callersMethodgenerateCodes
Generates Shannon-Fano codes for the symbols in a given text. @param text The input string for which to generate codes. Must not be null. @return A m
src/main/java/com/thealgorithms/compression/ShannonFano.java:73
↓ 7 callersMethodgeneratePassword
Generates a random password with a length between minLength and maxLength. @param minLength The minimum length of the password. @param maxLength The
src/main/java/com/thealgorithms/others/PasswordGen.java:32
↓ 7 callersMethodgenerateRandomIntegers
(int n)
src/test/java/com/thealgorithms/searches/QuickSelectTest.java:221
↓ 7 callersMethodgetA
()
src/main/java/com/thealgorithms/ciphers/ECC.java:137
↓ 7 callersMethodgetCeil
(Node root, int key)
src/main/java/com/thealgorithms/datastructures/trees/CeilInBinarySearchTree.java:47
↓ 7 callersMethodgetDimension
()
src/main/java/com/thealgorithms/datastructures/trees/KDTree.java:77
↓ 7 callersMethodgetMap
()
src/test/java/com/thealgorithms/datastructures/hashmap/hashing/MapTest.java:12
↓ 7 callersMethodgetMin
Retrieves the minimum element in the stack. @return The minimum element so far.
src/main/java/com/thealgorithms/stacks/MinStackUsingSingleStack.java:59
↓ 7 callersMethodgetNumberOfKeysInTable
Returns the current number of keys in the hash table. @return the number of keys present in the hash table
src/main/java/com/thealgorithms/datastructures/hashmap/hashing/HashMapCuckooHashing.java:266
↓ 7 callersMethodgetP
()
src/main/java/com/thealgorithms/ciphers/ECC.java:133
↓ 7 callersMethodgetPath
()
src/main/java/com/thealgorithms/datastructures/graphs/AStar.java:87
↓ 7 callersMethodgetPixel
Get the color at the given co-odrinates of a 2D image @param image The image to be filled @param xCoordinate The x coordinate of which color is to be
src/main/java/com/thealgorithms/dynamicprogramming/BoundaryFill.java:18
↓ 7 callersMethodgetSize
Returns the number of elements in the queue @return number of elements in the queue
src/main/java/com/thealgorithms/datastructures/queues/PriorityQueues.java:176
↓ 7 callersMethodgetVisited
()
src/main/java/com/thealgorithms/searches/DepthFirstSearch.java:29
↓ 7 callersMethodhexToDecimal
Converts a Hexadecimal number to a Decimal number. @param hex The Hexadecimal number as a String. @return The Decimal equivalent as an integer.
src/main/java/com/thealgorithms/conversions/HexToOct.java:18
↓ 7 callersMethodinsert
(int key)
src/main/java/com/thealgorithms/datastructures/trees/BTree.java:289
↓ 7 callersMethodintersectionPoint
Computes the single geometric intersection point between two non-parallel segments when it exists. <p>For parallel/collinear overlap, this method ret
src/main/java/com/thealgorithms/geometry/LineIntersection.java:60
↓ 7 callersMethodisColoringValid
(Graph graph, int[] colors)
src/test/java/com/thealgorithms/datastructures/graphs/WelshPowellTest.java:117
↓ 7 callersMethodisEmpty
Returns true if the queue is empty. @return True if the queue is empty.
src/main/java/com/thealgorithms/datastructures/queues/Queue.java:111
↓ 7 callersMethodisLeaf
(BinaryTree.Node node)
src/main/java/com/thealgorithms/datastructures/trees/BoundaryTraversal.java:118
↓ 7 callersMethodisMatch
(String text, String pattern)
src/main/java/com/thealgorithms/dynamicprogramming/WildcardMatching.java:20
↓ 7 callersMethodisPalindrome
(final Iterable linkedList)
src/main/java/com/thealgorithms/datastructures/lists/PalindromeSinglyLinkedList.java:25
↓ 7 callersMethodisPalindromeOptimised
(Node head)
src/main/java/com/thealgorithms/datastructures/lists/PalindromeSinglyLinkedList.java:43
↓ 7 callersMethodisolateLowestSetBit
Isolates the lowest set bit of the given number. For example, if n = 18 (binary: 10010), the result will be 2 (binary: 00010). @param n the number wh
src/main/java/com/thealgorithms/bitmanipulation/LowestSetBit.java:19
↓ 7 callersMethodlengthOfLastWord
Returns the length of the last word in the specified string. <p>The method iterates from the end of the string, skipping trailing spaces first, and t
src/main/java/com/thealgorithms/strings/LengthOfLastWord.java:34
↓ 7 callersMethodlinkedListToString
(SinglyLinkedListNode head)
src/test/java/com/thealgorithms/datastructures/lists/RotateSinglyLinkedListsTest.java:32
↓ 7 callersMethodmatchWordPattern
Determines if the given pattern matches the input string using backtracking. @param pattern The pattern to match. @param inputString The string to ma
src/main/java/com/thealgorithms/backtracking/WordPatternMatcher.java:33
↓ 7 callersMethodmerge
Merges overlapping intervals from the given array of intervals. The method sorts the intervals by their start time, then iterates through the sorted
src/main/java/com/thealgorithms/greedyalgorithms/MergeIntervals.java:41
↓ 7 callersMethodmerge
Merges two sorted singly linked lists into a single sorted singly linked list. <p>This method does not modify the input lists; instead, it creates a
src/main/java/com/thealgorithms/datastructures/lists/MergeSortedSinglyLinkedList.java:40
↓ 7 callersMethodminimumPathSum
(final int[][] grid)
src/main/java/com/thealgorithms/dynamicprogramming/MinimumPathSum.java:32
↓ 7 callersMethodrandom
Sets the {@link Random} instance to be used for random eviction selection. @param r a non-null {@code Random} instance @return this builder instance
src/main/java/com/thealgorithms/datastructures/caches/RRCache.java:458
↓ 7 callersMethodremoveByIndex
Removes the element at a specified logical index from the list. @param index the logical index of the element to remove
src/main/java/com/thealgorithms/datastructures/lists/CursorLinkedList.java:121
↓ 7 callersMethodremoveDuplicate
Removes duplicate characters from the given string. @param input The input string from which duplicate characters need to be removed. @return A strin
src/main/java/com/thealgorithms/strings/RemoveDuplicateFromString.java:16
↓ 7 callersMethodsearch
(final String text, final String[] patterns)
src/main/java/com/thealgorithms/strings/AhoCorasick.java:230
↓ 7 callersMethodsetNextEntry
(Entry<I, J> nextEntry)
src/main/java/com/thealgorithms/datastructures/caches/MRUCache.java:210
↓ 7 callersMethodshift
Recursively solve the Tower of Hanoi puzzle by moving discs between poles. @param n The number of discs to move. @param startPole
src/main/java/com/thealgorithms/puzzlesandgames/TowerOfHanoi.java:59
↓ 7 callersMethodsize
Returns the current number of elements in the queue. @return the number of elements currently in the queue
src/main/java/com/thealgorithms/datastructures/queues/CircularQueue.java:135
↓ 7 callersMethodsize
Gets the number of key-value pairs in the hash map. @return the number of key-value pairs in the hash map
src/main/java/com/thealgorithms/datastructures/hashmap/hashing/HashMap.java:103
↓ 7 callersMethodsort
Sorts the given array in ascending order using a PriorityQueue. @param arr the array to be sorted @return the sorted array (in-place)
src/main/java/com/thealgorithms/sorts/PriorityQueueSort.java:32
↓ 7 callersMethodsort
(T[] unsorted)
src/main/java/com/thealgorithms/sorts/WiggleSort.java:20
↓ 7 callersMethodsquareRoot
This function calculates the floor of square root of a number. We use Binary Search algorithm to calculate the square root in a more optimised way. @
src/main/java/com/thealgorithms/searches/SquareRootBinarySearch.java:27
↓ 7 callersMethodtransform
Performs the forward Move-to-Front transform. <p> Converts the input string into a list of integers, where each integer represents the position of the
src/main/java/com/thealgorithms/compression/MoveToFront.java:91
↓ 7 callersMethodupdateSize
updateSize -> updates the subtree size of the current node
src/main/java/com/thealgorithms/datastructures/trees/Treap.java:48
↓ 6 callersMethodaddRoundKey
@return ciphertext XOR key
src/main/java/com/thealgorithms/ciphers/AES.java:2529
↓ 6 callersMethodaddSegment
(Segment s)
src/main/java/com/thealgorithms/geometry/BentleyOttmann.java:96
↓ 6 callersMethodadj
(int nLeft)
src/test/java/com/thealgorithms/graph/HopcroftKarpTest.java:19
↓ 6 callersMethodadjacency
Getter for the adjacency matrix @return the adjacency matrix
src/main/java/com/thealgorithms/datastructures/graphs/MatrixGraphs.java:135
↓ 6 callersMethodalign
Computes the Smith–Waterman local alignment score between two strings. @param s1 first string @param s2 second string @param matchScore score for a m
src/main/java/com/thealgorithms/dynamicprogramming/SmithWaterman.java:26
↓ 6 callersMethodbcdToDecimal
Converts a BCD (Binary-Coded Decimal) number to a decimal number. <p>Steps: <p>1. Validate the BCD number to ensure all digits are between 0 and 9. <p
src/main/java/com/thealgorithms/bitmanipulation/BcdConversion.java:37
↓ 6 callersMethodbinSearchAlgo
(int[] arr, int start, int end, int target)
src/main/java/com/thealgorithms/searches/OrderAgnosticBinarySearch.java:18
↓ 6 callersMethodboundaryTraversal
(BinaryTree.Node root)
src/main/java/com/thealgorithms/datastructures/trees/BoundaryTraversal.java:30
↓ 6 callersMethodcalculateCircularOrbitVelocity
Calculates the speed required for a stable circular orbit. @param centralMass The mass of the central body (kg). @param radius The radius of the orbi
src/main/java/com/thealgorithms/physics/Gravitation.java:60
↓ 6 callersMethodcalculateCircularOrbitVelocity
Calculates the speed required for a stable circular orbit of a charged particle around a central charge (e.g., an electron orbiting a nucleus). @para
src/main/java/com/thealgorithms/physics/CoulombsLaw.java:69
↓ 6 callersMethodcheck
(BinaryTree.Node p, BinaryTree.Node q)
src/main/java/com/thealgorithms/datastructures/trees/SameTreesCheck.java:38
↓ 6 callersMethodcohenSutherlandClip
(Line line)
src/main/java/com/thealgorithms/lineclipping/CohenSutherland.java:68
↓ 6 callersMethodcombinationsOptimized
The above method can exceed limit of long (overflow) when factorial(n) is larger than limits of long variable. Thus even if nCk is within range of lon
src/main/java/com/thealgorithms/maths/Combinations.java:47
← previousnext →501–600 of 8,444, ranked by callers