Having two lists, I want to get all the possible couples. (a couple can be only one element from list 1 and another from list 2)
If I do a double "foreach" statement, I get it immediately (I am using python):
couples = []
for e1 in list_1:
for e2 in list_2:
couples.append([l1, l2])
How can I sort couples list in a way tha...
I want to understand how huge graphs can be implemented, so that graph algorithms run faster with huge graphs.
...
Given n integers, is there an O(n) or O(n log n) algorithm that can compute the maximum value of a mathematical expression that can be obtained by inserting the operators -, +, * and parentheses between the given numbers? Assume only binary variants of the operators, so no unary minus, except before the first element if needed.
For exam...
Hey all,
I'm doing some work on Max Cut, and the algorithm I have works on every graph that I can think to throw at it, but those have been graphs that I can work out the solution by hand to validate, so they've been somewhat small. I am looking for a bunch of medium/large graphs (in any format, I dont mind writing parsers) that already...
Fellow programmers,
I know this is a little outside your juridistiction, but I was wondering perhaps if you have time, if you could help me with one "procedure". Not in view of math but what would be the best way to take.
This is an airfoil / profile. Usually, profiles are defined with two sets of data. One is the position of mean c...
var store = ['1','2','2','3','4'];
I want to find out that 2 appear the most in the array. How do I go about doing that?
...
I've got a job that I've been asked to do which involves writing a program to determine where various people are to work on a given day.
For example the input may be:
4-6pm, Site A
1-2pm, Site B
9-11am & 2-4pm Site A
Essentially there can be many sites and people can work during multiple blocks. I get the feeling that this kind of pr...
Son of Darts Problem was a contest on Al Zimmermann's Programming Contests that ended on 20 Jun 2010 :
Suppose that you have a dartboard that is divided into R regions. Each dartboard region has a positive integer value associated with it. Further suppose that you have D darts and that you throw each of them at the dartboard. Each...
I am looking for a way to implement a fast logistic function. The classic definition of logistic function is:
y(x) = 1 / (1 + (1/e^x)) where ^ is exponentiation.
or equally: y(x) = (e^x) / (e^x + 1)
However, my special logistic function has a base E instead of e, so:
y(x) = E^x / (E^x + 1)
E and x in my case are 32-bit integer, fix...
hi,
I came across a specific problem and looking for some algorithm for it. The problem to solve is as described below.
Let's say we have combinations like below
1 - 3 - 5
1 - 4 - 5
1 - 8 - 5
2 - 4 - 5
3 - 4 - 5
2 - 4 - 7
These combinations were generated from given sets, in this particular case let's say from
{1},{3,4,8},{5}
...
Statement
Consider a string of length N consisting only of lowercase alphabets a-z. Let s[i] be the character at the i-th position in the string (1-based). The string is a K-string if there are EXACTLY K values of i (1 <= i < N) such that s[i+1]<s[i] (we assume 'a'<'b'<'c'<...<'z'). Given K, find the shortest K-string. If there are mult...
Hey, I'm trying to generate a list of primes below 1 billion. I'm trying this, but this kind of structure is pretty shitty. Any suggestions?
a <- 1:1000000000
d<- 0
b <- for (i in a) {for (j in 1:i) {if (i %% j !=0) {d <- c(d,i)}}}
...
How to determine if a given f(n) and g(n) is in theta, omega, big oh, little omega, or little oh?
- I think one way of doing it is by plotting graphs of both functions f(n) and g(n). Even by plotting graphs how do we say when a f(n) is in theta, omega, big oh, little omega, or little oh? Am not clear on that. Can someone throw more detai...
Can anyone help me finding the time complexity of
T(n)=1 if n<=0
T(n)=T(n-1)+T(n-2)+n
...
Here I will be giving two functions f(n) and g(n) and my aim is to decide if the f(n) is in theta, omega, big o, little o or little omega.
Please provide detailed proof if you are confident with such problems.
Problem 1: f(n) = (1/2)n^2 - 3n, g(n) = n^2
Problem 2: f(n) = 6n^3, g(n) = n^2
Problem 3: f(n) = 3n+5, g(n) = n^2
Problem 4: ...
I'm trying to figure out all the different ways I can create groups of 4 from 6 objects using objective-c.
For example, if I had the following objects: a, b, c, d, e, f
Then I could create groups like
a, b, c, d
b, c, d, e
a, d, e, f
and so on. Order doesn't matter. If I wanted to figure out all the different possibilities, what ki...
I've been interested in the problem of finding a better prime number recognizer for years. I realize this is a huge area of academic research and study - my interest in this is really just for fun. Here was my first attempt at a possible solution, in C (below).
My question is, can you suggest an improvement (without citing some other...
Take an example of a question/answer site with a 'browse' slideshow that will show one question/answer page at a time. The user clicks the 'next' button and a new question/answer is presented to him.
I need to decide which pages should be returned each time the user clicks 'next'. Some things I don't want and reasons why:
Showing ...
I have a set of points which are interpolated with an unknown method, or to be more precise, the method is known but it can be one of the several - it can be polynomial interpolation, spline, simple linear ... - and a line, which, let's for now imagine it is given in the simple form of y = ax + b.
For interpolation, I don't know what me...
The successor of an element in a BST is the element's successor in the sorted order determined by the inorder traversal. Finding the successor when each node has a pointer to its parent node is presented in CLRS's algorithm textbook. (Intro to algorithm by MIT press). Now I am thinking another question, can we find the successor without ...