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.

learn more… | top users | synonyms (2)

0
votes
0answers
12 views

Understanding time complexity

First of all I know this is not a direct coding question, but please don't close it as I badly need suggestions on this. I would like to understand and get a good grasp of the time complexity ...
1
vote
3answers
16 views

How can the worst case for an algorithm have different bounds?

I've been trying to figure this out all day. Some other threads address this, but I really don't understand the answers. There are also many answers that contradict one another. I understand that an ...
1
vote
2answers
21 views

Brute Force Permutation Swapping

I've been working on a brute force algorithm to generate all permutations of a given set. Eventually, I want to feed each of these permutations into a nxn matrix to test if it is a valid magic square ...
0
votes
0answers
14 views

Better Understanding Big O and Big Theta with a divide and conquer search

A divide and conquer algorithm takes an array of size n as input and makes two recursive calls on arrays of size n/2. Then, after an additional O(n) work, it produces an output. The running ...
0
votes
0answers
25 views

Why does this nested loop have memory traffic N(N+1) instead of N^2?

I was reading through a textbook earlier this afternoon about memory access optimization techniques, such as unroll and jam, and the book provided this as an example for consideration (before ...
-2
votes
0answers
23 views

Algorithm in Java throws InputMismatchException

import java.util.Scanner; public class planet { public static void main(String[] args) { planet test = new planet(); } int n,m; String str,strx; String[] str3=new ...
-5
votes
0answers
38 views

What is the random algorithm used in C#? [duplicate]

What is the algorithm used for the random generator in C#? Is it possible to view the source code of the Random class in C#? Is there an existing implementation of this algorithm in Javascript? What ...
-1
votes
0answers
21 views

Use jpg file as a template

Hi I need some help in finding correct solution to the problem. I have an jpg file that looks like an empty form and I need to put some values in correct places in that file using java. The ...
3
votes
2answers
46 views

How to smartly convert a number of seconds in a date-time value using C

In my embedded Linux application I have a "tick count" counter that increases 1 each 10 nanoseconds counting from 1st January 00:00:00 of 2014. I want to be able to, picking the current value of the ...
2
votes
3answers
46 views

Why does log appear so frequently in algorithmic complexity?

This question is about whether there is some abstract similarity between the solutions that leads to the appearance of log in problems such as sorting and searching. Or, more simply, why does log ...
0
votes
1answer
70 views

Is the following an encryption algorithm? If so, is it reversible? [on hold]

I came across the following method in a programming example. Is this really an encryption algorithm? Or is it more of a hex hashing/irreversible encoding algorithm? I see the use of bitwise shifts and ...
0
votes
1answer
41 views

Shortest path to connect n points

I have n points and I need to connect all of them minimizing the final distance. The image above represents an algorithm that in each node it connects to the nearest one but the final output might ...
0
votes
2answers
38 views

Generating two sets of numbers where the sum of each set and the sum of their dot product is N

In this question Getting N random numbers that the sum is M, the object was to generate a set of random numbers that sums to a specific number N. After reading this question, I started playing around ...
-1
votes
0answers
20 views

Searching in a tree

Given a tree with N vertices numbered from 1 to N. The vertex 1 is the root of the tree. Each vertex is assigned with an integer weight. A remove operation can remove sub-tree rooted at an arbitrary ...
0
votes
2answers
17 views

Grouping web site users by routes they make

I’m writing a simple website. I want to be able to group users by routes they make on my sites. For example I have this site tree, but the final product will be more complicated. Lets say I have three ...
-1
votes
0answers
12 views

Layout images of same height different widths in justified manner

I have hundreds of images of the same height (120px) but varying widths. I need to layout these images like a gallery so that it appears like Google image results. How do I do this? If I just put ...
-5
votes
0answers
24 views

Recursive & Iterative BinarySearch N [on hold]

My project asks me to do a recursive and iterative BinarySearch, calculating and timing the results for each one, having n=1000, n=100000,n=1000000. Also finding the worst case performance. Should i ...
0
votes
1answer
55 views

angle between hour minute second hands

I am writing a program to calculate the angle between the hour&min hand, hour&sec, minute&second. I wrote my code but no matter how much I change my calculations I still can't get the ...
2
votes
4answers
69 views

Minimal covering circle

There are n points on the plane, how can one approximately find the minimal radius of a circle that covers some k out of n these points? Number n is supposed to be less then 10^4. There is lots of ...
-7
votes
0answers
50 views

How was the first programming language made? [on hold]

I am new to programming and I have tried out a few different languages. However, I don't understand how the first programming language was created. What was the first programming language made and ...
1
vote
2answers
53 views

How many string2 exist in string1?

I'm trying to find an algorithm that takes an input from user (string1) and then takes another (string2) then counts How many string2 exist in string1. for example: there is 2 # in string1 here ...
0
votes
0answers
5 views

FCM clustering in spatial data

I am new in R, try to make cluster with EM and F-CM algorithms for spatial data set (n=150, (x,y) coordinates and 4 components). Can I use those algorithm (EM and F-CM) ? How to determine the number ...
1
vote
2answers
60 views

Fibonacci algortihm to find if a number(or a close neighbour) is the difference between 2 fibonacii numbers

I hope that someone can help me. Given a number n(which is not necessary to be a fibonacci number), i must find if that number is equal to the difference between two fibonacci numbers, if not i must ...
-1
votes
0answers
24 views

Short variable stores binary values incorrectly in S-DES (C++)

everyone. Very peculiar problem I'm having here. I'm writing a S-DES (Simplified Data Encryption Standard) Algorithm which I'd like to run for four rounds / iterations. The program is essentially ...
0
votes
0answers
13 views

evaluation metric for community detection using igraph in R?

I am running Community Detection in graphs and I run different community detection algorithm implemented in igraph listed here : 1. Edge-betweennes.community(w,-d) 2. walktrap.community (w,-d) ...
1
vote
3answers
50 views

Luhn algorithm java

I am trying to create a program to validate 10 to 12 digit long number sequences based on the luhn algorithm, but my program keeps on telling me that every number is invalid even though they're not. ...
2
votes
1answer
25 views

Configuration of a module's data sending

I want to configure (module A) to send certain data to (module B) at certain slots of time. (Module B) should send these configuration to (module A) during initialization. The data is: struct _data ...
0
votes
1answer
42 views

Counting Inversions in an array via merge sort

Inversion Count for an array indicates – how far (or close) the array is from being sorted. If array is already sorted then inversion count is 0. If array is sorted in reverse order that inversion ...
0
votes
2answers
26 views

Creating unique and recognizable sets of numbers

There have been different questions about random number generation, but I have not seen one that would address the specific problem that I am trying to solve. My requirements are: I need to be able ...
0
votes
3answers
46 views

How to modify the algorithm to reduce the delay?

I have a lot of inputs like this where user enters value: <INPUT TYPE=TEXT NAME="Milk" ONKEYUP="convcase(document.convert.Milk.value)"> <INPUT TYPE=TEXT NAME="Buckwheat" ...
0
votes
2answers
23 views

Asymmetric unique pair algorithm

This is a fast question. I know about asymmetric encryption and I know that you can use the private key to decrypt whatever is encrypted with the public key. I know too that having the Private key I ...
0
votes
2answers
48 views

How do I know how long will an algorithm (e.g. k-means) take to run?

For example, I'm running the k-means algorithm on 1 million data points. Each point is 128-dimensional, and I want 1000 clusters. Wikipedia tells me that its complexity is n^(dk+1)log(n), where d is ...
1
vote
1answer
39 views

Using suffixes for dictionary searching

P/S: Duplicates questions raised so far are concerning on prefixes (thanks for that anyway) This question is on suffixes. With dictionary dic={"abcd":2, "bbcd":2, "abgg":2} Is it possible to ...
-2
votes
2answers
19 views

What is the Big O, Theta O, Omega O for the following code?

for( i = 0; i< n; i++) { j+=i; } Assuming that Big O for the above code is O(2n), what will be Theta O ( tight bound ) and Omega O (lower bound) for the above code?
1
vote
2answers
43 views

Trying to dereference `&`-pointer

I am trying to write a naif implementation of kmeans in Rust for learning purposes. One of the steps is as follows: I have a collection of points xs and another collection of points centroids. I want ...
2
votes
2answers
71 views

How can you find points in regions of space quickly

Consider 5 dimensional space which has been partitioned by at least two planes which go through the origin. If there are n planes then the number of distinct pyramidal regions this creates is ...
1
vote
0answers
39 views

Extract an object from a photo

I am currently writing a program that can extract an object from a photo (by detecting and removing the background). This program works with user input in the following manner : The user marks with ...
4
votes
2answers
61 views

Efficient equality function on trees

A few days ago, I was given the following interview question. It was described with Standard ML code, but I was free to answer with the language of my choice (I picked Python): I have a type: ...
-1
votes
0answers
20 views

Greedy Course Scheduling Algorithm: latest start time

This is a practice test question: The following greedy algorithm is guaranteed to find the maximum number of non-conflicting courses: Choose the course with earliest completion time. Cancel out all ...
-1
votes
1answer
22 views

How to determine space and time complexity of an algorithm?

I have an algorithm, I am not sure about time and space complexity. , for (i = 1 to n ) do begin R(xi) = random(o, xi, r) i++ end What is the time and space complexity in above algorithm and why? ...
-4
votes
3answers
45 views

I write a algorithm for revers the number but doesn't work [on hold]

import java.util.Scanner; public class bertako { int[] arr; int n,k=0,temp1=0,temp2=0; Scanner scan = new Scanner(System.in); bertako(){ n = scan.nextInt(); for (int ...
3
votes
1answer
34 views

Extended find of unique tuples in a relation represented by a BDD

Consider {<1,2>, <1,3>, <1,7>, <0,4>} as the set of tuples of a relation R. Now consider that R is represented (via its membership function) by a BDD. That is, The BDD representing R ...
0
votes
1answer
40 views

Writing algorithm for types of triangle

I am faced with a question that goes like this: Write an algorithm that reads three integers a, b, c representing the sides of a triangle. Next, print the type of triangle represented (scalene, ...
0
votes
1answer
24 views

Trust based dictionary

Lets say we have a system with a number of "users". Each of those users can have their own "key/value" dictionary. Let say we store this data in a dictionary itself, data, with key (user, key) and ...
1
vote
0answers
52 views

Algorithm to create a list of numbers based on range and quartile

I have the following requirement: A function to create a "list" container to hold a group of data with numValues data, and the range, median, and interquartile ranges ...
1
vote
3answers
56 views

algorithms an pseudocode first year IT

I am faced with a question that goes like this: Write pseudocode that allows a user to repeatedly enter positive integers until an odd number is entered. It would then print the sum of all ...
0
votes
0answers
22 views

Minimum to Maximum spanning trees?

I have seen where one can modify classic Mininum spanning tree algorithms to find the Maximum spanning tree instead. Can an algorithm such as Kruskal's be modified to return a spanning tree that is ...
-3
votes
0answers
25 views

What is the most flexible sorting algorithms that's also efficient? [on hold]

What algorithm can be used for all-general purpose and has the best average performance? And what algorithms are good at specific scenarios? For example: What would you recommend implementing ...
-1
votes
1answer
24 views

Adjacency Matrix for ACM Finals JAVA

I was going through the questions they issued for 1996 ACM Regionals and I try to solve all of them. I found this interesting one about Adjacency Matrices and Connectivity matrices. Here's the ...
0
votes
1answer
41 views

Randomized Selection Algorithm

I am trying to implement a randomized selection algorithm where an array is filled with random numbers and the user selects a location and the program returns the value coinciding with the location in ...