Big O, how do you calculate/approximate it?

Most people with a degree in CS will certainly know what Big O stands for. It helps us to measure how well an algorithm scales. But I'm curious, how do you calculate or approximate the complexity...

What are the complexity guarantees of the standard containers?

Apparently ;-) the standard containers provide some form of guarantees. What type of guarantees and what exactly are the differences between the different types of container? Working from the SGI...

Programmatically obtaining Big-O efficiency of code

I wonder whether there is any automatic way of determining (at least roughly) the Big-O time complexity of a given function? If I graphed an O(n) function vs. an O(n lg n) function I think I would...

What does "O(1) access time" mean?

I have seen this term "O(1) access time" used to mean "quickly" but I don't understand what it means. The other term that I see with it in the same context is "O(n) access time". Could someone...

O(log N) == O(1) - Why not?

Whenever I consider algorithms/data structures I tend to replace the log(N) parts by constants. Oh, I know log(N) diverges - but does it matter in real world applications? log(infinity) < 100 ...

Given a number N, find the number of ways to write it as a sum of two or more consecutive integers

Here is the problem that tagged as dynamic-programming (Given a number N, find the number of ways to write it as a sum of two or more consecutive integers) and example 15 = 7+8, 1+2+3+4+5, 4+5+6 I...

List of big-O analysis for Python datastructures

Is there a list of the different data structures and their big-O access times for Python? I was rummaging through the standard library docs and didn't see any, hence the question. :-)

sprintf like functionality in Python

I would like to create a string buffer to do lots of processing, format and finally write the buffer in a text file using a C-style sprintf functionality in Python. Because of conditional...

Complexity of list.index(x) in Python

I'm referring to this: http://docs.python.org/tutorial/datastructures.html What would be the running time of list.index(x) function in terms of Big O notation?

Big O, what is the complexity of summing a series of n numbers?

I always thought the complexity of: 1 + 2 + 3 + ... + n is O(n), and summing two n by n matrices would be O(n^2). But today I read from a textbook, "by the formula for the sum of the first n...

How can building a heap be O(n) time complexity?

Can someone help explain how can building a heap be O(n) complexity? Inserting an item into a heap is O(log n), and the insert is repeated n/2 times (the remainder are leaves, and can't violate...

A tool for calculating the big-O time complexity of Java code?

I have a question regarding time complexity (big O notation) for Java software. Is there a way to quickly calculate or test it (or any website that could calculate it for me would be welcomed). ...

Linear-time sorting algorithm for strings?

I have an array of strings, each one with a different length. e.g: s[0] = "sSWXk" s[1] = "qCk" s[2] = "sOQQXPbk" . . . s[x] = "KVfdQk"; I also am given that n = s[0].length() + s[1].length() +...

Why is naive multiplication n^2 time?

I've read that operations such as addition/subtraction were linear time, and that "grade-school" long multiplication is n^2 time. Why is this true? Isn't addition floor(log n) times, when n is the...

Time complexity of Uniform-cost search

I am reading the book Artificial Intelligence: A Modern Approach. I came across this sentence describing the time complexity of uniform cost search: Uniform-cost search is guided by path costs...

Find insertion location

I have a sorted ArrayList of integers. Now I have a new integer to insert into the ArrayList. This new integer has to be inserted at the appropriate position to keep the ArrayList in sorted...

Why is my Rust program slower than the equivalent Java program?

I was playing around with binary serialization and deserialization in Rust and noticed that binary deserialization is several orders of magnitude slower than with Java. To eliminate the...

Example of Big O of 2^n

So I can picture what an algorithm is that has a complexity of n^c, just the number of nested for loops. for (var i = 0; i < dataset.len; i++ { for (var j = 0; j < dataset.len; j++) { ...

Sort big files in Amazon S3

I have a big file (attribute file) in my Amazon S3 bucket in .zip form. It is around 30 gb when unzipped. The file is updated every 2 days. INDEX HIEGHT GENDER AGE 00125 155 MALE 15 01002 161...

Python Big O Determination

I'm writing a program where I have to determine the growth rate of some code. It might be run like this: python3 my_program.py program_with_code_to_test Here is where I am stuck: The executable...

Object files in R-package too large (Rcpp)

I am using Rcpp to integrate C++ code into an R-package. After compiling, I see that the *.o files are huge (~2Mb), while the original *.cpp and *.h files are only ~20kb. Where does this...

What's the Big O complexity of a ever decreasing range on a for loop?

I got 2 nested for loops, I calculate a new value for nrResults on every execution of the inner for loop (which will loop nnrResults - 2 times). The time complexity should be of order O(n), since...

How Can I fix the variable value without aditional constrain

I need to do Fix&Optimize heuristic and I need fix the last value of some variables but without adition constrain because the problem is big and more constrain is worse. Example that I don't want...

agl build fails in "recipe perl-native-5.24.4-r0: task do_configure:"

I am trying to build AGL(with poky icefish) as per instructions in https://wiki.automotivelinux.org/agl-distro/source-code inside a container based off...

Sorting functions according to their Big-O complexity

Question: Sort the functions in increasing order of big-O complexity f1(n) = (n^0.999999) log n f2(n) = 10000000n f3(n) = 1.0000001^n f4(n) = n^2 My answer to this question is that is: 3, 2,...

How to force SQL Server Management Studio to use 64 bit Import Wizard to avoid error: Microsoft.ACE.OLEDB.12.0 provider is not registered

I have 64 bit O/S and 64 bit Office installed. I have installed the MS Data Access components (tried various versions 64 bit/32 bit). I cannot get SSMS to import Excel files. I get error...

What will the time complexity of this python program in Big O notation?

I find it difficult to calculate the time complexity of this program as it involves a lot of built-in methods. Could anyone please help? Basically the question is to find topper of each subject...

Error while generating report in apache-jmeter-5.4.1.tgz

sh jmeter.sh -n -t filePath.jmx -l outFilePath.jtl -e -o folderPath Error generating the report: org.apache.jmeter.report.dashboard.GenerationException: Error while processing samples: Consumer...

Is there a good data structure for finding all stored subsets of a given bitset?

Let X be a set of distinct 64-bit unsigned integers std::uint64_t, each one being interpreted as a bitset representing a subset of {1,2,...,64}. I want a function to do the following: given a...

Number of reshuffles used to sort

I found an interesting problem recently, which looks like this: There is a dull sorting algorithm which takes the 1st number from an array, it finds an element which is lower by 1 than the 1st...