complexity

How do I find the running time given algorithm speed and computer speed?

I'm currently working through an assignment that deals with Big-O and running times. I have this one question presented to me that seems to be very easy, but I'm not sure if I'm doing it correctly. The rest of the problems have been quite difficult, and I feel like I'm overlooking something here. First, you have these things: Algorithm ...

C++ STL: Container Recreation or Reuse after clearing?

In programming we face various situations where we are required to make use of intermediate STL containers as the following example depicts: while(true) { set < int > tempSet; for (int i = 0; i < n; i ++) { if (m.size() == min && m.size() <= max) { tempSet.insert(i); } } //Some co...

multiset, map and hash map complexity

Hallo everybody, I would like to know the complexity in Big O notation of the STL multiset, map and hash map classes when: inserting entries accessing entries retrieving entries comparing entries ...

Is list::size() really O(n)?

Recently, I noticed some people mentioning that std::list::size() has a linear complexity. According to some sources, this is in fact implementation dependent as the standard doesn't say what the complexity has to be. The comment in this blog entry says: Actually, it depends on which STL you are using. Microsoft Visual Studio V6 ...

How much to log within an application??? How much is too much...

Hi guys Just wondering how much people log within their applications??? I have seen this: "I typically like to use the ERROR log level to log any exceptions that are caught by the application. I will use the INFO log level as a "first level" debugging scheme to show whenever I enter or exit a method. From there I use th...

How do you deal with Brain Buffer Overflow?

This is probably an old topic, but I just ran into it again, and it sounds like a good area to look for other ideas. The library I am working on has a bug that I am having difficulty isolating. In fact one of the things that happened in the last day or two, was the size got too big. The amount of detail is so large, I can't keep the w...

What is the time complexity of this Scheme function?

What is the time complexity? Why? (define (mult a b) (define (internal a accum) (if (= a 1) accum (internal (- a 1) (+ accum b)))) (internal a b)) (define (to-the-power-of m n) (define (internal x accum) (if (= x 0) accum (internal (- x 1) (mult accum m)))) (internal n...

When evaluating a design, how do you evaluate complexity?

We all know to keep it simple, right? I've seen complexity being measured as the number of interactions between systems, and I guess that's a very good place to start. Aside from gut feel though, what other (preferably more objective) methods can be used to determine the level of complexity of a particular design or piece of software? ...

Best practices on managing complexity/visualizing components in your software?

We're building tools to mine information from the web. We have several pieces, such as Crawl data from the web Extract information based on templates & business rules Parse results into database Apply normalization & filtering rules Etc, etc. The problem is troubleshooting issues & having a good "high-level picture" of what's happen...

Explaining computational complexity theory

It is said that true mastery of a subject is achieved when you can explain it simply. Unfortunately as an Electronics Engineer I lack some of the more formal aspects of computer science. Taking into consideration that there is some background in math, how would you explain computational complexity theory to the naïve? Where to start ...

Should you use a partial class across projects

Ok, So, I have a class library with all my database logic. My DAL/BLL. I have a few web projects which will use the same database and classes, so I thought it was a good idea to abstract the Data Layer into its own project. However, when it comes to adding functionality to classes for certain projects I want to to add method to cer...

Are there public key cryptography algorithms that are provably NP-hard to defeat?

Should practical quantum computing become a reality, I am wondering if there are any public key cryptographic algorithms that are based on NP-complete problems, rather than integer factorization or discrete logarithms. Edit: Please check out the "Quantum computing in computational complexity theory" section of the wiki article on quant...

Worst Case Time Complexity for an algorithm

What is the Worst Case Time Complexity t(n) :- I'm reading this book about algorithms and as an example how to get the T(n) for .... like the selection Sort Algorithm Like if I'm dealing with the selectionSort(A[0..n-1]) //sorts a given array by selection sort //input: An array A[0..n - 1] of orderable elements. //output: Array A[0.....

What's Up with O(1)?

I have been noticing some very strange usage of O(1) in discussion of algorithms involving hashing and types of search, often in the context of using a dictionary type provided by the language system, or using dictionary or hash-array types used using array-index notation. Basically, O(1) means bounded by a constant time and (typically)...

Computational complexity of Fibonacci Sequence

I understand Big-O notation, but I don't know how to calculate it for many functions. In particular, I've been trying to figure out the computational complexity of the naive version of the Fibonacci sequence: int Fib(int n) { if (n <= 1) return 1; else return Fib(n - 1) + Fib(n - 2); } What is the computational...

What is the processing overhead of length() in REXX?

How does the processing overhead of the length() function in REXX change with the length of the string? Update: I'm using: uni-REXX (R) Version 297t Open-REXX (TM) Copyright (C) iX Corporation 1989-2002. All rights reserved. ...

What algorithms count frequencies of common elements in a collection of sets?

I would like information on algorithms that can help identify commonality and differences between sets of overlapping data. Using stackoverflow's tag system as an example: Let's say this question has been given 5 tags. Let's say there are 1000 other questions that have at least one of these tags. Of these 1000 questions, how many of...

Can I reduce the computational complexity of this?

Well, I have this bit of code that is slowing down the program hugely because it is linear complexity but called a lot of times making the program quadratic complexity. If possible I would like to reduce its computational complexity but otherwise I'll just optimize it where I can. So far I have reduced down to: def table(n): a = 1 ...

Does using the Specification Pattern truly reduce complexity in your code?

From my reading, it appears that the Specification Pattern can greatly reduce the reduce the number of methods needed to filter data. What benefits have you seen using the Specification Pattern? Were there unforeseen benefits that you noticed. conversely, what pitfalls did you encounter? ...

What is the best way to get the minimum or maximum value from an Array of numbers?

Let's say I have an Array of numbers: [2,3,3,4,2,2,5,6,7,2] What is the best way to find the minimum or maximum value in that Array? Right now, to get the maximum, I am looping through the Array, and resetting a variable to the value if it is greater than the existing value: var myArray:Array /* of Number */ = [2,3,3,4,2,2,5,6,7,2]; ...