Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/TheAlgorithms/Java
/ functions
Functions
8,444 in github.com/TheAlgorithms/Java
⨍
Functions
8,444
◇
Types & classes
1,826
↓ 17 callers
Method
peekRear
Checks the element at the rear of the queue without removing it. @return Element at the rear of the queue. @throws IllegalStateException if the queue
src/main/java/com/thealgorithms/datastructures/queues/Queue.java:98
↓ 17 callers
Method
push
Pushes a new element onto the {@code stack}. If the value is less than or equal to the current minimum, it is also pushed onto the {@code minStack}.
src/main/java/com/thealgorithms/stacks/MinStackUsingTwoStacks.java:23
↓ 17 callers
Method
union
Unites the sets containing elements x and y. Uses union by rank to attach the smaller tree under the larger tree. @param x the first element @param y
src/main/java/com/thealgorithms/searches/UnionFind.java:65
↓ 16 callers
Method
add
Inserts an element at the back of the queue. @param element The element to be added to the queue. @return {@code true} if the element was successfull
src/main/java/com/thealgorithms/datastructures/queues/GenericArrayListQueue.java:48
↓ 16 callers
Method
addEdge
Adds a new Edge to the graph. If the nodes aren't yet in nodeList, they will be added to it. @param startNode the starting Node from the edge @param
src/main/java/com/thealgorithms/datastructures/graphs/ConnectedComponent.java:49
↓ 16 callers
Method
buildFromEdges
Creates a centroid tree from an edge list. @param n number of nodes (0-indexed: 0 to n-1) @param edges list of edges where each edge is [u, v] @retur
src/main/java/com/thealgorithms/datastructures/trees/CentroidDecomposition.java:184
↓ 16 callers
Method
buildHuffmanTree
Builds a Huffman tree from the given character array and their frequencies. @param charArray array of characters @param charFreq array of frequencie
src/main/java/com/thealgorithms/others/Huffman.java:80
↓ 16 callers
Method
ceil
Returns the smallest double value that is greater than or equal to the input. Equivalent to mathematical ⌈x⌉ (ceiling function). @param number the nu
src/main/java/com/thealgorithms/maths/Ceil.java:18
↓ 16 callers
Method
close
()
src/main/java/com/thealgorithms/io/BufferedReader.java:188
↓ 16 callers
Method
countGraphs
Main method used for counting the connected components. Iterates through the array of nodes to do a depth first search to get all nodes of the graph f
src/main/java/com/thealgorithms/datastructures/graphs/ConnectedComponent.java:79
↓ 16 callers
Method
countUniformIntegers
This function will calculate the number of uniform numbers between a and b @param a lower bound of range @param b upper bound of range @return the co
src/main/java/com/thealgorithms/maths/UniformNumbers.java:41
↓ 16 callers
Method
enqueue
@brief Adds an element to the tail of the queue, blocking if full @param item the element to add @throws InterruptedException if the thread is interru
src/main/java/com/thealgorithms/datastructures/queues/ThreadSafeQueue.java:50
↓ 16 callers
Method
equals
(Object o)
src/main/java/com/thealgorithms/searches/BM25InvertedIndex.java:79
↓ 16 callers
Method
findBridges
Finds all bridge edges in an undirected graph. <p>The graph is represented as an adjacency list where each vertex is identified by an integer in the
src/main/java/com/thealgorithms/graph/TarjanBridges.java:52
↓ 16 callers
Method
getScores
Returns a copy of the scores array. @return A copy of the scores array.
src/main/java/com/thealgorithms/others/MiniMaxAlgorithm.java:193
↓ 16 callers
Method
hash
(Key key, int size)
src/main/java/com/thealgorithms/datastructures/hashmap/hashing/Map.java:19
↓ 16 callers
Method
increment
Increments the counter for the current node.
src/main/java/com/thealgorithms/datastructures/crdt/GCounter.java:42
↓ 16 callers
Method
insertElement
Inserts an element at the specified position in the array. <p> Creates a new array with size = original array size + 1. Elements at positions <= in
src/main/java/com/thealgorithms/others/InsertDeleteInArray.java:55
↓ 16 callers
Method
kthSmallest
If you sort the subarray from index left to right, what would be the k-th smallest element? This query is also commonly known as the quantile query.
src/main/java/com/thealgorithms/datastructures/trees/WaveletTree.java:209
↓ 16 callers
Method
leonardoNumberIterative
Calculates the nth Leonardo Number using an iterative approach. <p> This method provides better performance than the recursive version for large value
src/main/java/com/thealgorithms/maths/LeonardoNumber.java:60
↓ 16 callers
Method
sortStack
Sorts the given stack in ascending order using recursion. The sorting is performed such that the largest element ends up on top of the stack. This met
src/main/java/com/thealgorithms/stacks/SortStack.java:28
↓ 16 callers
Method
toRadians
()
src/main/java/com/thealgorithms/maths/MathBuilder.java:387
↓ 15 callers
Method
add
Vector addition @param vector The vector to be added. @return The sum-vector.
src/main/java/com/thealgorithms/others/KochSnowflake.java:201
↓ 15 callers
Method
add
Adds an element to the end of the array. If the array is full, it creates a new array with double the size to accommodate the new element. @param ele
src/main/java/com/thealgorithms/datastructures/dynamicarray/DynamicArray.java:55
↓ 15 callers
Method
append
(E value)
src/main/java/com/thealgorithms/datastructures/lists/TortoiseHareAlgo.java:20
↓ 15 callers
Method
breadthFirstOrder
This method returns a list of the vertices in a breadth first order beginning with the specified vertex @param startVertex the vertext to begin the t
src/main/java/com/thealgorithms/datastructures/graphs/MatrixGraphs.java:278
↓ 15 callers
Method
checkParity
This method checks the parity of the given number. @param n the number to check the parity of @return true if the number has even parity, false other
src/main/java/com/thealgorithms/bitmanipulation/ParityCheck.java:26
↓ 15 callers
Method
convert
(BigDecimal number)
src/main/java/com/thealgorithms/conversions/NumberToWords.java:27
↓ 15 callers
Method
deleteElement
Deletes an element at the specified position from the array. <p> Creates a new array with size = original array size - 1. Elements after the deletion
src/main/java/com/thealgorithms/others/InsertDeleteInArray.java:91
↓ 15 callers
Method
depthFirstOrder
This method returns a list of the vertices in a depth first order beginning with the specified vertex @param startVertex the vertex to begin the trav
src/main/java/com/thealgorithms/datastructures/graphs/MatrixGraphs.java:223
↓ 15 callers
Method
editDistance
(String s1, String s2)
src/main/java/com/thealgorithms/dynamicprogramming/EditDistance.java:71
↓ 15 callers
Method
fibonacci
Calculates the nth term in the Fibonacci sequence using recursion. @param n the position in the Fibonacci sequence (must be non-negative) @return the
src/main/java/com/thealgorithms/recursion/FibonacciSeries.java:34
↓ 15 callers
Method
find
Generic method to perform binary search on any comparable type. This is the main entry point for binary search operations. <p>Example Usage: <pre> In
src/main/java/com/thealgorithms/searches/BinarySearch.java:59
↓ 15 callers
Method
findAnySolution
Finds any integer solution to the linear Diophantine equation ax + by = c. <p> The method returns one of three types of solutions: <ul> <li>A specific
src/main/java/com/thealgorithms/maths/LinearDiophantineEquationsSolver.java:55
↓ 15 callers
Method
g
This method returns a polynomial in x computed modulo n @param base Integer base of the polynomial @param modulus Integer is value which is to be use
src/main/java/com/thealgorithms/maths/PollardRho.java:50
↓ 15 callers
Method
getValue
(String word)
src/main/java/com/thealgorithms/conversions/WordsToNumber.java:62
↓ 15 callers
Method
hasNext
@return True if there is a next node, otherwise false.
src/main/java/com/thealgorithms/devutils/nodes/SimpleNode.java:48
↓ 15 callers
Method
integerToRoman
Converts an integer to its Roman numeral representation. Steps: <ol> <li>Iterate over the Roman numeral values in descending order</li> <li>Ca
src/main/java/com/thealgorithms/conversions/IntegerToRoman.java:54
↓ 15 callers
Method
isBST
(BinaryTree.Node root)
src/main/java/com/thealgorithms/datastructures/trees/CheckBinaryTreeIsValidBST.java:14
↓ 15 callers
Method
isPowerOfFour
Checks if the given integer is a power of four. A number is considered a power of four if: 1. It is greater than zero 2. It has exactly one '1' bit i
src/main/java/com/thealgorithms/maths/PowerOfFour.java:28
↓ 15 callers
Method
leonardoNumber
Calculates the nth Leonardo Number using recursion. <p> Time Complexity: O(2^n) - exponential due to repeated calculations Space Complexity: O(n) - du
src/main/java/com/thealgorithms/maths/LeonardoNumber.java:37
↓ 15 callers
Method
maxSum
Computes the maximum subarray sum using Kadane's Algorithm and checks if it matches a predicted answer. @param a The input array of inte
src/main/java/com/thealgorithms/dynamicprogramming/KadaneAlgorithm.java:38
↓ 15 callers
Method
multiply
Multiplies this complex number by another. @param z The number to be multiplied. @return The product.
src/main/java/com/thealgorithms/maths/FFT.java:100
↓ 15 callers
Method
onesComplement
Returns the 1's complement of a binary string. @param binary A string representing a binary number (e.g., "1010"). @return A string representing the
src/main/java/com/thealgorithms/bitmanipulation/OnesComplement.java:22
↓ 15 callers
Method
select
What is the 0-based index of the k-th occurrence of the number x in the array? @param x the number to search for @param k the occurrence count (1-bas
src/main/java/com/thealgorithms/datastructures/trees/WaveletTree.java:144
↓ 15 callers
Method
size
Returns the size of the deque @return the size of the deque
src/main/java/com/thealgorithms/datastructures/queues/Deque.java:140
↓ 14 callers
Method
add
(int[][] a, int[][] b)
src/main/java/com/thealgorithms/divideandconquer/StrassenMatrixMultiplication.java:111
↓ 14 callers
Method
add
A method to insert a new value in BST. If the given value is already present in BST the insertion is ignored. @param data the value to be inserted
src/main/java/com/thealgorithms/datastructures/trees/BSTIterative.java:43
↓ 14 callers
Method
addProcess
Adds a new process to the highest priority queue (queue 0). @param p The process to be added to the scheduler
src/main/java/com/thealgorithms/scheduling/MLFQScheduler.java:39
↓ 14 callers
Method
binPow
Calculate a^p using binary exponentiation [Binary-Exponentiation](https://cp-algorithms.com/algebra/binary-exp.html) @param a the base for exponentia
src/main/java/com/thealgorithms/maths/BinaryPow.java:15
↓ 14 callers
Method
binarySearch
Performs a binary search on a 2D sorted array to find the target value. The array must be sorted in ascending order in both rows and columns. @param
src/main/java/com/thealgorithms/searches/BinarySearch2dArray.java:31
↓ 14 callers
Method
buildGraph
Helper to build a symmetric adjacency list for an undirected graph.
src/test/java/com/thealgorithms/graph/TarjanBridgesTest.java:24
↓ 14 callers
Method
compareTo
(Point other)
src/main/java/com/thealgorithms/geometry/Point.java:7
↓ 14 callers
Method
convertBase
Converts a number from a source base to a destination base. @param sourceNumber The number in the source base (as an integer). @param sourceBase The
src/main/java/com/thealgorithms/conversions/AnytoAny.java:22
↓ 14 callers
Method
getChild
()
src/main/java/com/thealgorithms/strings/AhoCorasick.java:39
↓ 14 callers
Method
getParent
()
src/main/java/com/thealgorithms/devutils/nodes/TreeNode.java:66
↓ 14 callers
Method
isProbablePrime
Performs the Euler primality test for a given number. @param n number to test (must be > 2 and odd) @param trials number of random bases to test
src/main/java/com/thealgorithms/maths/EulerPseudoprime.java:34
↓ 14 callers
Method
knapSack
Solves the 0/1 Knapsack problem using Dynamic Programming (bottom-up approach). @param weightCapacity The maximum weight capacity of the knapsack. @p
src/main/java/com/thealgorithms/dynamicprogramming/Knapsack.java:52
↓ 14 callers
Method
log
()
src/main/java/com/thealgorithms/maths/MathBuilder.java:306
↓ 14 callers
Method
modPow
@param a basis @param b exponent @param c modulo @return (a^b) mod c
src/main/java/com/thealgorithms/maths/Prime/PrimeCheck.java:77
↓ 14 callers
Method
offer
Inserts the specified element (O(log n)). @throws NullPointerException if {@code e} is null @throws ClassCastException if {@code cmp == null} and {@co
src/main/java/com/thealgorithms/datastructures/heaps/IndexedPriorityQueue.java:109
↓ 14 callers
Method
peek
Checks what's at the front of the queue @return element at the front of the queue
src/main/java/com/thealgorithms/datastructures/queues/PriorityQueues.java:149
↓ 14 callers
Method
pointsEqual
(Point2D.Double p1, Point2D.Double p2)
src/main/java/com/thealgorithms/geometry/BentleyOttmann.java:420
↓ 14 callers
Method
polarOrder
()
src/main/java/com/thealgorithms/geometry/Point.java:18
↓ 14 callers
Method
power
(double base, int exponent)
src/main/java/com/thealgorithms/maths/PowerUsingRecursion.java:12
↓ 14 callers
Method
search
(String text, String pattern)
src/main/java/com/thealgorithms/strings/RabinKarp.java:18
↓ 14 callers
Method
subtract
Subtract two points on the elliptic curve.
src/main/java/com/thealgorithms/ciphers/ECC.java:213
↓ 14 callers
Method
sumRange
Returns the sum of elements from index left to right (inclusive) using the provided prefix sum array. @param prefixSum The prefix sum array computed
src/main/java/com/thealgorithms/prefixsum/RangeSumQuery.java:64
↓ 14 callers
Method
toString
()
src/main/java/com/thealgorithms/datastructures/lists/SinglyLinkedList.java:242
↓ 14 callers
Method
unionSets
Merges the sets containing the two given nodes using union by size. The root of the smaller set is attached to the root of the larger set. @param x a
src/main/java/com/thealgorithms/datastructures/disjointsetunion/DisjointSetUnionBySize.java:63
↓ 13 callers
Method
addElement
Adds an element to the G-Set. @param e the element to be added
src/main/java/com/thealgorithms/datastructures/crdt/GSet.java:32
↓ 13 callers
Method
countFriendsPairing
(int n, int[] a)
src/main/java/com/thealgorithms/dynamicprogramming/CountFriendsPairing.java:16
↓ 13 callers
Method
dequeue
@brief Removes and returns the element at the head of the queue, blocking if empty @return the element at the head of the queue @throws InterruptedExc
src/main/java/com/thealgorithms/datastructures/queues/ThreadSafeQueue.java:74
↓ 13 callers
Method
divide
Divides this complex number by another. @param z The divisor. @return The quotient.
src/main/java/com/thealgorithms/maths/FFT.java:147
↓ 13 callers
Method
equals
(Object o)
src/test/java/com/thealgorithms/sorts/SlowSortTest.java:130
↓ 13 callers
Method
evictionListener
Sets an eviction listener to be notified when entries are evicted from the cache. @param listener a {@link BiConsumer} that accepts evicted keys and
src/main/java/com/thealgorithms/datastructures/caches/RRCache.java:473
↓ 13 callers
Method
generatePerlinNoise
Generate a 2D array of blended noise values normalized to [0, 1]. @param width width of the noise array (columns) @param height height of
src/main/java/com/thealgorithms/others/PerlinNoise.java:53
↓ 13 callers
Method
getDiceCombinations
Returns all possible dice roll combinations that sum to the target @param target the target sum to achieve with dice rolls @return list of all possib
src/main/java/com/thealgorithms/recursion/DiceThrower.java:33
↓ 13 callers
Method
getKey
()
src/main/java/com/thealgorithms/datastructures/caches/MRUCache.java:214
↓ 13 callers
Method
getMin
Retrieves the minimum element in the stack. @return The minimum element.
src/main/java/com/thealgorithms/stacks/MinStackUsingTwoStacks.java:54
↓ 13 callers
Method
getWrongMess
Returns the counter wrongMess @return wrongMess, the number of Wrong Messages
src/main/java/com/thealgorithms/others/CRCAlgorithm.java:63
↓ 13 callers
Method
orientation
(Point a, Point b, Point c)
src/main/java/com/thealgorithms/geometry/Point.java:22
↓ 13 callers
Method
peekFirst
Returns the first (head) value of the deque WITHOUT removing @return the value of the head of the deque, or null if empty
src/main/java/com/thealgorithms/datastructures/queues/Deque.java:122
↓ 13 callers
Method
poll
Retrieves and removes the element at the front of the queue. @return The element removed from the front of the queue, or {@code null} if the queue is
src/main/java/com/thealgorithms/datastructures/queues/GenericArrayListQueue.java:57
↓ 13 callers
Method
poll
Removes and returns the minimum element (O(log n)), or {@code null} if empty.
src/main/java/com/thealgorithms/datastructures/heaps/IndexedPriorityQueue.java:123
↓ 13 callers
Method
print
Prints the elements of a list to standard output. @param listToPrint the list to print
src/main/java/com/thealgorithms/sorts/SortUtils.java:65
↓ 13 callers
Method
push
Pushes an item onto the stack. @param item the item to be pushed onto the stack
src/main/java/com/thealgorithms/datastructures/stacks/NodeStack.java:45
↓ 13 callers
Method
put
Associates the specified value with the specified key in the cache. If the key already exists, its value is updated and the entry is moved to the most
src/main/java/com/thealgorithms/datastructures/caches/MRUCache.java:112
↓ 13 callers
Method
remove
Dequeue the element with the max priority from PQ @return The element removed
src/main/java/com/thealgorithms/datastructures/queues/PriorityQueues.java:126
↓ 13 callers
Method
romanToInt
Converts a Roman numeral string to its integer equivalent. Steps: <ol> <li>Iterate over the string from right to left.</li> <li>For each chara
src/main/java/com/thealgorithms/conversions/RomanToInteger.java:71
↓ 13 callers
Method
round
()
src/main/java/com/thealgorithms/maths/MathBuilder.java:261
↓ 13 callers
Method
sumRegion
Calculates the sum of the sub-matrix defined by (row1, col1) to (row2, col2). Indices are 0-based. @param row1 Top row index. @param col1 Left column
src/main/java/com/thealgorithms/prefixsum/PrefixSum2D.java:54
↓ 12 callers
Method
add
Adds an item to the heap, maintaining the heap property. @param item the item to be added
src/main/java/com/thealgorithms/datastructures/heaps/GenericHeap.java:21
↓ 12 callers
Method
addUndirectedEdge
(List<Set<Integer>> graph, int u, int v)
src/test/java/com/thealgorithms/graph/BronKerboschTest.java:75
↓ 12 callers
Method
arithmetic
Computes the arithmetic mean (average) of the given numbers. <p> The arithmetic mean is calculated as: (x₁ + x₂ + ... + xₙ) / n </p> <p> Example: For
src/main/java/com/thealgorithms/maths/Means.java:49
↓ 12 callers
Method
compare
(Point p1, Point p2)
src/main/java/com/thealgorithms/geometry/Point.java:27
↓ 12 callers
Method
compute
Calculates the n-th Bell number using the Bell Triangle. @param n the index of the Bell number (must be non-negative) @return the n-th Bell number @t
src/main/java/com/thealgorithms/maths/BellNumbers.java:29
↓ 12 callers
Method
convertOctalToBinary
Converts an octal number to its binary representation. <p>Each octal digit is individually converted to its 3-bit binary equivalent, and the binary d
src/main/java/com/thealgorithms/conversions/OctalToBinary.java:38
↓ 12 callers
Method
createSampleList
Initialize a list with natural order values with pre-defined length @param length @return linked list with pre-defined number of nodes
src/test/java/com/thealgorithms/datastructures/lists/SinglyLinkedListTest.java:20
↓ 12 callers
Method
encode
Encodes the given byte array to a Base64 encoded string. @param input the byte array to encode @return the Base64 encoded string @throws IllegalArgum
src/main/java/com/thealgorithms/conversions/Base64.java:37
← previous
next →
201–300 of 8,444, ranked by callers