Mergesort in java

I am new to Java and have tried to implement mergesort in Java. However, even after running the program several times, instead of the desired sorted output, I am getting the same user given input as …

Find all numbers in the String [closed]

For example, I have input String: “qwerty1qwerty2”; As Output I would like have [1,2]. My current implementation below: import java.util.ArrayList; import java.util.List; public class Test1 { …

Does a hasDuplicate array method without using java.util exit? Is O(n) achievable with it?

I had an interview today which involved this very question and in order to widen my algorithmic knowledge. I am trying to see if there are any better suggestions. I was trying to find duplicates in an …

Java – Collections.sort() performance

I’m using Collections.sort() to sort a LinkedList whose elements implements Comparable interface, so they are sorted in a natural order. In the javadoc documentation its said this method uses …

Iteratively compute the Cartesian product of an arbitrary number of sets

I want to compute the cartesian product of an arbitrary number of nonempty sets in Java. I’ve wrote that iterative code… public static List<Set> cartesianProduct(List<…