int size(Node* root){ if (root == nullptr) { return 0; } return size(root->left) + 1 + size(root->right); } bool isBST(Node* node
A person claims that they can improve InsertionSort by the following argument. In the innermost loop of InsertionSort, instead of looping over all entries in th
I have a dataset comprised of n unsorted tuples representing numbers (let's say specific color codes) and their frequency (number of times of appearance). I wan
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
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
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
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
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
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
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
What is the time & complexity of the code below? function SortFunction (entries): sorted_entries = {} while entries is not empty: smal
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
from collections import deque def findMax(hardDiskSpace, k): n = len(hardDiskSpace) if n * k == 0: return [] if k > n: return []
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;
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) {
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
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
I heard the calculation amount of map function is O(1). But I can't understand the reason.
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
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