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.

learn more… | top users | synonyms (1)

1
vote
0answers
56 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
28 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
77 views

Programming Concepts [on hold]

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
64 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
72 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
182 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 ...
-6
votes
0answers
38 views

Spoj Trie Problem [closed]

Recently I've tried to solve a problem of SPOj. After submitting the solution it is giving me WA. :( I've tried with some cases and every input is giving me correct answer. But as the online judge ...
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 ...
-3
votes
0answers
22 views

How Layered Voice Analisis Works? [closed]

This voice analysis technology has lots of applications, but the available versions are expensive and are oriented to security and businesses. I am interested in developing an open source version of a ...
4
votes
3answers
133 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 ...
-2
votes
1answer
41 views

Recursion and dynamic programming for maximization function [closed]

Player A and player B are given an array of size n. Each cell contains a positive integer, or 0. A and B take turns as given: Player A keeps either the first or the last cell, then player B keeps the ...
3
votes
1answer
155 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
503 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 ...
-1
votes
0answers
49 views

Algorithm for triangulating a polygon with given boundary edges [closed]

I am looking for an algorithm for triangulating a polygon with given points on the boundary and points in the interior. (This step has to be performed at the end of every iteration of an algorithm ...
0
votes
1answer
105 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? [on hold]

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
178 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
97 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
56 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
48 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
83 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
85 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
81 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
102 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
90 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
100 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
45 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
138 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
86 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
207 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 ...
2
votes
1answer
100 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
92 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
27 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
121 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
234 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 ...
1
vote
2answers
93 views

Algorithm Space and Time Complexity with Consideration for I/O (eg cache)

Is there an expression of performance for an algorithm or data structure that attempts to consider cache and other hardware concerns? Context: in my class we're looking at binary trees and it seems ...
30
votes
10answers
6k views

Is it reasonable to assume that any physical quantity can be represented by a 64-bit integer without overflow or underflow?

The original binary search algorithm in the JDK used 32-bit integers and had an overflow bug if (low + high) > INT_MAX ...