In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Algorithms are used for calculation, data processing, and automated reasoning.
2
votes
1answer
35 views
equal distribution within given set of users
I have a requirement where I have a list of entity and users who that entity can be assigned
E1 can be distributed by U1 or U2
E2 must be distributed by U5
E3 can be distributed by U2 ...
3
votes
2answers
218 views
What is a good algorithm to teach time complexity? [on hold]
I am trying to teach my friend (who has a web development background) about algorithms.
Is there a good problem that you think teaches the concept of time complexity well?
It should be intuitive to ...
1
vote
0answers
72 views
GNU Simulated Annealing [migrated]
I'm working from the template program given here:
https://www.gnu.org/software/gsl/manual/html_node/Trivial-example.html
The program as they give it compiles and runs perfectly, which is nice. What ...
-3
votes
1answer
68 views
How to reverse the nibbles in long long int variable in C? [on hold]
I need the help to resolve the below in C code.
I have a long long int k=0x0000888804eaad0e
and i need the reverse of this (nibble wise) in other long long int variable.
that is i want the result to ...
0
votes
1answer
72 views
Creating algorithms [on hold]
I am a relatively new programmer. I can pick up languages and learn syntax at a speed that I consider good, but I can't figure out how to solve problems logically using algorithms very well. I know ...
-4
votes
0answers
26 views
Algorithm to decide category within an interval [on hold]
Suppose a day is divided:
Night 00-06
Morning 06-12
Afternoon 12-18
Evening 18-00
I need some kind of algorithm to decide what category (Night, Morning...) a given time within an interval of 6 ...
0
votes
1answer
126 views
Check distance between all elements in a list of numbers in O(n*lg(n))
I have an exercise for my algorithms and data structures class, where I basically have to implement a divide and conquer algorithm or function called check_distance to determine whether all numbers in ...
0
votes
0answers
94 views
How do I search the leaves of a tree where each node could have more than two children? [migrated]
I'm trying to search the leaves of a tree data structure for a target value.
My function looks like this:
def searchLeaves(self, target): #DFS
if len(self.children == 0): #is a leaf
...
1
vote
0answers
30 views
Image segmentation - show or hide clusters
I'm trying to make a small program in c#, that will downsample image to specified amount of colors (using K-means). Then, user will be able to hide\show colored areas(clusters) in image. I've ...
-4
votes
0answers
78 views
Programming Concepts [closed]
Can someone tell me the all the programming concept to be an expert programmer ?
like Delegation, Classes etc..
any good books to learn those all the programming concepts that i can go from
beginner ...
-6
votes
1answer
78 views
in c programming i need custom atoi code [closed]
i want to subtract two 64 bit hex numbers(in c programming),
0x0000888888888888 -1st hex value
- 0x00000000839DDB7A -2nd hex value
= 0x0000888804EAAD0E
=(need the above result in hex)
The 1st ...
0
votes
1answer
55 views
How to search for patterns on a (game)board?
Assume a gameboard with two kinds of pieces.
Let the task be to find a common patterns of pieces, namely the patterns that lead to winning.
The problem is general, but the game in question is ...
1
vote
1answer
73 views
Non-fixed-size Fenwick Tree implementation
I'm planning to implement a non-fixed-size Fenwick tree. That is, a Fenwick tree that allows interleaving range queries with adding/removing elements.
All implementations and samples I've seen so far ...
2
votes
1answer
188 views
When designing a data structure, should I implement very inefficient operations for convenience?
(I've added the .NET tags because the data structures are for .NET, and this question should be considered in the context of the conventions for that platform.)
I'm writing a library of immutable and ...
0
votes
2answers
92 views
Add file paths to database
I am scanning a directory of files and want to add them to a database. I have two variants:
for file in walk(basedir):
files.append(file)
for file in files:
add_to_database(file)
versus
...
4
votes
3answers
134 views
Algorithm that generates a group of men and women who are each interested in everyone from the other gender
In my dating app, I need to compile lists of men and women where all of the men in the list are potentially interested in all of the women in the list, and vice versa.
That is, in a list of 10 men ...
3
votes
1answer
156 views
How to draw rectangles for 2D arrays
I have an 2D boolean array that looks like this:
[0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][0][0][0][0]
[0][0][0][1][1][1][0][0][0][0]
...
3
votes
3answers
504 views
How to model state of leaving/entering home
I have two sensors: One detecting if the door is open or closed, another if movement has been detected in the corridor. I want to detect if the person has left or entered home.
Usually the person has ...
0
votes
1answer
106 views
What algorithm can be used to determine order given incomplete information?
Given a series of statements such as:
a<c
a<b
b<c
(Read as "a is before b", "a is before c", etc.)
What is the order of the elements? In this example, the answer is a<b<c.
A less ...
-1
votes
0answers
50 views
What is the best algorithm for real-time routing? [closed]
I am trying to do optimal path vehicle routing but I read somewhere that Djikstra's algorithm has to be modified in order to route optimally in real-time. Is there any other algorithm that is ...
0
votes
2answers
179 views
What machine learning algorithm should I use to build an intelligent reminder? [closed]
I'm trying to build an intelligent reminder application for the mobile platform. I'm new to this and I'm kind of lost. So here's the problem...
The application must behave like a personal assistant ...
1
vote
2answers
99 views
Efficient datastructure to create size-limited dictionary
I need a class that acts like a dictionary but will constrain the total number of key/value pairs it contains. For instants, let's say the maximum number of entries is 1000 and the class already ...
-2
votes
1answer
57 views
Find the best shuffle
I am trying to solve the following problem:
Question Description: Given four integer numbers A, B, C, and D, a shuffle of them is a zero-index array, which consists of these four numbers in some ...
0
votes
1answer
50 views
How to create good positive and negative images for opencv to distinguish smiling from not smiling? [closed]
My goal is to create an opencv haar classifier xml that distinguishes between me smiling and not smiling.
I created images, cut them, showing me smiling and as negatives not smiling. About 5000 ...
0
votes
0answers
54 views
Algorithm for the Simplication and Evaluation of Equations
As a new programmer messing around in python, I've been playing about with writing small programs which can calculate some of the stuff I did in maths at school.
I've been trying to think of a way ...
-2
votes
2answers
85 views
Counting digits of a decimal number
Is there an algorithm to count digits of a decimal number other than saving it as a string and then looping to find the decimal point and thus count the digits?
0
votes
1answer
88 views
What's the algorithm should I use for seeing how well 2 strings match?
Suppose I have 2 strings:
string1 = "home/lisa/Music/some_files/01.05 - Garden Ground.mp3"
string2 = "Music/Jim Smith/Unknown/(Deluxe Version/Garden Ground).mp3"
string4 = "Music/Jim Smith/Unknown/00 ...
1
vote
1answer
87 views
More efficient alternative that checks if a list can be made a palindrome
I asked this question on Stackoverflow, but they told me this is the best place to ask.
For my algorithms and data structures class, I have to write an algorithm that is more efficient in the worst ...
5
votes
1answer
110 views
Compute Adjacent Pair
I was asked the following question as part of an interview:
Integer V lies strictly between integers U and W if U < V < W or if U > V > W.
A non-empty zero-indexed array A consisting of ...
-1
votes
1answer
92 views
How to selecting Teams with Minimum Difference between Knowledge Levels
For the below challenge from a programming site, I am bit confused.
Problem Statement:
A Professor of Physics gave projects to the students of his class. The students have to form a team of two for ...
0
votes
1answer
101 views
Best algorithm for “ACM ICPC Team”
I have this problem (complete description):
There is a list of persons N and M topics.
I have to find out the maximum number of topics a 2-person team can know. And also find out how many teams can ...
0
votes
1answer
56 views
How to determine whether two trees (not necessarily binary) are isomorphic
Two ordered trees T' and T'' are said to be isomorphic if one of the following holds:
◦ both T' and T'' consist of a single node
◦ both T' and T'' have the same number k of subtrees, and the ith ...
2
votes
2answers
189 views
String Searching algorithm
A title for a movie can be ambiguous. (Eg. The Lord of the Rings, Lord of the Rings, Lord of the Rings, The)
There exists a database entry that has a list of movie titles mapped to a unique ...
0
votes
0answers
47 views
All clustering possibilities for a graph
Is there a known algorithm for finding all clustering possibilities for a directed graph?
EDIT:
By cluster i mean a weakly connected sub-graph G, so that E(G) > 0.
By a clustering possibility I ...
0
votes
1answer
140 views
Program to look at the first say 5 characters of a word and return a string if that string is actually the first 5 characters of a word?
For example, say I have a string and it has the letters:
RDNAL
This is not an actual English word or it doesn't start an actual english word, so the program would skip this string and would avoid ...
2
votes
1answer
94 views
Need an algorithm to filter this collection format
I'm sorry the title is so vague ... I cannot think how to describe it any better.
I have a collection in this format:
var myCollection = [{id:"a"}, {id:"b",excludes:["a"]}, {id:"c",excludes:["b"]}];
...
0
votes
1answer
87 views
Line intersection detection algorithm
I'm trying to detect if a line drawn by the user intersects itself. I'm using a line intersection detection algorithm that goes through each waypoint of the line and checks if intersects with any ...
2
votes
0answers
209 views
What algorithm is this?
I have some vague recollections from my algorithms courses, but nothing specific comes to mind.
let S be a multiset of things we are interested in.
As input, we get T, s1, s2, ... sn, all of which ...
0
votes
0answers
34 views
python: area mapping using trigonometric circle
I have a car controlled by a raspberry pi, I would like to create maps to each place it visits. The solution I came up with is simple. Lets say you tell the car to go forward and then after 5 minutes ...
-1
votes
1answer
99 views
Algorithm to 'segment' a number into blocks of n?
I'm not sure how to word the title properly, but the problem goes something like this:
I have 5 nodes, and node 0 is the "master".
User inputs a number, e.g. 100 to the master.
master "splits" the ...
1
vote
2answers
153 views
What alghorithm can I use to find the biggest subarray within a 2d array with only n different numbers?
Let's say I have a 2d array 100x100 in size, each cell in that array has a number from 1 to 50 randomly.
How do I find the biggest subarray in a rectangle size in that array that has only n different ...
0
votes
1answer
95 views
dynamic programming with memoization
I’ve a problem with a programming exercise. I hope you can help me. In this exercise I need to find out what the maximum profit is of taking pictures from several items in a park. For taking pictures ...
1
vote
2answers
108 views
Estimating run time of algorithm
For instance if i have an algorithm that is O(n2) and it will run for 10 seconds for a problem size of 1000. Now if i were to double the problem size to 2000 i want to know the approximate run time in ...
0
votes
1answer
44 views
Boundary traversal in binary tree
How to perform boundary traversal in binary tree using only single traversal of the tree?
I am doing it in this way (not a single traversal):
void printBoundary (struct node* root)
{
if (root)
...
1
vote
1answer
28 views
Matrix distribution to process grid
I need to write a program, which will perform LU-decomposition, etc. The problem is that I don't know about the preferred way to distribute the loaded matrix from the root process to other processes. ...
0
votes
0answers
15 views
Finding Contextual Nodes in a Knowledge Graph [migrated]
I'm currently participating in developing a knowledge graph that uses ConceptNet and a few others as its data sources. It uses the same architecture as ConceptNet namely it is stored as a hypergraph ...
3
votes
1answer
122 views
Algorithm to find minimal set
I have a set of sets S and I want to find a minimal set of elements M such that each set in S shares at least one element with M.
S = set of sets
∀ f∈S ∃e · e∈f ∧ e∈M
For example:
S = {{1}, {1, 2, ...
-2
votes
0answers
24 views
NullPointerException from tring to get seperate RGB components [migrated]
I am trying to get the seperate RGB components from each element in a 2D color array,but it keeps throwing a NullPointerException and I am not sure why. It might be something small that I missed, so ...
5
votes
3answers
243 views
SQL - Algorithm for finding availability of a resource
I'm having trouble creating a mysql compatible algorithm for this.
Background
App with mysql, perl and JS. It's a booking system where each booking is comprised of a start, end and qty. Start and ...
1
vote
0answers
26 views
PSO – how Dimensions are set up?
I am coding a Particle Swarm Optimization in C++. I have been for days trying to understand the theory of how dimensions work in each different problem.
In the many examples I have seen, all of them ...