Category "time-complexity"

O(n) and time complexity function of the given code

If the following loop structure is under Analysis of Upper bound, does it still compute to O(n^2)? I'm confused since inner loop has a dependency on the outer l

What's the computational complexity of .iloc[] in pandas dataframes?

I'm trying to understand what's the execution complexity of the iloc function in pandas. I read the following Stack Exchange thread (Pandas DataFrame search is

What's the computational complexity of .iloc[] in pandas dataframes?

I'm trying to understand what's the execution complexity of the iloc function in pandas. I read the following Stack Exchange thread (Pandas DataFrame search is

Time complexity of nested loop?

I'm not very familiar with Big O notation. I'm wondering does the time complexity of the nested loop always be n^2? For example the following function, the inne

Time Complexity of Determinant of a Matrix using cofactor method

Trying to use the method found on a web to get the determinant of a Matrix. But I am not sure about the time complexity of this method because of the recursion

Find the number of steps a string can be reduced to 0

My assignment: You are given a non-negative integer variable $Z$. There are two actions available that can change its value: if $Z$ is odd, subtract 1

Time and Space complexity of this checking if string is palindrome

I want to verify my assumptions about Time and Space complexity of two different implementations of valid palindrome functions in JavaScript. In the first imple

Time and space complexity - for loop inside of while loop

What is the time & complexity of the code below? function SortFunction (entries): sorted_entries = {} while entries is not empty: smal

Python measuring Big O notation algorithms execution time

I am trying to make a function to measure the execution time of Big O algorithms. I have made a list with the names of the functions, and a list of n values, wh

Time and Space complexity of the max disk space

from collections import deque def findMax(hardDiskSpace, k): n = len(hardDiskSpace) if n * k == 0: return [] if k > n: return []

Big(O) time complexity unable to find

What is time complexity of following code : int count = 0; for (int i = N; i > 0; i /= 2) { for (int j = 0; j < i; j++) { count += 1;

How do I check if an array includes a value in JavaScript?

What is the most concise and efficient way to find out if a JavaScript array contains a value? This is the only way I know to do it: function contains(a, obj) {

Fast matrix determinant calculation with specific structure

I have a k*k squared matrix with diagonal elements x>0 and all other elements y>0. The values of k, x, y are all subject to change. Now I need the determi

Having trouble computing time complexity of a given function in Python

I am learning about time complexity now, and I am working with BST (Binary Search Trees). This question needs some context and this is a follow up post to this

The time complexity of the map function

I heard the calculation amount of map function is O(1). But I can't understand the reason.

Algorithm to find the most frequent words [closed]

I can't think of an algorithm for my code. Please help me out. We have two files. The first one has text (Text length is n-words). The second

Time complexity - understanding big-Theta

I'm currently taking algorithms and data structure. After nearly two months of studying, I still find time complexity extremely confusing. I was told (by my pr

What's the time complexity of prod() in math in Python

Summary) What's the time complexity of math.prod() How to improve this code to get to the pass Details) Currently working on 'Product of Array Except Self' on L

Is there a known algorithm for finding which K elements out of N elements have a sum that is closest to a whole number?

As a small example, say I have N=6 elements { 0.03, 0.25000039, 1.391, 500.1, 0.5000001, 1.75001 } and K=3 then the combination { 0.25000039, 0.5000001, 0.

Constant space, one pass, daily coding problem

This is the Daily Coding Problem: “Given a singly linked list and an integer k, remove the kth last element from the list. k is guaranteed to be smaller