Three useless and sometimes dangerous data structures

Mauro Ghiani
3 min readJan 13, 2019

--

(Part two of three or none)

All cultures of the past have been fascinated by circular structures. Probably because within a close range they have built a one-to-one correspondence with an infinite line of numbers. Or they just have rolled them down a hill and had fun.

Ensō, a circle.

The data structure I have in mind is called “the duhkha circle” from the Sanskrit word “dukka” meaning suffering. It’s very easy to create, it’s just a List that has a particular characteristic, when we arrive at the end it points back to the first element. It creates a circle that can be run without pause.

The duhkha circle.

There’s a circle of friends. One of them wants to pass his suffering to the next who, as a friend, is willing to participate. The receiver can accept the suffering or pass it over to the next friend, and so on so forth. Being a circle it’s quite likely that if nobody chooses to accept it, the suffering goes back to the first one who -naturally- will run again the wheel.

The duhkha circle

The newity is in the function that allows our friends to accept or refute the offer passed. If we start from “a”, we start at position 0. In this case, the probability to pass it is 1. So it will happen anyway. When the next element “b” checks in, his probability is 1/2 and so on. If b scores then he will make “a”’s suffering his own and restart from 0, with probability 1. In the general case the probability function is so defined:

p:[0,1] -> 1/2^n where n is the position of the item starting from a

The probability of an element “k” with position n is, of course, the product of the previous probabilities being each event independent from the other. So we have:

where Ri = 1/2^i

Hence for n quite big, the chance to take suffering from a previous person becomes almost insignificant and the wheel keeps running. On the other hand, when someone scores with probability 1/2^k he has to restart from 1 turning suffering to his own. This part has an established meaning in Buddhist literature where the true nature of human beings is thought to be “anattā” or empty.

For the code, we have simply a class with a private list and a private random class and some methods like Roll, that allows us to check whether the probability is met or not.

The method Run will make a straight list into a circular one, so when we reach the end it points at the first occurence. The parameter N can be set to a high number unless we want the while loop run forever.

So if we want to draw some philosophical point from this structure we have to recall the story of the man who goes to the doctor and the doctor says: “I have some good news and bad news.”
The bad news is that suffering is endless and permeates the whole universe. The good one is that there is no one that suffers.

--

--

Mauro Ghiani
Mauro Ghiani

Written by Mauro Ghiani

A complete non sequitur being.

No responses yet