MCPcopy Create free account

hub / github.com/TheAlgorithms/Java / functions

Functions8,444 in github.com/TheAlgorithms/Java

↓ 17 callersMethodpeekRear
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 callersMethodpush
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 callersMethodunion
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 callersMethodadd
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 callersMethodaddEdge
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 callersMethodbuildFromEdges
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 callersMethodbuildHuffmanTree
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 callersMethodceil
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 callersMethodclose
()
src/main/java/com/thealgorithms/io/BufferedReader.java:188
↓ 16 callersMethodcountGraphs
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 callersMethodcountUniformIntegers
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 callersMethodenqueue
@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 callersMethodequals
(Object o)
src/main/java/com/thealgorithms/searches/BM25InvertedIndex.java:79
↓ 16 callersMethodfindBridges
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 callersMethodgetScores
Returns a copy of the scores array. @return A copy of the scores array.
src/main/java/com/thealgorithms/others/MiniMaxAlgorithm.java:193
↓ 16 callersMethodhash
(Key key, int size)
src/main/java/com/thealgorithms/datastructures/hashmap/hashing/Map.java:19
↓ 16 callersMethodincrement
Increments the counter for the current node.
src/main/java/com/thealgorithms/datastructures/crdt/GCounter.java:42
↓ 16 callersMethodinsertElement
Inserts an element at the specified position in the array. <p> Creates a new array with size = original array size + 1. Elements at positions &lt;= in
src/main/java/com/thealgorithms/others/InsertDeleteInArray.java:55
↓ 16 callersMethodkthSmallest
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 callersMethodleonardoNumberIterative
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 callersMethodsortStack
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 callersMethodtoRadians
()
src/main/java/com/thealgorithms/maths/MathBuilder.java:387
↓ 15 callersMethodadd
Vector addition @param vector The vector to be added. @return The sum-vector.
src/main/java/com/thealgorithms/others/KochSnowflake.java:201
↓ 15 callersMethodadd
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 callersMethodappend
(E value)
src/main/java/com/thealgorithms/datastructures/lists/TortoiseHareAlgo.java:20
↓ 15 callersMethodbreadthFirstOrder
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 callersMethodcheckParity
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 callersMethodconvert
(BigDecimal number)
src/main/java/com/thealgorithms/conversions/NumberToWords.java:27
↓ 15 callersMethoddeleteElement
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 callersMethoddepthFirstOrder
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 callersMethodeditDistance
(String s1, String s2)
src/main/java/com/thealgorithms/dynamicprogramming/EditDistance.java:71
↓ 15 callersMethodfibonacci
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 callersMethodfind
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 callersMethodfindAnySolution
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 callersMethodg
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 callersMethodgetValue
(String word)
src/main/java/com/thealgorithms/conversions/WordsToNumber.java:62
↓ 15 callersMethodhasNext
@return True if there is a next node, otherwise false.
src/main/java/com/thealgorithms/devutils/nodes/SimpleNode.java:48
↓ 15 callersMethodintegerToRoman
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 callersMethodisBST
(BinaryTree.Node root)
src/main/java/com/thealgorithms/datastructures/trees/CheckBinaryTreeIsValidBST.java:14
↓ 15 callersMethodisPowerOfFour
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 callersMethodleonardoNumber
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 callersMethodmaxSum
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 callersMethodmultiply
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 callersMethodonesComplement
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 callersMethodselect
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 callersMethodsize
Returns the size of the deque @return the size of the deque
src/main/java/com/thealgorithms/datastructures/queues/Deque.java:140
↓ 14 callersMethodadd
(int[][] a, int[][] b)
src/main/java/com/thealgorithms/divideandconquer/StrassenMatrixMultiplication.java:111
↓ 14 callersMethodadd
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 callersMethodaddProcess
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 callersMethodbinPow
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 callersMethodbinarySearch
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 callersMethodbuildGraph
Helper to build a symmetric adjacency list for an undirected graph.
src/test/java/com/thealgorithms/graph/TarjanBridgesTest.java:24
↓ 14 callersMethodcompareTo
(Point other)
src/main/java/com/thealgorithms/geometry/Point.java:7
↓ 14 callersMethodconvertBase
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 callersMethodgetChild
()
src/main/java/com/thealgorithms/strings/AhoCorasick.java:39
↓ 14 callersMethodgetParent
()
src/main/java/com/thealgorithms/devutils/nodes/TreeNode.java:66
↓ 14 callersMethodisProbablePrime
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 callersMethodknapSack
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 callersMethodlog
()
src/main/java/com/thealgorithms/maths/MathBuilder.java:306
↓ 14 callersMethodmodPow
@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 callersMethodoffer
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 callersMethodpeek
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 callersMethodpointsEqual
(Point2D.Double p1, Point2D.Double p2)
src/main/java/com/thealgorithms/geometry/BentleyOttmann.java:420
↓ 14 callersMethodpolarOrder
()
src/main/java/com/thealgorithms/geometry/Point.java:18
↓ 14 callersMethodpower
(double base, int exponent)
src/main/java/com/thealgorithms/maths/PowerUsingRecursion.java:12
↓ 14 callersMethodsearch
(String text, String pattern)
src/main/java/com/thealgorithms/strings/RabinKarp.java:18
↓ 14 callersMethodsubtract
Subtract two points on the elliptic curve.
src/main/java/com/thealgorithms/ciphers/ECC.java:213
↓ 14 callersMethodsumRange
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 callersMethodtoString
()
src/main/java/com/thealgorithms/datastructures/lists/SinglyLinkedList.java:242
↓ 14 callersMethodunionSets
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 callersMethodaddElement
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 callersMethodcountFriendsPairing
(int n, int[] a)
src/main/java/com/thealgorithms/dynamicprogramming/CountFriendsPairing.java:16
↓ 13 callersMethoddequeue
@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 callersMethoddivide
Divides this complex number by another. @param z The divisor. @return The quotient.
src/main/java/com/thealgorithms/maths/FFT.java:147
↓ 13 callersMethodequals
(Object o)
src/test/java/com/thealgorithms/sorts/SlowSortTest.java:130
↓ 13 callersMethodevictionListener
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 callersMethodgeneratePerlinNoise
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 callersMethodgetDiceCombinations
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 callersMethodgetKey
()
src/main/java/com/thealgorithms/datastructures/caches/MRUCache.java:214
↓ 13 callersMethodgetMin
Retrieves the minimum element in the stack. @return The minimum element.
src/main/java/com/thealgorithms/stacks/MinStackUsingTwoStacks.java:54
↓ 13 callersMethodgetWrongMess
Returns the counter wrongMess @return wrongMess, the number of Wrong Messages
src/main/java/com/thealgorithms/others/CRCAlgorithm.java:63
↓ 13 callersMethodorientation
(Point a, Point b, Point c)
src/main/java/com/thealgorithms/geometry/Point.java:22
↓ 13 callersMethodpeekFirst
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 callersMethodpoll
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 callersMethodpoll
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 callersMethodprint
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 callersMethodpush
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 callersMethodput
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 callersMethodremove
Dequeue the element with the max priority from PQ @return The element removed
src/main/java/com/thealgorithms/datastructures/queues/PriorityQueues.java:126
↓ 13 callersMethodromanToInt
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 callersMethodround
()
src/main/java/com/thealgorithms/maths/MathBuilder.java:261
↓ 13 callersMethodsumRegion
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 callersMethodadd
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 callersMethodaddUndirectedEdge
(List<Set<Integer>> graph, int u, int v)
src/test/java/com/thealgorithms/graph/BronKerboschTest.java:75
↓ 12 callersMethodarithmetic
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 callersMethodcompare
(Point p1, Point p2)
src/main/java/com/thealgorithms/geometry/Point.java:27
↓ 12 callersMethodcompute
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 callersMethodconvertOctalToBinary
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 callersMethodcreateSampleList
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 callersMethodencode
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
← previousnext →201–300 of 8,444, ranked by callers