Questions tagged [algorithm-design]
Questions related to general, high level, techniques for the design of algorithms.
99 questions
0
votes
0
answers
65
views
What algorithm should be used to find the closest set of dates?
I have tried to outline my problem as structured as possible, here is a rough overview, I am trying to find the best matching stay for a hotel booking system. If someone inputs check in and checkout ...
2
votes
1
answer
103
views
Seeking help in designing an algorithm
I am not a computer science nor a math person, but if given a pseudo-code or a English outline of steps. I can probably fumble my way through and write some code. I Apologize for the wall of text/...
1
vote
1
answer
116
views
longest symmetric sequence
Suppose we are given a $n$-vector $A$ of real numbers. We need to find the longest sequence of symmetrical numbers. The numbers $a_i$ and $a_j$ are symmetrical if they are located at the same distance ...
2
votes
1
answer
213
views
Faster selection algorithm for small order statistics
SELECT(A,p,r,i) is an algorithm that
partitions $A[p:r]$ around the $i$ th order statistic ie. in the output, we have $l\in A[p:p+i-2]<A[p+i-1]< h\in A[p+i:...
3
votes
2
answers
275
views
The awkward status of Mersenne Twister
Random number generators generally fit into 3 categories IMO:
ad-hoc designs serving as stub to be replaced by something else if this ever happens,
considerate designs aiming at achieving statistical ...
1
vote
1
answer
60
views
An algorithm to evaluate the strength of Quiz Participants
As a side-project, I had the idea to write some kind of an algorithm that would evaluate all participations in our weekly Pub quiz, to then calculate the average strength of the participants.
This is ...
-2
votes
1
answer
66
views
How to design algorithm
I am a newbie to algorithm designing. I am working on user association and load balancing algorithm designing in millimeter wave wireless communications.
In this topic I am able to formulate the ...
1
vote
1
answer
178
views
3-colouring with a bounded amount of colors
The topic of 3-colouring is often talked about, but what happens if we limit the amount of times we can use one color? Take a graph $G=(V,E)$ with $k$ being the number of vertices, is it possible for ...
1
vote
1
answer
100
views
Fingerprint functions for set equality checks?
Given I have two sets of objects $A =\{a, b, c\}$ and $B = \{a, b, c, a\}$
Based on the set equality, I want the fingerprint of these sets to be the same $F(A) = F(B)$.
Additionally I want to be able ...
0
votes
1
answer
152
views
Queue for two types using 2 queues?
I'm reading the book Cracking the Code.
The answer for this question suggests a solution using timestamps and two separate queues. This is straightforward and involves simply enqueuing into the ...
1
vote
0
answers
142
views
Is the minimum spanning tree a minimum-altitude connected subgraph
I'm not sure if my solution to the following problem (adapted from Exercise 20, Chapter 4 of Algorithm Design by Jon Kleinberg and Éva Tardos) is correct. I would appreciate it if anyone could point ...
1
vote
0
answers
176
views
Sub-matrix with minimum size of $k$ and minimum sum
We have an $n \times m$ matrix whose entries are non-negative integers and we want to find a sub-matrix whose area (number of entries) is at least $k$ such that the sum of the entries in minimal. The ...
0
votes
0
answers
169
views
Counting number of sequences summing to target
This is a problem that I have been struggling to understand in a theoretical computer science book I've been reading:
We call a sequence of $n$ integers $x_1, \dots, x_n$ valid if each $x_i$ is in $\{...
1
vote
2
answers
190
views
Comparing Registers with 16-bits
I am given with this information:
"CMP OP1,OP2 will compare registers OP1 and OP2 if they are equal,
flag values will be ZF=1, CF=0,
if the first
operands value is greater flag values will be ZF=...
1
vote
0
answers
100
views
Abstract algebra algorithms
Let’s make a big list of algorithms relying on abstract algebra. This will help us see how ubiquitous algebra is in algorithm design. I’ll start with two: one is the General Number Field Sieve, the ...
1
vote
1
answer
815
views
Partition the indices of 2d array to minimize sum of sub-matrices
Given an $n\times n$ Matrix $M$, and the indices $[{1,2,3,4,...,n}]$ are divided into several intervals : $[1,x_1],[x_1,x_2],...[x_k,n]$, which further extract several squared sub-matrices along the $...
1
vote
1
answer
127
views
"Searching and sorting" algorithm to find the natural logarithim of a number?
Yeah, this is for a homework assignment, but I hope that you'll humor me anyway. I am asked to design an algorithm that finds the natural logarithm of a number. This would be straightforward, but I'm ...
1
vote
1
answer
106
views
Finding lost bottle (algorithm problem)
The question is as follows:
A scientist creates a new compound, called compound A, that will explode 10 days after being mixed with compound B. This compound A was stored in a label-less bottle on a ...
0
votes
0
answers
106
views
Doubt on integrality gap and LP relaxation
I have an exercise that tells me that, given a problem P (of which now I omit the description) there is no integrality gap between LP and ILP formulation of this problem, and for every fractional LP-...
0
votes
0
answers
37
views
How to divide services and capacities in a graph?
Given a graph where some nodes can provide some services with x,y,z... capacities. A node connected to multiple nodes needs to divide these services to the connected nodes and these nodes themselves ...
2
votes
1
answer
235
views
Given an array of size n, create a sub array with given conditions using dynamic programming
We are given an array of integers of size n, which is not necessarily sorted, and we want to create a sub array. We are allowed to do one of 3 tasks below in each level:
1. skip the number in original ...
3
votes
1
answer
721
views
Can a greedy algorithm have more than one subproblems to solve after making greedy choice?
For example:
s = <s1 s2 s3> is my problem,
I make greedy choice s2 and solve s1 and <...
4
votes
1
answer
170
views
Finding max value algorithm with subset comparison
I have a set of $N$ different values, and my goal is to find the biggest one in the least number of comparisons. Comparing subsets (using the sum of each) is also allowed, and counts as one comparison....
3
votes
1
answer
416
views
Longest substrings of common length with the same parity
Given two sequences $a$ and $b$, find largest $x$ such that in $a$ there is substring $A$ and substring $B$ in $b$ meeting those conditions:
length of both $A$ and $B$ is equal to $x$;
sum of elements ...
0
votes
0
answers
55
views
Trouble Convincing Myself Algorithm Correctness
I'm having a tough time convincing myself right when coming up for some solutions to medium/hard leetcode.com problems. Take the following question for example.
...