MCPcopy Create free account

hub / github.com/TheAlgorithms/Java / functions

Functions8,444 in github.com/TheAlgorithms/Java

↓ 10 callersMethodpeekLast
Returns the last (tail) value of the deque WITHOUT removing @return the value of the tail of the deque, or null if empty
src/main/java/com/thealgorithms/datastructures/queues/Deque.java:131
↓ 10 callersMethodread
Reads a single byte from the stream
src/main/java/com/thealgorithms/io/BufferedReader.java:58
↓ 10 callersMethodremove
This solves the problem of removing elements quickly. Even though the worst case of 'remove' method is O(n), it is a very pessimistic view. We will ne
src/main/java/com/thealgorithms/slidingwindow/ShortestCoprimeSegment.java:89
↓ 10 callersMethodremove
Deletes a given value from the Binary Tree @param value Value to be deleted @return If the value was deleted
src/main/java/com/thealgorithms/datastructures/trees/BinaryTree.java:133
↓ 10 callersMethodrgbToHsv
Conversion from the RGB-representation to the HSV-representation. @param red Red-component of the color. @param green Green-component of the color. @
src/main/java/com/thealgorithms/conversions/RgbHsvConversion.java:87
↓ 10 callersMethodsort
(T[] array)
src/main/java/com/thealgorithms/sorts/AdaptiveMergeSort.java:4
↓ 10 callersMethodsubtract
Subtracts a number from this complex number. @param z The number to be subtracted. @return The difference.
src/main/java/com/thealgorithms/maths/FFT.java:87
↓ 10 callersMethodtoTitleCase
Converts a string to title case. @param input The string to convert @return The title-cased string, or empty string if input is null/empty. If in
src/main/java/com/thealgorithms/strings/TitleCase.java:24
↓ 10 callersMethodupdate
Adds a value to all elements in the range [l, r]. <p> This method uses a branchless approach by allocating an extra element at the end of the array,
src/main/java/com/thealgorithms/prefixsum/DifferenceArray.java:64
↓ 10 callersMethodvertexDoesExist
Checks if a particular vertex exists in a graph @param aVertex the vertex to check for existence @return whether or not the vertex exists
src/main/java/com/thealgorithms/datastructures/graphs/MatrixGraphs.java:156
↓ 9 callersMethodadd
Adds an element to the set. @param element The element to be added.
src/main/java/com/thealgorithms/datastructures/crdt/TwoPSet.java:45
↓ 9 callersMethodareFriendly
Checks whether two numbers are Friendly Numbers. @param a First number (must be positive) @param b Second number (must be positive) @return true if a
src/main/java/com/thealgorithms/maths/FriendlyNumber.java:41
↓ 9 callersMethodclear
()
src/test/java/com/thealgorithms/datastructures/lists/SinglyLinkedListTest.java:82
↓ 9 callersMethodcompute
Solves the 0/1 Knapsack problem using recursion. @param values the array containing values of the items @param weights the array containing weight
src/main/java/com/thealgorithms/dynamicprogramming/KnapsackZeroOne.java:30
↓ 9 callersMethodcountRangeWithDigitSum
Counts how many numbers in the range [L, R] have a digit sum equal to the target. @param l The lower bound of the range (inclusive). @param r
src/main/java/com/thealgorithms/dynamicprogramming/DigitDP.java:35
↓ 9 callersMethodcountSetBits
Counts total number of set bits in all numbers from 1 to n Time Complexity: O(log n) @param n the upper limit (inclusive) @return total count of set
src/main/java/com/thealgorithms/bitmanipulation/CountSetBits.java:23
↓ 9 callersMethoddecompress
Decompresses a list of integers back into a string using the LZW algorithm. @param compressed A list of integers representing the compressed data. Ca
src/main/java/com/thealgorithms/compression/LZW.java:99
↓ 9 callersMethoddequeue
Removes and returns the element at the front of the queue. @return the element at the front of the queue. @throws NoSuchElementException if the queue
src/main/java/com/thealgorithms/datastructures/queues/LinkedQueue.java:71
↓ 9 callersMethoddisplay
Prints contents of the list
src/main/java/com/thealgorithms/datastructures/lists/DoublyLinkedList.java:66
↓ 9 callersMethoddrawLine
Draws an anti-aliased line using Wu's algorithm. The algorithm produces smooth lines by drawing pairs of pixels at each x-coordinate (or y-coordinate
src/main/java/com/thealgorithms/geometry/WusLine.java:88
↓ 9 callersMethodencode
Encodes the given plaintext string into a binary string using the generated Huffman dictionary. @param text The plaintext string to compress. @return
src/main/java/com/thealgorithms/compression/HuffmanCoding.java:175
↓ 9 callersMethodencrypt
Encrypts a message using the public key. @param message The message converted to BigInteger. @param p The prime modulus. @param g The gen
src/main/java/com/thealgorithms/ciphers/ElGamalCipher.java:108
↓ 9 callersMethodfind
Generic Linear search method that searches for a value in the given array by checking each element one by one. @param array List to be searched (can
src/main/java/com/thealgorithms/searches/LinearSearch.java:59
↓ 9 callersMethodfind
(T[] array, T key)
src/main/java/com/thealgorithms/searches/IterativeTernarySearch.java:30
↓ 9 callersMethodfindMin
Return the node of the heap whose key is minimal. $ret == null if (empty==true)
src/main/java/com/thealgorithms/datastructures/heaps/FibonacciHeap.java:131
↓ 9 callersMethodget
@param n the zero-based-index of the queried ugly number @exception IllegalArgumentException n is negative @return the n-th ugly number (starting from
src/main/java/com/thealgorithms/maths/NthUglyNumber.java:43
↓ 9 callersMethodgetAbsValue
Returns the absolute value of a number. @param number The number to be transformed @return The absolute value of the {@code number}
src/main/java/com/thealgorithms/maths/AbsoluteValue.java:13
↓ 9 callersMethodgetElementKey
Retrieves the key value of an element at the specified index. @param elementIndex 1-based index of the element @return double value representing the
src/main/java/com/thealgorithms/datastructures/heaps/MaxHeap.java:111
↓ 9 callersMethodgetLCS
Returns the Longest Common Subsequence (LCS) of two given strings. @param str1 The first string. @param str2 The second string. @return The LCS of th
src/main/java/com/thealgorithms/dynamicprogramming/LongestCommonSubsequence.java:23
↓ 9 callersMethodgetListValues
Helper method to extract values from the linked list into an array for assertion.
src/test/java/com/thealgorithms/datastructures/lists/MergeKSortedLinkedListTest.java:83
↓ 9 callersMethodgetSolution
Gets the solution coefficients. @return the solution
src/main/java/com/thealgorithms/maths/LinearDiophantineEquationsSolver.java:281
↓ 9 callersMethodharmonic
Computes the harmonic mean of the given numbers. <p> The harmonic mean is calculated as: n / (1/x₁ + 1/x₂ + ... + 1/xₙ) </p> <p> Example: For numbers
src/main/java/com/thealgorithms/maths/Means.java:103
↓ 9 callersMethodinsert
Inserts an element at the rear of the queue. @param element Element to be added. @return True if the element was added successfully, false if the que
src/main/java/com/thealgorithms/datastructures/queues/Queue.java:50
↓ 9 callersMethodinsert
(TrieNode root, final String key)
src/main/java/com/thealgorithms/datastructures/trees/TrieAutocomplete.java:34
↓ 9 callersMethodintersection
Computes the intersection of two integer arrays, preserving element frequency. For example, given [1,2,2,3] and [2,2,4], the result will be [2,2]. St
src/main/java/com/thealgorithms/datastructures/hashmap/hashing/Intersection.java:53
↓ 9 callersMethodisAlphabeticIsogram
Checks if a string is an isogram using boolean array approach. Time Complexity: O(n) Space Complexity: O(1) @param str the input string @return true
src/main/java/com/thealgorithms/strings/Isogram.java:46
↓ 9 callersMethodisFullIsogram
Checks if a string is an isogram using length comparison approach. Time Complexity: O(n) Space Complexity: O(k) where k is the number of unique charac
src/main/java/com/thealgorithms/strings/Isogram.java:80
↓ 9 callersMethodkaprekarNumberInRange
Finds all Kaprekar numbers within a given range (inclusive). @param start the starting number of the range (inclusive) @param end the ending number
src/main/java/com/thealgorithms/maths/KaprekarNumbers.java:43
↓ 9 callersMethodkasai
Computes the LCP array using Kasai's algorithm. @param text the original string @param suffixArr the suffix array of the string @return the LCP
src/main/java/com/thealgorithms/strings/KasaiAlgorithm.java:29
↓ 9 callersMethodmaximumSubarraySum
Finds the maximum sum of a subarray of size K consisting of distinct elements. The algorithm uses a sliding window technique with a frequency map to
src/main/java/com/thealgorithms/others/MaximumSumOfDistinctSubarraysWithLengthK.java:44
↓ 9 callersMethodmoveHashToEnd
Moves all '#' characters in the input string to the end. @param str the input string containing characters and '#' @return a new string with all '#'
src/main/java/com/thealgorithms/strings/MoveHashToEnd.java:34
↓ 9 callersMethodmultiply
Multiplies two matrices. @param matrixA the first matrix rowsA x colsA @param matrixB the second matrix rowsB x colsB @return the product of the two
src/main/java/com/thealgorithms/matrix/MatrixMultiplication.java:36
↓ 9 callersMethodpeek
Retrieves, but does not remove, the element at the front of the queue. @return The element at the front of the queue, or {@code null} if the queue is
src/main/java/com/thealgorithms/datastructures/queues/GenericArrayListQueue.java:38
↓ 9 callersMethodpointOf
(int x, int y)
src/test/java/com/thealgorithms/datastructures/trees/KDTreeTest.java:9
↓ 9 callersMethodpop
Removes the top element from the stack. If the element is the minimum element, it is also removed from the {@code minStack}.
src/main/java/com/thealgorithms/stacks/MinStackUsingTwoStacks.java:34
↓ 9 callersMethodprime
(int num)
src/main/java/com/thealgorithms/maths/PalindromePrime.java:21
↓ 9 callersMethodpush
Pushes a new value onto the stack. Each entry stores both the value and the minimum value so far. @param value The value to be pushed onto the stack.
src/main/java/com/thealgorithms/stacks/MinStackUsingSingleStack.java:24
↓ 9 callersMethodquadratic
Computes the quadratic mean (root mean square) of the given numbers. <p> The quadratic mean is calculated as: √[(x₁^2 × x₂^2 × ... × xₙ^2)/n] </p> <p>
src/main/java/com/thealgorithms/maths/Means.java:125
↓ 9 callersMethodremove
Remove an element from the front of the queue @return the new front of the queue
src/main/java/com/thealgorithms/others/QueueUsingTwoStacks.java:45
↓ 9 callersMethodsearch
(int key)
src/main/java/com/thealgorithms/datastructures/trees/BTree.java:285
↓ 9 callersMethodsetTurnAroundTimeTime
(final int turnAroundTime)
src/main/java/com/thealgorithms/devutils/entities/ProcessDetails.java:64
↓ 9 callersMethodshuffle
Shuffles the provided array in-place using the Fisher–Yates algorithm. @param arr the array to shuffle; must not be {@code null} @throws IllegalArgum
src/main/java/com/thealgorithms/misc/ShuffleArray.java:30
↓ 9 callersMethodsize
Returns the number of elements in the bag. @return the number of elements currently in the bag
src/main/java/com/thealgorithms/datastructures/bags/Bag.java:49
↓ 9 callersMethodstart
()
src/main/java/com/thealgorithms/datastructures/graphs/Cycles.java:39
↓ 9 callersMethodsumOfSeries
Calculate sum of arithmetic series @param firstTerm the initial term of an arithmetic series @param commonDiff the common difference of an arithmetic
src/main/java/com/thealgorithms/maths/SumOfArithmeticSeries.java:25
↓ 9 callersMethodtoString
()
src/main/java/com/thealgorithms/others/Luhn.java:141
↓ 9 callersMethodxor
Applies the XOR operation between the input bytes and the key bytes. If the key is shorter than the input, it wraps around (cyclically). @param input
src/main/java/com/thealgorithms/ciphers/XORCipher.java:48
↓ 8 callersMethodaddEdge
this method adds an edge to the graph between two specified vertices @param from the data of the vertex the edge is from @param to the data of the ve
src/main/java/com/thealgorithms/datastructures/graphs/Graphs.java:77
↓ 8 callersMethodaddMovie
Add a movie to the index. @param docId Unique identifier for the movie. @param name Name of the movie. @param imdbRating IMDb rating of the movie. @pa
src/main/java/com/thealgorithms/searches/BM25InvertedIndex.java:128
↓ 8 callersMethodaddUser
(String userName)
src/main/java/com/thealgorithms/scheduling/FairShareScheduling.java:40
↓ 8 callersMethodallocateResources
(int totalResources)
src/main/java/com/thealgorithms/scheduling/FairShareScheduling.java:51
↓ 8 callersMethodaverage
Computes the arithmetic mean of a {@code double} array. <p>The average is calculated as the sum of all elements divided by the number of elements: {@
src/main/java/com/thealgorithms/maths/Average.java:32
↓ 8 callersMethodbuildSuffixArray
(String text)
src/main/java/com/thealgorithms/strings/SuffixArray.java:18
↓ 8 callersMethodcalculateTrajectory
Calculates projectile trajectory using standard Earth gravity. @param initialVelocity Initial speed of the projectile (m/s). @param launchAngleDegree
src/main/java/com/thealgorithms/physics/ProjectileMotion.java:57
↓ 8 callersMethodcheckTree
(Integer[] preorder, Integer[] inorder, BinaryTree.Node root)
src/test/java/com/thealgorithms/datastructures/trees/CreateBinaryTreeFromInorderPreorderTest.java:97
↓ 8 callersMethodcompare
Compares the G-Set with another G-Set to check if it is a subset. @param other the other G-Set to compare with @return true if the current G-Set is a
src/main/java/com/thealgorithms/datastructures/crdt/GSet.java:52
↓ 8 callersMethodcompress
Compresses a string using the Arithmetic Coding algorithm. @param uncompressed The string to be compressed. @return The compressed representation as
src/main/java/com/thealgorithms/compression/ArithmeticCoding.java:54
↓ 8 callersMethodcompress
Compresses a string using the Run-Length Encoding algorithm. @param text The string to be compressed. Must not be null. @return The compressed string
src/main/java/com/thealgorithms/compression/RunLengthEncoding.java:40
↓ 8 callersMethodcompute
Calculates the nth Fibonacci number. @param n The index of the Fibonacci number to calculate. @return The nth Fibonacci number as a BigInteger. @thro
src/main/java/com/thealgorithms/maths/FibonacciLoop.java:32
↓ 8 callersMethodcontains
Checks if the set contains the specified element. @param element the element to check for @return true if the set contains the element, false otherwi
src/main/java/com/thealgorithms/datastructures/crdt/ORSet.java:43
↓ 8 callersMethodconvert
Converts the given input value using the affine transformation: result = slope inValue + intercept. @param inValue The input value to convert. @retur
src/main/java/com/thealgorithms/conversions/AffineConverter.java:36
↓ 8 callersMethodconvert
Converts the input string using the Atbash cipher. Alphabetic characters are substituted with their opposite in the alphabet, while non-alphabetic cha
src/main/java/com/thealgorithms/ciphers/AtbashCipher.java:87
↓ 8 callersMethodconvert
Convert a decimal number to another radix. @param number the number to be converted @param radix the radix @return the number represented in the new
src/main/java/com/thealgorithms/stacks/DecimalToAnyUsingStack.java:29
↓ 8 callersMethodcountInversions
Counts the number of inversions in the given array. @param arr The input array of integers. @return The total number of inversions in the array.
src/main/java/com/thealgorithms/divideandconquer/CountingInversions.java:33
↓ 8 callersMethodcountNiceSubarrays
Returns the count of subarrays containing exactly k odd numbers. @param nums input array of integers @param k number of odd elements required in t
src/main/java/com/thealgorithms/slidingwindow/CountNiceSubarrays.java:28
↓ 8 callersMethodcutRod
This method calculates the maximum obtainable value for cutting a rod of length n into different pieces, given the prices for each possible piece leng
src/main/java/com/thealgorithms/dynamicprogramming/RodCutting.java:21
↓ 8 callersMethoddecode
Decodes the given binary string back into the original plaintext using the Huffman Tree. Validates the integrity of the binary payload during traversa
src/main/java/com/thealgorithms/compression/HuffmanCoding.java:203
↓ 8 callersMethoddecompose
@brief Performs QR decomposition on a matrix using the Gram-Schmidt process @param matrix the input matrix (m x n) @return QR object containing orthog
src/main/java/com/thealgorithms/matrix/QRDecomposition.java:44
↓ 8 callersMethoddecompress
Decompresses a string that was compressed using the Run-Length Encoding algorithm. @param compressedText The compressed string. Must not be null. @re
src/main/java/com/thealgorithms/compression/RunLengthEncoding.java:67
↓ 8 callersMethoddeterministicMillerRabin
(long n)
src/main/java/com/thealgorithms/maths/Prime/MillerRabinPrimalityCheck.java:43
↓ 8 callersMethodfindMinCut
(Collection<Integer> nodeSet, List<int[]> edges)
src/main/java/com/thealgorithms/randomized/KargerMinCut.java:49
↓ 8 callersMethodfindPrimes
Finds all prime numbers up to n using the Sieve of Eratosthenes algorithm @param n the upper limit (inclusive) @return a list of all prime numbers fr
src/main/java/com/thealgorithms/maths/SieveOfEratosthenes.java:37
↓ 8 callersMethodgetAllocatedResources
()
src/main/java/com/thealgorithms/scheduling/FairShareScheduling.java:58
↓ 8 callersMethodgetHeight
Returns the height of the game tree. @return The height of the game tree (log2 of the number of leaf nodes).
src/main/java/com/thealgorithms/others/MiniMaxAlgorithm.java:202
↓ 8 callersMethodgetImaginary
Returns the imaginary part of the complex number. @return The imaginary part of the complex number.
src/main/java/com/thealgorithms/maths/FFT.java:64
↓ 8 callersMethodgetMap
()
src/test/java/com/thealgorithms/datastructures/hashmap/hashing/LinearProbingHashMapTest.java:11
↓ 8 callersMethodgetMaxMatching
Calculates the maximum weighted matching for the tree, starting from the given root node. @param root The index of the root node of the tree. @param
src/main/java/com/thealgorithms/dynamicprogramming/TreeMatching.java:40
↓ 8 callersMethodgetMaxValue
Finds the absolute maximum value among the given numbers. @param numbers The numbers to compare. @return The absolute maximum value. @throws IllegalA
src/main/java/com/thealgorithms/maths/AbsoluteMax.java:14
↓ 8 callersMethodgetRoot
returns root node of the Treap
src/main/java/com/thealgorithms/datastructures/trees/Treap.java:333
↓ 8 callersMethodgetRoot
()
src/main/java/com/thealgorithms/datastructures/trees/LazySegmentTree.java:171
↓ 8 callersMethodhashCode
()
src/main/java/com/thealgorithms/datastructures/trees/KDTree.java:93
↓ 8 callersMethodheight
(Node n)
src/main/java/com/thealgorithms/datastructures/trees/AVLTree.java:250
↓ 8 callersMethodincrement
Increments the increment counter for the current node.
src/main/java/com/thealgorithms/datastructures/crdt/PNCounter.java:46
↓ 8 callersMethodintersects
Checks whether two line segments intersect. @param p1 first endpoint of segment 1 @param p2 second endpoint of segment 1 @param q1 first endpoint of
src/main/java/com/thealgorithms/geometry/LineIntersection.java:22
↓ 8 callersMethodinverseSqrt
Returns the inverse square root of the given number upto 6 - 8 decimal places. calculates the inverse square root of the given number and returns true
src/main/java/com/thealgorithms/maths/FastInverseSqrt.java:24
↓ 8 callersMethodinverseTransform
Performs the inverse Move-to-Front transform. <p> Reconstructs the original string from the list of indices produced by the forward transform. This re
src/main/java/com/thealgorithms/compression/MoveToFront.java:139
↓ 8 callersMethodisEmpty
Checks if the queue is empty. @return {@code true} if the queue is empty; {@code false} otherwise
src/main/java/com/thealgorithms/datastructures/queues/CircularQueue.java:55
↓ 8 callersMethodisEmpty
Returns whether or not the deque is empty @return whether or not the deque is empty
src/main/java/com/thealgorithms/datastructures/queues/Deque.java:149
↓ 8 callersMethodisHappy
Checks whether the given number is a Happy Number. Uses Floyd’s Cycle Detection algorithm (tortoise and hare method) to detect loops efficiently. @pa
src/main/java/com/thealgorithms/maths/HappyNumber.java:27
↓ 8 callersMethodisPalindrome
Check if {@code n} is palindrome number or not @param number the number @return {@code true} if {@code n} is palindrome number, otherwise {@code fals
src/main/java/com/thealgorithms/maths/PalindromeNumber.java:24
← previousnext →401–500 of 8,444, ranked by callers