Say you have a linked list structure in Java. It's made up of Nodes:
class Node {
Node next;
// some user data
}
and each Node points to the next node, except for the last Node, which has null for next. Say there is a possibility that the list can contain a loop - i.e. the final Node, instead of having a null, has a referenc...
I have a graph (with nodes and edges) containing symmetry and a group of permutations to label the nodes so no edges are changed (automorphisms). Now I would like to determine for which nodes a permutation exchanges two equivalent (i.e. nodes with the same color or symmetry class) neighboring nodes.
When the nodes with equivalent neighb...
They say that compacting garbage collectors are faster than traditional memory management because they only have to collect live objects, and by rearranging them in memory so everything's in one contiguous block, you end up with no heap fragmentation. But how can that be done quickly? It seems to me that that's equivalent to the bin-pa...
Hi,
I am to program the Solovay-Strassen primality test presented in the original paper on RSA.
Additionally I will need to write a small bignum library, and so when searching for a convenient representation for bignum I came across this specification:
struct {
int sign;
int size;
int *tab;
} bignum;
I will also be writing a m...
I have been trying to solve this problem for a while, but couldn't with just integer arithmetic and bitwise operators. However, I think its possible and it should be fairly easy. What am I missing?
The problem: to get an integer value of arbitrary length (this is not relevant to the problem) with it's X least significant bits sets to 1 ...
I currently was tasked to make a genogram for a family consisting of siblings, parents with aunts and uncles with grandparents and greatgrandparents for only blood relatives. My current algorithm is using recursion. but I am wondering how to do it in non recursive way to make it more efficient. it is programmed in c# using graphics to dr...
I am creating an algorithm that is based on directed graphs. I would like a function that will grab all the nodes that are attached to a particular node.
public List<Node> GetNodesInRange(Graph graph, int Range, Node selected)
{
var result = new List<Node>();
result.Add(selected);
if (Range > 0)
{
foreach (Node ...
I am not sure if you can post revision programming questions in here but i am stuck with some algorithms revision
If an algorithm is quadratic it takes time proportional to the number of n^2 ?
So if the slides say its almost 1/2 the square of n records is this the same as saying (n^2 * 0.5)
Thanks
...
How can I write an algorithm to check if the sum of any two numbers in an array/list matches a given number
with a complexity of nlogn?
...
I've seen people here made comments like "regex is too slow!", or "why would you do something so simple using regex!" (and then present a 10+ lines alternative instead), etc.
I haven't really used regex in industrial setting, so I'm curious if there are applications where regex is demonstratably just too slow, AND where a simple non-reg...
Does merge sort work by;
taking a list of values
splitting it in to two
take the first element of each list, the lowest value one goes in to a new list(and i guess removed from the original). comare the next two numbers - do this until one list is empty, then place the rest of the other list at the end ofthe nw list?
Also, what are ...
Suppose I have this program, I want to compare 2 input lists. Assume array A and array B. How do I determine the best case and worst case of the function?
Here is my code in [php]:
foreach($array_1 as $k){
if(!in_array($k, $array_2)){
array_push($array_2, $k);
}
}
What is the best case and worst case of the for loo...
Sorry for bad English :(
Suppose i can preliminary organize recipes and ingredients data in any way.
How can i effectively conduct search of recipes by user-provided ingredients, preferably sorted by max match - so, first going recipes that use maximum of provided ingridients and do not contain any other ingrs, after them recipes that u...
Hi all,
I have been writhing a rather large document with latex.
Now I would like to list all the figures / tables / algortihms once again at the end of the file so that I can check if they all look the same.
For example, if every algorithm has the same notation.
How can I do this?
I know about \listofalgorithms and \listoffigures b...
Hi folks:
I have a question about algorithm:
How to find all characters in a string whose appearance is greater than a specific number, say 2 for example efficiently?
Regards.
...
Is there any very fast method to find a binary logarithm of an integer number? For example, given a number
x=52656145834278593348959013841835216159447547700274555627155488768 such algorithm must find y=log(x,2) which is 215. x is always a power of 2.
The problem seems to be really simple. All what is required is to find the position of...
Hello.
Consider a weighted graph G=(V,E,w). We are given a family of subsets of vertices V_i.
A Steiner Forest is a forest that for each subset of vertices V_i connects all of the vertices in this subset with a tree.
Example: only one subset V_1 = V. In this case a Steiner forest is a spanning tree of the whole graph.
Example: a grap...
The challenge is to find the fastest way to determine in C/C++ the length of a c-string using bitwise operations in C.
char thestring[16];
The c-string has a max size of 16 chars and is inside a buffer
If the string is equal to 16 chars doesn't have the null byte at the end.
I am sure can be done but didn't got it right yet.
I am wo...
I'm sorry for deleting the original question, here it is:
We have a bag or an array of n integers, we need to find the product of each of the (n-1) subsets. e.g:
S = {1, 0, 3, 6}
ps[1] = 0*3*6 = 0;
ps[2] = 1*3*6 = 18; etc.
After discussions, we need to take care of the three cases and they are illustrated in the following:
1. S is a se...
I need to know the best way to detect a winning move in a game of noughts and crosses. Source code doesn't matter, I just need a example or something I can start with.
The only thing I can come up with is to use loops and test every direction for every move a player makes, to search for e.g five in a row. Is there a faster and more effi...