An algorithm is a sequence of well-defined steps that defines in abstract the solution to a problem.

learn more… | top users | synonyms

2
votes
0answers
23 views

AVL binary search tree implementation

Is there any text-book implementation of self-balancing binary search trees such as AVL or red-black in Mathematica?
0
votes
0answers
45 views

“Real Graph example” to test algorithms

I wrote some algorithms which process graphs. I tested them and found those ones worked. But I would like to demonstrate them too. What is the best way to create example graphs from real world? I ask ...
-2
votes
0answers
30 views

Can't seem to add another seed to rule 110 [closed]

I'm trying to create some different scenarios to rule 110 CA. In this case I'm trying to add several seeds as 1 in the first generation. However, it doesn't seem to matter if i insert the ...
-1
votes
1answer
38 views

Algorithm in Module behaves different [closed]

In my Notebook i wrote this algorithm: ...
2
votes
0answers
90 views

Using the Baby-Step Giant-Step algorithm

Here is a concept I am working through: As part of an attack on an El-Gamal cipher, solving the discrete logarithm problem $$10^x = 532107 \;\, {\rm mod} \;\, 1313839.$$ Using the ...
5
votes
4answers
276 views

Efficient way to sum all the primes below $N$ million in Mathematica

Today, I saw a problem described as below: Sum all primes below $N$ million At the beginning, I feel it is rather simple to calculate it in Mathematica ...
0
votes
0answers
41 views

Substitution Permutation Network (SPN) - Decryption In Mathematica

I am working with a Substitution Permutation Function, SPN, in Mathematica. I have an encryption function for an SPN. By changing the parameters that go into the spn function, and not the function ...
5
votes
4answers
711 views

A too complicated lookup

I have the following keys: nm = {"bay", "ica", "rat", "tat", "dax", "dow", "sp5", "nas", "mean", "total"}; which I want to use to find a corresponding entry in ...
0
votes
1answer
75 views

Books of algorithms for programming [closed]

I'm studying Computer Science and would like to know, if there are special books on algorithms for programmers, or if you can suggest some books talking on algorithms in general
4
votes
3answers
136 views

Unragging a matrix

Today I ran into matrices like this one: ...
2
votes
2answers
35 views

Count elements between matching opening and closing parentheses?

Suppose I have a List of the form: lst={"(", "x1", "x2", "(", "(", "x3", ")", "x5", "(", "x6", ")", ")", ")"} For each pair ...
2
votes
2answers
87 views

Replace missing data

I have vectors of equal lengths where I want to replace the zeroes (missing data) with their preceding values. So far I have written: ...
9
votes
5answers
459 views

Match opening and closing parentheses?

Suppose I have a List of the form: lst={"(", "(", "(", ")", "(", ")", ")", ")"} By running ...
24
votes
7answers
680 views

Faster position list construction from a “take instructions” list

Take some list, e.g., {1,2,3,4,5}, and a "take instructions" list, say {1,1,2,1,1}. The latter is read as "take the first ...
2
votes
1answer
95 views

Stochastic Predator-Prey model using Gillespie's SSA

I'm trying to model the predator-prey situation using SSA. I am very new to Mathematica so my handling of matrices is probably terrible, and that's probably adding to my confusion: ...
2
votes
2answers
51 views

Efficiently or Elegantly construct linear graph list from vertex pairs

I am processing MRP data, with BOM relations as pairs of part number strings. I want to construct lists that represent the linear graphs defined by these pairs. Here is some code to generate random ...
1
vote
0answers
57 views

Implementation of Lubaehevsky-Stillinger Algorithm to pack hard spheres

To generate a model of a polycrystalline material with specified grain size distribution (e.g coming from a Monte Carlo Grain Growth simulation) the Paper "Effects of grain size distribution and ...
4
votes
1answer
66 views

Default algorithm in NonlinearModelFit

Does anyone know the default algorithm used in NonlinearModelFit? The documentation gives several possible algorithms, but I can't figure out what it uses if you do not specify the algorithm. Thanks. ...
0
votes
1answer
255 views

Code efficiency improvement needed solving problem 499 in Project Euler

I am trying to solve https://projecteuler.net/problem=499 by constructing a transition matrix and finding its steady state. Here is my code: ...
2
votes
1answer
108 views

Maximizing the number of zero entries in a matrix

I have a matrix with a bunch of parameters in its entries, they all come in different combinations in different places of the matrix. I can post the matrix itself if requested, but I think what I mean ...
1
vote
0answers
86 views

How can I detect certain letters by shape in an image?

I have a website where people can post Flipbook animations, called Flipnotes. Unfortunately, most of the Popular flipnotes are in the following categories: MV (Music Video) AV (Audio Video) AMV ...
2
votes
0answers
45 views

How to compute the longest non-contiguous common sequence?

LongestCommonSequence[] works well, but what about finding the longest common sub-sequence (not necessarily contiguous)? Is this function built in to the genome ...
15
votes
3answers
185 views

Partitioning with constraints on subsets

Given the following data: constraints = {{11, 2}, {11, 3}, {11, 4}, {11, 6}, {11, 9}, {1, 6}, {5, 6}, {2, 5}}; weights = {3, 7, 3, 2, 4, 2, 2, 2, 3, 2, 1}; I ...
4
votes
1answer
212 views

A problem about Steffensen method

Two days ago,I asked a question about bisection algorithm. Thanks for Michael E2 giving me a good solution My algorithm 1, I use the bisection algorithm to generate a initial value that contain a ...
6
votes
2answers
350 views

Implement the Bisection algorithm elegantly and easily

Description: Rencently, I have finished my course Numerical Analysis, so I'd like to implement many algorithm that I have learned from that course.By this practice, I hope that I can improve my ...
4
votes
1answer
126 views

How to execute a notebook in background

I am developing an algorithm that take time to return results. I thought if I could run this notebook in background and continue to develop the rest of my work. It is possible to do that?
7
votes
1answer
194 views

How to know the internal algorithms of functions like Predict or Classify?

The document centre seems only explain how to use these functions, but just in an very brief way. I know Mathmatica is not open source, so we can not expect to see the code of the function, but are ...
4
votes
0answers
92 views

Implement a piecewise function elegantly and efficiently

Given that $$ g(x)= \begin{cases} max(x_{min},x-m) & 0.5x \leq max(x_{min},x-m) \\ 0.5x & max(x_{min},x-m)<0.5x<min(1,x+m) \\ min(1,x+m) & min(1,x+m)\leq 0.5x \end{cases}$$ ...
0
votes
1answer
54 views

timing series algorithm [closed]

If we have a timing series t1,t2,t3.... and every timing point means an event. A time interval T is given. Once T is given, how to calculate the maximum event number happening in T? case A ...
3
votes
3answers
81 views

Generating increasingly longer lists from a single list

I start with an array such as {{1,1},{0,1},{-1,1}}. (1) I want to create an array from this which replaces each array inside the array with 3 new arrays, one ...
6
votes
3answers
308 views

Calculating integral by Romberg Algorithm

In my "Numeric Anasyis" course, I learned the Romberg Alogrithm to calculate the numerical integral. The Romberg Alogrithm as shown below: $$ ...
16
votes
7answers
592 views

Enumerating tuples from a larger space such that all pairs of values are present at least once

I am trying to write a function that will accept a list of N lists and returns a list of N-tuples that represent all pairs of values from the original N lists at least once. To illustrate with an ...
3
votes
1answer
208 views

How to create a Poincare disk type kaleidoscope in Mathematica?

Creating a Kaleidoscope in Mathematica is not a new topic at all, examples can be found from the links like: Wolfram reference and Wolfram demonstrations. My question is how to create Poincare disk ...
2
votes
1answer
135 views

Neighbourhood - Calculations

SeedRandom[0]; n = 5; (m = N @ RandomInteger[{1, 3}, {n, n}]) // MatrixForm result1 = MeanFilter[m, 1] // MatrixForm ...
9
votes
5answers
385 views

Repeating Digits

I have written ...
2
votes
3answers
62 views

Reconstructing an expression [duplicate]

I have a nested expression like this one expr = Tan[Sin[Cos[x]]]; I can deconstruct it with ...
4
votes
3answers
543 views

computing gaussian curvature

Can gaussian curvature K be computed from WolframAlpha or any other available Mathematica ...
10
votes
5answers
730 views

How to deal with recursion formula in Mathematica?

In engineering problems, I am always seeing many recursion formula. For instance, In the book "The NURBS book", I discovered many recursion formula Fibonacci ...
3
votes
2answers
220 views

A problem about recursion formula of deCasteljau algorithm

I use mathematica to realize the deCasteljaul algorithm $$\vec{P}_{k,i}(u_0)=(1-u_0)\vec{P}_{k-1,i}(u_0)+u_0\vec{P}_{k-1,i+1}(u_0)$$ The graphics that deCasteljaul algorithm generated as below: ...
11
votes
2answers
219 views

Temporal database reconstruction in mathematica

<EDIT> after some internet research I found the database domain that deals with this kind of thing: Temporal Databases. I think my question therefore becomes how to reconstruct a temporal ...
8
votes
3answers
302 views

Random Integer Sequences

I want to construct a random square matrix in the following manner: a) Three states [0 | 1 | 2] are repeated ...
14
votes
2answers
442 views

Better way to test that a matrix is upper-triangular?

Today, I got to thinking about how to test that a matrix was upper-triangular. So I had a try at it. Algorithm $\quad \quad a_{ij}=0 $ Or $i \leq j$ $\Rightarrow$ $True$ My solution is ...
5
votes
2answers
170 views

Graph expansion on Mathematica

Is there a way by which Mathematica can be given a graph as an input and be asked to find its expansion? Note: By "expansion" I mean the quantity called "isoperimetric number" or "Cheeger constant", ...
9
votes
3answers
914 views

An inverted pyramid

I want to draw a pyramid approximately like this ...
9
votes
5answers
710 views

Coalition Games

Suppose an election produces the following result: result = {{"a", 120}, {"b", 80}, {"c", 50}, {"d", 30}}; Letters are parties and numbers seats. To form a ...
11
votes
7answers
656 views

Splitting strings into letter keys and integers

I have strings of the following form: string = "ABC123DEFG456HI89UZXX1"; Letter keys of variable lengths are followed by (positive) integers. I want to get this ...
9
votes
4answers
307 views

Replacing matrix values

I want to find the n largest values in a matrix and replace all others with zero. The solution I found uses ReplaceAll and becomes very slow as the size of ...
18
votes
3answers
447 views

How to generate a blank crossword sheet?

I attempted to generate a blank crossword sheet. My method is by combining the rows and columns as shown on the graph below. However, some of the across and ...
9
votes
2answers
213 views

Extracting values with multiple keys

I want to extract sorted data from a huge database based upon two (or more) keys in a very timely manner. Here is a reproducible toy example for two keys only: ...
5
votes
1answer
131 views

How to make a case insensitive sorted list and rename the file names of a given folder?

Suppose I had about 500 .JPG and .jpg files in my folder "c:\images\". How to ask ...