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)

-2
votes
0answers
12 views

Best way to calculate a matching rate between a research and a database

I am doing an online dating service using Java EE, Hibernate and JSF. I want to do a matching system who can give a score according to certain search criteria.` In our database, we have many fields ...
1
vote
0answers
4 views

Find a cut in graph that divides the graph to approximately equal two subgraphs

Is there a practical algorithm (not NP-hard) that can cut a graph into two approximately equal sub-graphs (e.g., One sub-graph has 40%-50% vertices), in the meantime, prove that the cut is the minimal ...
0
votes
0answers
8 views

Efficient algorithm and storage format for the table 3xN

Given the following table: |A|B|C| |0|0|1| |1|0|3| |1|1|1| |1|2|1| |1|3|1| |1|4|2| |2|5|1| I need to come up with the most efficient algorithm and storage format that will allow me, determine C ...
0
votes
1answer
53 views

Is the complexity of Dijkstra's correct?

I have a question regarding to runtime complexity of Dijkstra's algorithm. (see pseudo code in CLRS vertion 3): DIJKSTRA(G, w, s) 1 INITIALIZE-SINGLE-SOURCE(G, s) 2 S ← ∅ 3 Q ← V[G] 4 while Q != ∅ ...
0
votes
1answer
38 views

Replace all spaces in a string with '%20'. Assume that the string has sufficient space at the end of the string to hold the additional characters

The question is as the titles, and I have write a code to implement this function. The code is as below, but the sentence: *(str+length_copy-1+tail_space_num) = *(str+length_copy-1); cause an error. ...
0
votes
0answers
16 views

Modify Quine Mccluskey algorithm

Anyone that is familiar with quine mccluskey would know that to get the implicants, we should compare the group with n number of 1s to the group with n+1 number of 1s. So my question is: Can there be ...
2
votes
1answer
51 views

Algorithm for traversing a maze

I need some help in writing a set of if-then rules for traversing a maze. This is the problem: "Assume that the maze is constructed on a grid of square cells by placing walls across some of the edges ...
0
votes
1answer
54 views

Battleship AI about sinking part under certain rules [closed]

I'm having some troubles in finding if, under certain rules, is possible to code an efficient AI for the sinking part of battleship. Rules are: the length of the shortest ship could even be 1. You ...
0
votes
2answers
64 views

Concatenate a string from a sorted Array

Hi I'm practicing for my interview and I would like to know if there is a better solution for this problem: Given a key String key="apple" and a sorted Array of strings, String[] words ={apple, ...
-4
votes
1answer
69 views

How to reverse a sentence without additional memory

I was recently asked this question in an interview. Initially, I was asked to reverse a sentence without using inbuilt String api methods like split etc. I/p : I like god O/p : god like I I did ...
-5
votes
2answers
33 views

Java wait for user input specified milliseconds [closed]

I need some simple code in java that will allow me to loop, while waiting for the user to enter text into the console for a specified number of milliseconds, returning the entered text if text is ...
0
votes
0answers
16 views

Build a simple blog that auto-tags posts

I'm looking at building a simple blog as a side project to experiment with. One feature I would like to add is an auto-tagging option that reads a list of pre-defined tags and will suggest tags for ...
2
votes
3answers
51 views

Ranks of array elements with respect to lexicographic ordering

I have an array A of length n containing strings of length 3. I want to build an array B where each string in A is replaced by its rank in A with respect to the lexicographic ordering. (Note that A ...
1
vote
4answers
53 views

Convert RGB Value to UIColor?

Given a huge list of RGB values, I would like to associate and pair them to a standard UIColor. For example, (255,0,0) is the "common" Red color. I would like to pair and label values like (254,85,44) ...
2
votes
3answers
99 views

Most efficient way to sort a circular buffer

I've implemented a circular buffer using a fixed-length array. In order to point to the start of valid data, I use an index (_startIndex). Similarly, in order to point to the end of valid data, I use ...

1 2 3 4 5 1986
15 30 50 per page