## Resolved: Improve performance of Array ordering by IDs

In this post, we will see how to resolve Improve performance of Array ordering by IDs Question: I have a function: As you can see, it calls getModelsFromCache which roughly looks like this: As you can see, getModelsFromCache returns and ...

## Resolved: Time Complexity of a Recursive Function with a Reducing Parameter

In this post, we will see how to resolve Time Complexity of a Recursive Function with a Reducing Parameter Question: This is the function. What’s the big O notation and how can I calculate it? I’m new to this. Is ...

## Resolved: How does a two level sorting algorithm work?

In this post, we will see how to resolve How does a two level sorting algorithm work? Question: I had a problem where I wanted to sort a list of tuples, first by the first element and then by the ...

## Resolved: What will be the time complexity of this code fragment?

In this post, we will see how to resolve What will be the time complexity of this code fragment? Question: Given this question where increment over the iterator i happens by incrementing its value by its own log value. What ...

## Resolved: Time complexity of lookup and then insertion in a std::map>

Question: So I have a graph (std::map) that stores strings as the keys and the values are sets of strings (adjacency lists for each node in a graph): std::map<std::string, std::set<std::string>> graph My insertion code is simply: graph[from].insert(to) where from and ...

## Solved: What is Constant Amortized Time?

Question: What is meant by “Constant Amortized Time” when talking about time complexity of an algorithm? Best Answer: Amortised time explained in simple terms: If you do an operation say a million times, you don’t really care about the worst-case ...

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

Question: 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 the heap property). So, ...

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

Question: 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 of your algorithms? ...

## Solved: How can I find the time complexity of an algorithm?

Question: I have gone through Google and Stack Overflow search, but nowhere I was able to find a clear and straightforward explanation for how to calculate time complexity. What do I know already? Say for code as simple as the ...

## Solved: What are the differences between NP, NP-Complete and NP-Hard?

Question: What are the differences between NP, NP-Complete and NP-Hard? I am aware of many resources all over the web. I’d like to read your explanations, and the reason is they might be different from what’s out there, or there ...