[Solved] Big O Of Mod 20

Assuming that you can insert integers of any size, the complexity will be the same as the complexity of division. So it is O(log n) due to log n is the number of digits. Notice 1: If you can only insert 32 or 64 bit integers, the “complexity” will be O(1). Notice 2: Since computers … Read more

[Solved] time complexity of recursion function

We have: 1 : if statement 3 : * operator 3 : function statement Totally: 7 So we have: T(n)=t(n-1) + t(n-2) + t(n-3) + 7 T(99)=1 T(98)=1 … T(1)=1 Then to reduce T(n), we have T(n-3)<T(n-2)<T(n-1) therefore: T(n) <= T(n-1)+T(n-1)+T(n-1) + 7 T(n) <= 3T(n-1) + 7 So we can solve T(n) = 3T(n-1) … Read more

[Solved] Big O Notation/Time Complexity issue

It would be O(N). The general approach to doing complexity analysis is to look for all significant constant-time executable statements or expressions (like comparisons, arithmetic operations, method calls, assignments) and work out an algebraic formula giving the number of times that they occur. Then reduce that formula to the equivalent big O complexity class. In … Read more

[Solved] Searching Duplicate String Complexity

You are making your code way too complicated, use a HashSet<String>, which will guarantee uniqueness and will return whether the element was already in the set. public class DuplicateEle { public static void main(String args[]) { Set<String> seen = new HashSet<>(); String[] arr = { “hello”, “hi”, “hello”, “howru” }; for (String word : arr) … Read more