## [Solved] Big O, how do you calculate/approximate it?

I’ll do my best to explain it here on simple terms, but be warned that this topic takes my students a couple of months to finally grasp. You can find more information on the Chapter 2 of the Data Structures and Algorithms in Java book. There is no mechanical procedure that can be used to … Read more

## [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] Prove that (log n)! = O(n^k)

n^k = (e^k)^log n and the factorial grows faster than an exponential (product of growing factors vs. product of constant factors). 1 solved Prove that (log n)! = O(n^k)

## [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 for a loop vs a javasccript method that solves a problem [closed]

If your a double loop that solves this problem breaks out of the loops as soon as a match is found, then both methods are similarly inefficient – they both require iterating over all of N elements M times, worst-case, where N is the length of one array and M is the length of the … Read more

## [Solved] Is there a way to do the sum of the n integers function that would have O(n^2)?

I’m not really sure why you want this, but you could do it with two nested loops: int getSum(int n) { int sum = 0; for(int i = 1; i <= n; i++) { int x = 0; while(x++ < i) { sum++; } } return sum; } This runs 1+2+3+…+n times, which simplifies to … Read more

## [Solved] Giving the Big O, Big Theta and Big Omega for a function [closed]

Drop all lower-order terms and constants and you get: Θ(T(n)) = Θ(n + 10*log(n)) = Θ(n) Since this is a tight bound (Θ) we also infer upper and lower bounds as O(n) and Ω(n). solved Giving the Big O, Big Theta and Big Omega for a function [closed]

## [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] What is the running time of this algorithm? [closed]

Clearly, O(n) time-complexity, as i iterates from 0 to n-1. solved What is the running time of this algorithm? [closed]

## [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