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
1answer
19 views
Algorithm for finding reference angle
Definition of "reference angle":
An angle ϑr in the interval [0, 2π) corresponding to an angle ϑ outside of this interval, satisfying the conditions
sin(ϑ) = sin(ϑr) and cos(ϑ) = cos(ϑr).
For ...
1
vote
2answers
27 views
Finding elements in a BST that sum up to a provided value
I'm trying to get an approach to solve the problem
Find two elements in balanced BST which sums to a given a value.
Constraints Time O(n) and space O(logn).
I was wondering whether the following ...
1
vote
2answers
22 views
Algorithm to traverse a binary tree level by level starting from root
Can anyone suggest an algorithm to traverse a binary tree level by level starting from root?
0
votes
1answer
23 views
Creating a method that prints different outputs for each value in array c#
Hi I currently have a array that has all the values of a text file in it and currently have it reading back the file when it runs but I want to produce outputs for each value in the array when it ...
1
vote
3answers
56 views
Given a rectangular area and a set of rectangles, check if the entire area is covered by them
All values here are real numbers with up to two floating point digits.
Suppose we have a rectangular area, 100.0 by 75.0.
Then you are given a set of rectangles. How can I check whether these ...
0
votes
3answers
59 views
How are primitive arrays implemented in java?
There are several questions that are similar to this one here on S.O., but they don't quite answer what the code implementation is. I've looked at
Why isn't there a java.lang.Array class? If a ...
0
votes
0answers
31 views
Data Structures for minimizing the processing and memory utilization.
Consider the case that a set of integer numbers are to be stored in a highly volatile list where items are removed, inserted, updated frequently.
Most importantly, the search for a data item should ...
-2
votes
1answer
47 views
Dynamic approach to the TSP
I'm having trouble recognizing why this algorithm doesn't return the shortest path for the TSP.
vector<int> tsp(int n, vector< vector<float> >& cost)
{
long nsub = 1 << ...
1
vote
3answers
51 views
structuring complicated java methods
Can anyone show me how to control java's order of execution while still organizing the code in a simplified, easy-to-maintain structure?
I am programming a rather complicated algorithm in java. One ...
1
vote
1answer
43 views
Huffman code - compression [closed]
I've heard about something like a compression factor, or just simply compression, according to the huffman coding topic. I remember the formula:
compression = ( Linput - Loutput ) / Linput
However, ...
0
votes
1answer
63 views
A function to reproduce the same number for each input
say you have some data consisting of 2 columns and 1000 rows, like:
0,0
1,0
2,3
3,4
etc
I want to create a function that will always give what's in column 2 if given an input from column one, so ...
0
votes
0answers
65 views
How to derive this result? [migrated]
Problem is to find the total number of zeroes in the decimal representation for the series with input N
0, 1, 2, 3, 4, 5 ... upto N
due to time limit constraints run time complexity was needed ...
-4
votes
0answers
47 views
Term that appears once [duplicate]
I have been given a problem by my teacher which I can not solve. I have a sequence of numbers given and some operations: change the value at a given position or find the term that apperas once in that ...
1
vote
2answers
66 views
get all the paths between 2 nodes in a directed graph
I am trying to get all the paths in a directed graph between two nodes. I have a problem with a cycle and I cannot find the reason.
Here is my graph (taken from http://www.technical-recipes.com) :
...
0
votes
1answer
16 views
Trilateration and locating the point (x,y,z)
I want to find the coordinate of an unknown node which lie somewhere in the space which has its reference distance away from 3 or more nodes which all of them have known coordinate.
This problem is ...