Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Describing my algorithm

Overview

I'm in a strange place here. I've written an algorithm, and am now not certain how to document it. I'm looking for assistance in turning this logic into a precise description.

Details

I have a method that takes a variable number of groups as input and spits out a large set of results. The number of results varies with the distribution of items in the groups and the number of groups. I can calculate the number of results that will be created as such:

In Psudocode:

(# of groups -1) * (# items in group 1) * (# items in group 2) * ... * (# items in group n)

In English:

The number of groups minus one, times the number of items in group 1, times the number of items in group 2, times the number of items in group 3 ... etc.

Question

Both the pseudocode and English descriptions above seem unwieldy.

How do I more succinctly describe this algorithm? Is there a compact mathematical formula? Or can it be described with more precise words? Better Pseudocode? Any advice would be greatly appreciated.

like image 424
xelco52 Avatar asked Jul 24 '26 16:07

xelco52


1 Answers

You could use the capital Pi notation to express this very neatly. Model the groups as sets and use the cardinality notation to mean # of items in group.

like image 53
Jeff Foster Avatar answered Jul 26 '26 12:07

Jeff Foster