Recently in an interview I was asked several questions related to the Big-O of various algorithms that came up in the course of the technical questions. I don't think I did very well on this... In the ten years since I took programming courses where we were asked to calculate the Big-O of algorithms I have not have one discussion about ...
Possible Duplicate:
are there any O(1/n) algorithms?
Is it ever possible for your code to be Big O less than O(1)?
...
I have been looking at the source code for Microsoft .NET Libraries such as System.Web...... Whenever I look inside the code, I see flags, events, a whole ecosystem of rather complicated code which seems like overkill to do a pretty simple thing. It's filled with absolutely everything. I'm not sure I saw a simple piece of code inside ...
The Banker's algorithm is used to determine if all requests for resources can be satisfied without leading to a deadlock.
m is the total number of resources types
n is the total number of processes
NEED is an array of size m * n, it defines pending requests for each resources type. E.g.: NEEDij = 2 means that process i is requesting f...
Hello,
I'm doing some work with Ukkonen's algorithm for building suffix trees, but I'm not understanding some parts of the author's explanation for it's linear-time complexity.
I have learned the algorithm and have coded it, but the paper which I'm using as the main source of information (linked bellow) is kinda confusing at some parts...
When I need to join two strings I use String.Format (or StringBuilder if it happens in several places in the code).
I see that some good programmers doesn't give attention to strings joining complexity and just use the '+' operator.
I know that using the '+' operator make the application to use more memory, but what about complexity? ...
I'm new to Objective-C, Cocoa, Xcode and Interface Builder. I've got some C background in the past, as well as a fair amount of RealBASIC experience.
I'm working through Mark and LaMarche's iPhone 3 Dev book and I'm really just sort of stunned about how tedious some things are. Maybe someone can shed some light on this for me. My questi...
void compute(int n) {
int h = n;
while (h > 1) {
for (int i = 0; i < n; i++) {
// do some operation
}
h = h / 2;
}
}
Can anybody please tell me what is the complexity( Big O ) of this function of n ??
This is actually an argument between me and a friend of mi...
I am reading Nicolai Josuttis book on C++STL algorithms. For many algorithms such as stable_sort(), he mentions that the complexity of the algorithm n * log(n) if enough memory is available, otherwise it is n * log(n) * log(n). My question is how does the memory usage affects the complexity ? And how does STL detect such a situation?
...
My group is having some discussion and strong feelings about for loop construction.
I have favored loops like:
size_t x;
for (x = 0; x < LIMIT; ++x) {
if (something) {
break;
}
...
}
// If we found what we're looking for, process it.
if (x < LIMIT) {
...
}
But others seem to prefe...
I'm working on an application that allows dentists to capture information about certain clinical activities. While the application is not highly customizable (no custom workflows or forms) it does offer some rudimentary customization capabilities; clients can choose to augment the predefined form fields with their own custom ones. Ther...
I refer you to the following video, which describes how to implement Conway's Game of Life in APL, using a few dozen keystrokes:
http://www.youtube.com/watch?v=a9xAKttWgP4
This video was featured prominently in the Return of Uncle Bob Martin podcast, in which Scott Hanselman complains that "his hands hurt" from programming in languages...
I have a string, and another text file which contains a list of strings.
We call 2 strings "brotherhood strings" when they're exactly the same after sorting alphabetically.
For example, "abc" and "cba" will be sorted into "abc" and "abc", so the original two are brotherhood. But "abc" and "aaa" are not.
So, is there an efficient way t...
If one computer can only hold 1 million numbers, how to find out the median number from 100 million numbers?
...
I think this might be a classic question but I am not aware of an answer. Can a program output a copy of itself, and, if so, is there a short program that does this?
I do not accept the "empty program" as an answer, and I do not accept programs that have access to there own source code. Rather, I am thinking something like this:
int ma...
The Binary Tree here is not a Binary Search Tree. Its just a Binary Tree.
The structure could be taken as -
struct node {
int data;
struct node *left;
struct node *right;
};
The maximum solution I could work out with a friend was something of this sort -
Consider this binary tree (from http://lcm.csa.iisc.ernet.in/dsa/no...
I've got models like this:
class PledgeItem(models.Model):
title = models.CharField(...)
usd_amount = models.DecimalField(...)
class Pledger(models.Model):
name = models.CharField(...)
...
class Pledge(models.Model):
pledger = models.ForeignKey(Pledger)
item = models.ForeignKey(PledgeItem)
usd_amount = m...
I'm curious if n log n is the best a linked list can do.
Thanks
...
How to calculate number of sequences over {0,1} such that each sequence contains at least half ones?
...
Hi
I have a question to find a complexity class estimate of a algorithm. The question gives recorded times for an algorithm. So, do I just average out the times based on how it was computed?
Sorry, I missed a part.
ok, so it recorded time like N = 100, Algorithm = 300, next N = 200, Algorithm = 604, next N = 400 Algorithm = 1196, next...