Tagged Questions
An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when your issue is related to algorithm design.
0
votes
0answers
24 views
Reader-writer lock possible implemetation issue
I just read deeply the example of second reader writers problem- prefering writers over readers, mentioned here.
I have a very specific question regarding the solution implementation mentioned there.
...
1
vote
2answers
56 views
Missing method PasswordDeriveBytes (PBKDF1) in .NET CORE
I'm developing a service in .NET Core 1.1. It connects to a legacy database which stores data encrypted with AES Rjindael. The decryption algorithm uses System.Security.Cryptography....
0
votes
0answers
5 views
Non-Disjunct Rectangle Edge Covering for 2D Squares on a Grid
Even though the title sounds complicated, my actual problem should not be too hard to model. However, I have not been able to find a good algorithm to do the following:
I want to cover a set of ...
21
votes
6answers
17k views
How to create a trie in c#
Does anyone know where I can find an example of how to construct a trie in C#. I'm trying to take a dictionary/list of words and create a trie with it.
1
vote
0answers
15 views
Measuring the identicality of unequal strings in Javascript
In principle this question can be answered language-independent, but specifically I am looking for a Javascript implementation.
Are there any libraries that allow me to measure the "identicalness" ...
2
votes
3answers
1k views
Trying to build inverse function
* If you are doing intro2cs in huji be careful...
I know why you're here *
I'm trying to build a function that get a function (assume continuity of monotone) as argument and return its inverse ...
3
votes
2answers
58 views
Am I reading the Balanced Brackets challenge wrong?
I'm doing the Balanced Brackets problem (https://www.hackerrank.com/challenges/balanced-brackets) and I can't figure out where I'm going wrong.
e.g.
3
{[()]}
{[(])}
{{[[(())]]}}
-->
YES
NO
YES
...
3
votes
3answers
718 views
Find the diameter of a set of n points in d-dimensional space
I am interesting in finding the diameter of two points sets, in 128 dimensions. The first has 10000 points and the second 1000000. For that reason I would like to do something better than the naive ...
8
votes
5answers
581 views
Compare 10 Million Entities
I have to write a program that compares 10'000'000+ Entities against one another. The entities are basically flat rows in a database/csv file.
The comparison algorithm has to be pretty flexible, it'...
1
vote
0answers
19 views
How to test if my implementation of back propagation neural Network is correct
I am working on an implementation of the back propagation algorithm. What I have implemented so far seems working but I can't be sure that the algorithm is well implemented, here is what I have ...
2
votes
4answers
81 views
Find the longest continuum in the array that the sum of the values in the continuum equal to zero modulo 3
I wrote a code that finds the longest continuum in the array that the sum of the values in the continuum equal to zero modulo 3, e.g for the array a[]={2,-3,5,7,-20,7}
We have 2-3+5+7-20=-9 so the ...
-1
votes
1answer
32 views
Conversion of 1-D array to 2-D array
I have tried to convert a 1-D array to a 2-D array. For example, if the 1-D array looks like this 1 2 3 4; the 2-D array should look like this
1 2 3 4
1 2 3 0
1 2 0 0
1 0 0 0
For this, I have tried ...
0
votes
0answers
25 views
Issue creating better random algorithm - daily spread
i need a algoritm that spreads some numbers across a day in percentages, following min / max percentage for that time rule, this is what i have atm:
public function getSpread() {
$rules = [
...
1
vote
2answers
34 views
Javascript least common multiple algorithm
I'm trying to script a function that takes two numbers and returns the smallest common multiple that is also divisible by all the numbers between those numbers, what I've got only works for 1,1 ...
0
votes
1answer
58 views
Linearly reading a multi-dimensional array obeying dimensional sub-sectioning
I have an API for reading multi-dimensional arrays, requiring to pass a vector of ranges to read sub-rectangles (or hypercubes) from the backing array. I want to read this array "linearly", all ...
2
votes
1answer
27 views
A simple duplicate block finding algorithm performs worse when using BloomFilter for lookups
I have concatenated two ISO files into one file. Both the individual ISO files are Linux distros of the same vendor but different versions. In the program I have written (shown below), the ...
20
votes
4answers
4k views
Combinations from dictionary with list values using Python
I have the following incoming value:
variants = {
"debug" : ["on", "off"],
"locale" : ["de_DE", "en_US", "fr_FR"],
...
}
I want to process them so I get the following result:
combinations = [
...
1
vote
0answers
32 views
How to design a constructive algorithm
Most algorithmic problems which I have practiced gives me a set of data and then asks me to compute something from it. For example, Given a graph G, find out how many connected components are in it, ...
29
votes
11answers
11k views
An efficient way to compute mathematical constant e
The standard representation of constant e as the sum of the infinite series is very inefficient for computation, because of many division operations. So are there any alternative ways to compute the ...
0
votes
1answer
41 views
How to solve equation T(n) = 5T(n/5) + sqrt(n), T(1) = 1, T(0) = 0 using recursion tree?
When I apply master theorem, I get O(n) but when I try to solve it using recursion tree, I get stuck and couldn't make out any solution.
I tried this :
T(n) = 5T(n/5) + sqrt(n)
T(n) = 5(5T(n/25) + ...
0
votes
2answers
220 views
Recursion Trees and Asymptotic Complexity: T(n) = T(n/3) + T(n/2) + n
I'm trying to use recursion trees to find the asymptotic complexity of this function:
T(n) = T(n/3) + T(n/2) + n if n > 5; otherwise T(n) = 1
I've made the recursion tree and determined that each ...
0
votes
2answers
18 views
create discrete step function in matlab
I am using the following code to create a standard discrete unit step function in MATLAB.
>> n = -5 : 5;
>> y = heaviside(n);
>> stem(n,y);
However, this prints I tried lots of ...
-3
votes
0answers
12 views
About k-fold cross validation in machine learning
What is the difference between validation and test?
What is different if I didn't use validation set when building a model?
I heard that validation's purpose is to avoid over-fitting. If it is right, ...
2
votes
1answer
23 views
About worse case scenarios in binary searching
Binary searching's worse case scenario is 1 + lg n, but does this worse case change if the element is in the sorted array or if the element isn't in it? I'm thinking that it should take less searches ...
-1
votes
1answer
56 views
Find the nth number formed using 2 set bits
Given an n, I need to find the nth number that can be formed using just 2 bits.
To clarify better, the sequence basically goes like 3,5,6,9,10..
ie. If n=1, answer=3 etc. (Note that the answer has ...
0
votes
0answers
14 views
Data structure for Camelcase search (similar to Eclipse and Idea)
I'm trying to implement an algorithm for camel case search (skipping letters between capital letters), for example:
Given list and input string.
List:
ManualProxy.java
MapPropertyBase.java
...
0
votes
1answer
19 views
ID Overlap checking algorithm
Example, the server has these ids:
aaaa, aaaa - 1 , aaaa - 2 , bbbb
If the client sign in, the server check client's algorithm
If the client's id is aaaa, server make client's id aaaa - 3
If the ...
0
votes
0answers
10 views
Distributed Sliding Window in Java
How would you design a distributed sliding window algorithm in Java? I have an automaton for pattern detection. It is either in accepting state or invalidates.
Say the pattern I'm looking for is age: ...
-4
votes
0answers
18 views
Which topic is this algorithm related to?
I understand this can't be really 'answered', but I just need someone to point me in the right direction of what topics I can study that will help me solve the problem below. go ahead and down vote me,...
-4
votes
2answers
1k views
which one is faster and why? Array vs Link List [closed]
Which one is faster and why? (in C/C++)
Array
Link List.
If we just want to iterate in for loop and print it.
-2
votes
1answer
22 views
Check if buckets of items can be placed in an interleaved manner
bucket1 = [1,2,3,4]
bucket2 = [5,6]
bucket3 = [7,8,9,10,11]
bucket4 = [12]
Need to place them in an arrangement such that 3 consecutive elements in the arrangement should be from different buckets....
3
votes
7answers
3k views
Detecting duplicate files
I'd like to detect duplicate files in a directory tree. When two identical files are found only one of the duplicates will be preserved and the remaining duplicates will be deleted to save the disk ...
0
votes
1answer
21 views
Small BFS Detail Clarification
The standard bfs implementation is something like (courtesy of Wikipedia):
Breadth-First-Search(Graph, root):
create empty set S
create empty queue Q
root.parent = NIL
Q....
0
votes
2answers
27 views
How can I analyze the time complexity of this algorithm?
What will be the time complexity for nested loops
for (i=1; i<=n; i++) {
for (j=1; j<=log(i); j++) {
O(1);
}
}
where n is given by user? Does the time complexity depend on ...
0
votes
1answer
21 views
Data structure visualization
Is there any library in any languages (python java preferred) that enables the visualization of an array, list etc. to see the operation throughout the execution of the programs?
This is for ...
5
votes
2answers
2k views
Karatsuba Multiplication for unequal size, non-power-of-2 operands
What's the most efficient way to implement Karatsuba large number multiplication with input operands of unequal size and whose size is not a power of 2 and perhaps not even an even number? Padding the ...
6
votes
4answers
3k views
Algorithms question: flipping columns
Suppose that we are given an m x n grid of zeros and ones and want to transform the grid so that the maximum number of rows are composed solely of ones. The only operation we are allowed to perform ...
6
votes
2answers
75 views
Coming up with an algorithm in O(n)
Here is the Problem to solve:
n dwarves make m statements about 'who is taller than who'
(for example: Jason < Tim, Burton < Jason etc.), but some dwarves could lie about the order and give us ...
0
votes
1answer
23 views
showing array for quickfind
I'm trying to print out the full array id[] after each time the union method is called. in the main method. also need to bee able to count the number of times the array is accessed. i am aware that it ...
4
votes
6answers
97 views
Create Max time from 4 digits
I have 4 digits as a,b,c and d.
I am trying to create max possible time in 24 hours format.
Example:
1 2 3 4 => 23:41
0 9 7 1 => 19:07
My approach was: to sort the all numbers. Then for hours ...
2
votes
2answers
65 views
How to use Bresenham's line drawing algorithm with sub pixel bias?
Bresenham's line drawing algorithm is well known and quite simple to implement.
While there are more advanced ways to draw anti-ailesed lines, Im interested in writing a function which draws a single ...
-1
votes
0answers
38 views
Permutation of list of integers of size N
I need help creating a list of integer lists which are permutations of the main list of which have a fixed size of size. I've provided a pseudo-code example below of what I would like the ...
0
votes
3answers
52 views
Project Euler #1 in Java - Why result correct although rounded down?
"Find the sum of all the multiples of 3 or 5 below 1000"
I am having problems with understanding why the solution below still returns the correct result because x3, x5 and x15 use int after division. ...
0
votes
1answer
23 views
Scraping Dynamic Data and Avoiding Duplicates with BS4, Selenium in Python
what I'm trying to do here is retrieve data from a dynamic page that constantly reloads with information. The way I have it setup is that it refreshes every 60 seconds. The issue is, that the old ...
2
votes
1answer
45 views
Algorithm to determine when midnight occurs based on segments of a traveling bus
I am writing an importer that takes information from a bus company and provides it in the following format:
1. Stations are numbered with indexes from 0 to n (0,1,2,3,4,5... etc)
The provider sends a ...
1
vote
1answer
76 views
Adjacent Elements in MATLAB with Mathematical Formulation
I have a set with elements and the possible adjacent combinations for this are:
So the total possible combinations are c=11 which can be calculated with the formula:
I can model this using a as ...
1
vote
0answers
60 views
Why the algorithm fails when increase the number precision? How can we decrease the sensitivity of the algorithm to the number precision?
I am using Newton Raphson +successive Substitute algorithm to perform flash calculation(chemical process simulation).
The algorithm can converge well when the input is in low precision like ...
41
votes
9answers
34k views
robust algorithm for surface reconstruction from 3D point cloud?
I am trying to figure out what algorithms there are to do surface reconstruction from 3D range data. At a first glance, it seems that the Ball pivoting algorithm (BPA) and Poisson surface ...
1
vote
1answer
31 views
Finding changes between 2 huge arrays
For the sake of simplicity, I have mapped a very large 2D space to a simple bit array (in reality it's around 200k of members).
Now let's say that I run a small algorithm that draws a "circle" of 1s ...
-1
votes
1answer
19 views
java: compare arrays with different size - error in loop [duplicate]
I have 2 arrays of String with difference size.
arrayA > arrayB
I need to print "Yes" if I found every words inside arrayA by use of arrayB, otherwise print "No".
Now the problem is that the ...