Questions tagged [discrete-mathematics]

NOTE: Only questions about software development related to discrete mathematics are on topic. Discrete mathematics is the branch of mathematics concerned with discrete phenomena – as opposed to continuous phenomena like geometry, real analysis, physics, etc. Typical discrete math topics are discrete probability, combinatorics, graph theory, algorithms and complexity, but also matrices, difference equations, recurrences.

Discrete mathematics is the branch of mathematics concerned with discrete phenomena – as opposed to continuous phenomena such as geometry, real analysis, and physics. Typical discrete math topics are discrete probability, combinatorics, graph theory, algorithms, and complexity, but also matrices, difference equations, and recurrences. Applications abound in computer science, as many computer models are built upon discrete elements.

Questions relating to discrete mathematics must still be programming-related. Questions that are not programming-related may be asked on mathematics.stackexchange.com.

1083 questions
9
votes
1 answer

Enumerate all partial orders

How to efficiently enumerate all partial orders on a finite set? I want to check whether a partial order with specified properties exists. To check this I am going with brute force to enumerate all possible partial orders on small finite sets.
porton
  • 5,214
  • 11
  • 47
  • 95
8
votes
2 answers

PHP take all combinations

I saw this algorithm that will take numbers or words and find all possible combinations And I'm using it, but it does NOT return all "real" combinations. PHP:
Minion
  • 2,497
  • 4
  • 27
  • 29
8
votes
2 answers

Parity of permutation with parallelism

I have an integer array of length N containing the values 0, 1, 2, .... (N-1), representing a permutation of integer indexes. What's the most efficient way to determine if the permutation has odd or even parity, given I have parallel compute of O(N)…
317070
  • 827
  • 6
  • 12
8
votes
6 answers

What is the total number of unique values for a double in the range [0.0, 1.0)?

Random.NextDouble() (a Double from the range [0.0,1.0)) is sometimes multiplied with a large Int64 (let Int64 big = 9000000000L), and the result floored to obtain a random Int64 value larger than what can be obtained from Random.Next() (an Int32…
blizpasta
  • 2,624
  • 3
  • 25
  • 31
8
votes
1 answer

Finding a pattern or formula to convert Sketch shape path points(json format) to svg path

I am trying to find a pattern to convert Sketch shape points(json format) to svg path, as we know sketch files are just zip files, unzipping you will get json files. here are sample json codes { "_class": "triangle", "do_objectID":…
JohnPep
  • 193
  • 1
  • 11
8
votes
4 answers

How do programs like mathematica draw graphs and how can I make such a program?

I've been wondering how programs like mathematica and mathlab, and so on, plot graphs of functions so gracefully and fast. Can anyone explain to me how they do this and, furthermore, how I can do this? Is it related to an aspect or course in…
8
votes
7 answers

Algorithm to detect redundant rules

I am looking for an algorithm to detect redundant rules. Rules have a fixed number of input parameters and each parameter has a distinct domain. Consider three rule parameters Color, Material and Size: Color: Red, Green, Blue Material: Wood, Glass,…
8
votes
3 answers

Algorithm for finding smallest collection of components

I'm looking for an algorithm to solve the following problem. I have a number of subsets (1-n) of a given set (a-h). I want to find the smallest collection of subsets that will allow me to construct, by combination, all of the given subsets. This…
8
votes
10 answers

Finding a Eulerian Tour

I am trying to solve a problem on Udacity described as follows: # Find Eulerian Tour # # Write a function that takes in a graph # represented as a list of tuples # and return a list of nodes that # you would follow on an Eulerian Tour # # For…
james_dean
  • 1,477
  • 6
  • 26
  • 37
7
votes
2 answers

Random Sample of N Distinct Permutations of a List

Suppose I have a Python list of arbitrary length k. Now, suppose I would like a random sample of n , (where n <= k!) distinct permutations of that list. I was tempted to try: import random import itertools k = 6 n = 10 mylist = list(range(0,…
joejoejoejoe4
  • 1,206
  • 1
  • 18
  • 38
7
votes
3 answers

Resource placement (optimal strategy)

I know that this is not exactly the right place to ask this question, but maybe a wise guy comes across and has the solution. I'm trying to write a computer game and I need an algorithm to solve this question: The game is played between 2 players.…
blackened
  • 387
  • 6
  • 16
7
votes
3 answers

All possible subdivisions of a list

I've just written a small recursive programme to generate all the possible subdivisions of a list: def subdivisions(ls): yield [ls] if len(ls) > 1: for i in range(1, len(ls)): for lhs in subdivisions(ls[:i]): …
EoghanM
  • 25,161
  • 23
  • 90
  • 123
7
votes
2 answers

What is the formula to find the different unlabeled trees that can be formed from a given set of nodes?

I am just doing a research on a project and came across a problem. I would be very grateful if anybody could help me out with this. Consider the figure below: Two dots joined by a line results in only one diagram, three dots joined by single lines…
jarus
  • 1,853
  • 11
  • 44
  • 76
7
votes
2 answers

Python set operations - complement union of set

I am in a Discrete Math course and am trying to replicate De Morgan's law of Complement(B union C) = Complement(B) intersect Complement(C). I tried searching for Python's ability to perform a complement on a set, but I didn't see much if…
TimmyTooTough
  • 101
  • 1
  • 1
  • 6
7
votes
3 answers

2D bin packing on a grid

I have an n × m grid and a collection of polyominos. I would like to know if it is possible to pack them into the grid: no overlapping or rotation is allowed. I expect that like most packing problems this version is NP-hard and difficult to…