Do you know the legend of Flavius Josephus, a historian living in the 1st century, who beat death through his mathematical skills? How did cluster analysis result in effective intervention for the 1854 London cholera outbreak? Do you know how to multiply two numbers represented in Roman numerals without converting them to Hindu-Arabic system? Why is the Hindu-Arabic system better than others (or is it)? Can you prove with a simple visual representation that every odd integer is the difference of two squares?
Let’s discuss these and more!
Representations. The way information is represented plays a crucial role in how we understand it, draw inferences, do computations on it, and organize it. A good representation makes all of these efficient.
A child can add 573 to 287 (chocolates) with minimal effort. Imagine you doing DLXXIII + CCLXXXVII (Hint: the answer is DCCCLX). If basic arithmetic doesn’t cut it for you, think about data structures. Data structures are ways of representing information such that search and retrieval are efficient. Indexes and other storage models are representations that help your database queries run fast. Good feature vectors help in classifying Cats vs Dogs, and detecting spam emails. (But then it’s the huge amount of legitimate email we get which is the bigger problem!)
In short, from Mathematics to Biology to Computer Science, representations are terribly important. And that’s the broad theme of these talks.
The zeroth talk of this series is going to be a generic one, in which I am going to introduce and motivate the idea of representations. I’ll touch upon some history and move on to talk briefly about a few application areas.
I’ll also discuss a bunch of old numerical problems and explain how the right kind of information representation leads to intuitive and efficient ways of solving them. I’ll illustrate the usefulness of binary and other base systems, as well as the power of powers!
Subsequent talks are going to be focused on other ares. I’ll go deeper into some of the specific topics I introduce in the first talk. In any case, we’ll figure it out as we go based on the level of participation and interest.
I plan to keep the first part of each talk less technical so it is more widely accessible, and move on to more technical details, with some code and demos. I’ll add the slide decks and code (Jupyter notebooks) to a repo if anyone wants to take a look later.
2. Who am I?
I’m Sanket. I am a product guy, a data scientist, a mentor,
“strategic thinker”, and an impostor at large.
Products and Data Science at DataWeave. Solving problems
for online retailers and consumer brands.
Working with start ups building data products. Analytics,
Machine Translation, Search, NLP, etc.
Previous Life: Research in Distributed Algorithms and
Complex Adaptive Systems.
Sanket Patil Representations
3. Who am I?
Outside of Work, I have a number of eclectic interests.
I’m an aspiring writer: Writing
I’m part of some experiments around sustainability and
growing food: Tamarind Valley Collective
A few years ago I picked up bird watching.
Website: Where I write about books, tech, and life in general:
Dilettante Diaries
Twitter: @sanketp
Talk to me
I spend some time during weekends giving guidance on product
and tech problems, mentoring, and playing the role of a “sounding
board”. If you think this might be useful for you, click here to talk
to me.
Sanket Patil Representations
4. Why am I doing this?
Over the last 15 years or so I have worked in research labs and
startups thinking deeply about problems in a bunch of
different areas. I want to share some of those learnings with
others.
I have always liked discussing interesting problems and
concepts with others; I think that’s when I learn better.
Also, I suck at doing small talk, but I really love having long
conversations about topics that interest me.
So, this is my way of engaging with people, if you will.
And, look, it’s just fun, so I don’t think it really needs much
justification beyond that.
Sanket Patil Representations
5. Wherefore Representation?
First of all . . .
What on earth does “wherefore” mean? It’s an archaic word that
means: “for what reason / purpose” or simply, “why”.
So, why?
That’s precisely what we want to explore together. Hopefully, that
will be clear through the course of this and subsequent talk.
With all that out of the way, . . .
Sanket Patil Representations
6. . . . let’s begin
The White Rabbit put on his spectacles. “Where shall I begin
please your Majesty?” he asked.
“Begin at the beginning,” the King said gravely, “and go on till
you come to the end: then stop.”
7. Representations
Figure: The Treachery of Images, by Ren´e Magritte
Source: Wikipedia
“But it is a pipe.”
“No, it’s not,” I said. “It’s a drawing of a pipe. Get it? All rep-
resentations of a thing are inherently abstract. It’s very clever.”
8. An Object and its Representation
“It’s quite simple. Who would dare pretend that the rep-
resentation of a pipe is a pipe? Who could possibly smoke
the pipe in my painting? No one. Therefore it IS NOT A
PIPE.”
Sanket Patil Representations
9. An age-old question
Figure: Object and its Representation
Source: Science Direct
Sanket Patil Representations
10. An Object and its Representation
“The shape of an object, the layout of a scene, the sense of a
word, and the meaning of a sentence must all be represented as
spatio-temporal patterns of neural activity.”
Sanket Patil Representations
11. A Word and its Meaning
“I don’t know what you mean by ‘glory’,” Alice said.
Humpty Dumpty smiled contemptuously. “Of course you
don’t—till I tell you. I meant ‘there’s a nice knock-down ar-
gument for you!’ ”
“But glory’ doesn’t mean ’a nice knock-down argument’,” Alice
objected.
“When I use a word,” Humpty Dumpty said, in rather a scornful
tone, “it means just what I choose it to mean—neither more nor
less.”
“The question is,” said Alice, “whether you can make words
mean so many different things.”
“The question is,” said Humpty Dumpty, “Which is to be
master—that’s all.”
Sanket Patil Representations
12. Map and Territory
Figure: “Sylvie and Bruno Concluded”, by Lewis Carroll
Source: Lit2Go
Sanket Patil Representations
13. Figure: “On Exactitude in Science”, by Jorge Luis Borges
Source: KWARC
Sanket Patil Representations
14. This is not a Story
Figure: “Ceci n’est pas un conte”, by Denis Diderot written in 1772.
Source: Goodreads
Sanket Patil Representations
15. Why Representations?
The duality of objects and their representations is well
explored in the arts.
You might have come across concepts such as: “the map is
not the territory”, “the word is not the thing.”
Such symbolism and art and literature and philosophy aside,
the idea of representations is all too pervasive.
It has practical importance in almost every field of scientific
endeavour.
Sanket Patil Representations
16. More Practically: Why Representations?
They are fundamental to the way we understand the world
and navigate through it. They are all pervading: language,
communication, mathematics, biology, systems, machine
learning, . . .
The way information is represented plays a crucial role in how
we understand it, draw inferences, do computations on it, and
organize it. A good representation makes all of these efficient.
Scripts and alphabets help us give concrete form to abstract
thought, and communicate them with each other.
Sanket Patil Representations
17. Calculus helps us measure, compute and reason about real
world quantities such as distance, time, and volume.
Data structures help us represent data, and even abstract
concepts (such as “trust”) such that they can be retrieved
and processed efficiently.
They capture underlying “patterns”. Good representations
essentially have the effect of “disentanglement”.
That is to say they highlight the variances in underlying data
clearly. This is what makes Machine Learning work.
Sanket Patil Representations
18. Prehistory and DNA Sequencing
Recently I’ve been reading a little bit about prehistory and
certain new techniques in DNA sequencing.
These are helping in understanding—well, in a manner of
speaking—who we are and how we came to be.
What were our migration patterns, the movement of
languages and culture.
Now, while all of this is fascinating in itself I was also
pleasantly surprised to know that fairly simple techniques from
machine learning such as principle component analysis
(popularly known as PCA) play a key role in this.
(We will talk about PCA and related techniques in a
subsequent session.)
The long and short of it: the centrality of representations
cannot be overstated.
Sanket Patil Representations
19. This talk · · ·
Somewhat generic. Introduction to the talk series and
motivation for the overall theme.
In the rest of the talk
Examples of representations and how they help solve real
problems
A brief note on number systems (with focus on Roman
numerals)
Some old problems from discrete mathematics (with a new
twist)
I will keep it slightly high level focussing more on the intuition
and less on rigour
Might be quite basic for many of you; but hopefully you’ll still
find it enjoyable and may even get a new insight or two.
Sanket Patil Representations
20. Rest of the Talk Series: Three Broad Themes
1 Theme 1: Distributed Data Structures/Algorithms; efficient
storage structures.
2 Theme 2: Information Theory/Machine Learning/Deep
Learning.
3 Theme 3: Game Theory; modelling behaviour; Multi-agent
Systems.
Sanket Patil Representations
22. Visualization in the Time of
Cholera
Figure: John Snow’s original map with clusters
Source: Wikipedia
23. Cholera Epidemic of 1854
One of the first usage of data representation to solve real
world problems in modern times was done in London in 1854.
Prevailing theory: cholera was an airborne disease. A popular
theory called the miasma or miasmatic theory.
Miasma Theory was quite fascinating but equally misguided.
that attributed “bad air” or “pollution” or some evil in the air
to most diseases at the time.
But there was this physician called John Snow, who had a
different hypothesis. He suspected that the cause of Cholera
and resultant deaths are due to contaminated water.
Sanket Patil Representations
24. Data Visualization
John Snow mapped all the cholera cases and related deaths
on and around broad street.
Using basic visualizations he inferred that there are clusters of
cases around water pumps.
This lead to his conclusion that contaminated water might be
the cause for he disease.
He convinced the authorities to remove the handle the pump
at Broad Street. (Today there is a small pump at the same
location commemorating this.)
This resulted in a drop of cholera cases within a few days!
Sanket Patil Representations
25. John Snow didn’t have access to the modern visualization
techniques.
Today we use Voronoi Diagrams or Cluster Analysis to model
such problems (each one a major topic that we can look into
subsequently).
Sanket Patil Representations
27. Voronoi Diagrams
Start with a set of seed points or ”sites” or generators.
Partition the region into a set of cells each one containing a
site into a set of cells each one containing a site (called
Voronoi cells) such that every point within that cell is closer
to the site than it is to any other site.
Imagine these seeds or sites to be important public service
institutions such as hospitals, fire stations, schools, and of
course, water pumps.
In this case we are looking at a plane, but it can be
generalized to higher dimensions as well.
Sanket Patil Representations
30. Two Classes
Figure: Linearly Separable?
Source: Deep Learning Book
Question
Can you draw a straight line through this scatterplot to separate
the two classes? How do we make them linearly separable?
Sanket Patil Representations
31. Two Classes
Figure: Linearly Separable?
Source: Deep Learning Book
Polar Coordinates
The same data points represented using their polar coordinates.
Now, it is straightforward to draw a line through this plane.
Sanket Patil Representations
32. Cartesian vs Polar Coordinates
r = 1
r = 3
r = 9
r = 4
θ = 60
X
Y
Figure: Cartesian and Polar Coordinates
Sanket Patil Representations
33. Cartesian to Polar and Back
Step 1: Cartesian to Polar
Visualize a bunch of (well, lots of them, infinitely many)
concentric circles with different radii. Each of the dots and
triangles shown in the first figure lie on one of these circles.
The radius of the circle on which a data point lies is its r
polar coordinate and the angle that the ray from the origin
passing through this point forms with the x-axis is its θ polar
coordinate.
Step 2: Represent data with new coordinates
Think of r and θ as your new x and y, and scatter the dots
and triangles on this new plane.
What you get is something similar to second figure with the
two types of points more or less neatly separated.
Sanket Patil Representations
34. Intuition
The underlying process or the function (which is not known to
us a priori) that generated the data was not linear. Therefore,
you can’t use a linear function (a straight line) to separate
them.
They are not linearly separable in the Cartesian space.
However, you can clearly see that the two classes of data
points fall in two roughly separate circular or quadratic spaces.
By using polar coordinates in Cartesian space, we are
transforming the space in such a manner that now we are able
to disentangle the two sets of data points.
Sanket Patil Representations
35. Dimensions: Lower to Higher to Lower
Representation Learning
This happens a lot in machine learning (and especially deep
learning) wherein you represent data points in a different kind of
space—sometimes higher dimensions and sometimes reduced
number of dimensions—depending on where a model can learn
better representations such that it’s “easier” for it to separate
classes.
Dimensionality Reduction
Dimensionality reduction techniques are also used a lot to
represent data in lower number of dimensions which carry the most
distinctive information, while reducing noise. Example: Principal
Component Analysis
The above description is quite hand wavy, of course, but we will
learn about some of these techniques with more rigour in
subsequent talks.
Sanket Patil Representations
37. Solving an Infinite Series using a Geometric Representation
Figure: A Geometric Series
Source: Mathematical Association of America
Sanket Patil Representations
38. Sum of Odd Numbers
Figure: Visual Proof of Sum of Odd Numbers Theorem
Source: Wikipedia
Sanket Patil Representations
39. A Tweet sized proof for an old identity
Sanket Patil Representations
40. Representation: More Examples from Different Disciplines
Calculus as a language to represent continuous quantities.
The Talking Drums of Africa: long distance language and
cultural communication.
Morse code as an efficient way of encoding and transmitting
information
Language Models: Representing redundancy and capturing
statistics inherent to languages
Representing trust over the Internet: Blockchains (powered by
Merkle Trees)
Representing “Meaning”: word embeddings, speech vectors,
image embeddings.
· · ·
Sanket Patil Representations
41. Numbers
“There are 10 kinds of people in the world.
Those that understand binary,
those that don’t,
and those that didn’t expect this joke to be in ternary.”
42. Roman vs Hindu-Arabic
Think
What are the main differences between Roman and
Hindu-Arabic numeral systems?
Is arithmetic more difficult with Roman numerals in
comparison with Hindu-Arabic numerals?
What made the Hindu-Arabic system superior and/or popular?
Sanket Patil Representations
43. Friends, Romans, countrymen · · ·
· · · lend me a hand in doing basic arithmetic;
Addition
What is DLXXIII + CCLXXXVII?
Question
How do you add two numbers represented in Roman numerals
without converting them to the decimal form?
Sanket Patil Representations
44. Before that: Underlying Principles
Think about how Roman number are constructed.
Not a positional system. No place value. Only face value.
Additive system. To go from one number to the next, you
stick an I in front.
Numerals are ordered in non-increasing order. You add them
up to get the final number.
A bunch of numerals to indicate bigger numbers.
However, it is also subtractive, but that is to manage “short
cuts”.
When a numeral has to be repeated more than 3 times, a
short cut is used. E.g., XL instead of XXXX.
If a smaller numeral comes before a larger one, together they
form a group and is treated as such.
If you keep that in mind, you will see that a Roman
representation is an additive system with individual numerals
(including short cut groups) are sorted in non-increasing order.
Sanket Patil Representations
45. It’s simple(r)
Roman Arithmetic can be built easily on top of these principles.
A Four Step Algorithm
Let’s add IV and IX
1 Expand: IV → IIII, IX → VIIII, and so on.
2 Append: IIIIVIIII
3 Sort (non-increasing): VIIIIIIII
4 Contract: VIIIIIIII → VVIII → XIII
Exercise: Think
How do we do subtraction?
What about multiplication and division?
Sanket Patil Representations
46. Number Systems: Some Observations
There is nothing sacrosanct about the decimal system that we
are used to except that it’s convenient and widely used.
Similarly, there’s nothing sacrosanct about the binary system
either.
There are other kinds of number systems and bases that can
be very useful in certain applications
We will see some examples next.
Sanket Patil Representations
47. Three Problems from Discrete
Mathematics
1 A Geometric Problem
2 A Survival Problem
3 A Weight Problem
48. Problem 1: Lines in a Plane
Maximum Number of Regions
Suppose you have a pizza and a sharp knife. (If you don’t fancy
pizza, consider a chapati or a plain dos´e.) What is the maximum
number of slices that you can get by making 1, 2, 3, or in the
general case, n, straight cuts on the surface of the pizza (or
equivalent)?
Sanket Patil Representations
50. What happens when a new line is added?
1
8
7
6
5
43
10
2
L1
L2
L3
L4
New region formed by L3 common
to both L1 and L2
New region formed
by L4 common
to both L1 and L2
New region formed
by L4 common
to both L2 and L3
New region formed
at the boundary
New region formed
at the boundary
Figure: Number of regions added when a new line is added
Sanket Patil Representations
51. Key Insights
Every new line added to the plane meets each of the existing
lines exactly once.
A new line (L4) in the previous figure) “cuts” the region on
either side of a previous line in two when it intersects with it:
once as it “enters” and once as it “exits”.
However, the number of regions does not increase as 2n
because there are “common” regions formed between pairs of
previous lines, as you can see in the figure.
Thus,if there are k lines previously, the k + 1th line adds k + 1
new regions.
What does that tell us?
Sanket Patil Representations
53. Aside: Can you prove this?
Theorem (Sum of first n natural numbers)
1 + 2 + · · · + n = n×(n+1)
2
You can use the good old proof by induction, of course. But
it’s boring.
Sanket Patil Representations
54. Gauss’ Trick
Sum of first n natural numbers.
1 + 2 + 3 + · · · + (n − 2) + (n − 1) + n
+
n + (n − 1) + (n − 2) + · · · + 3 + 2 + 1
=
(n + 1) + (n + 1) + · · · + (n + 1) + (n + 1) + (n + 1)
=
n · (n + 1)
But since we have taken the sum twice, we just halve it to get:
n·(n+1)
2
Sanket Patil Representations
55. Problem 2: The Josephus Problem
Roman-Jewish war; Jews were surrounded by Romans;
preferred suicide to getting captured.
Scheme: Form a circle. Start from position 1. Kill every
second person alive.
Josephus Flavius — a historian — didn’t want such a thing.
In the original story, he and a co conspirator found suitable
places in the circle by quickly solving the problem mentally
and survived.
What we are going to look at is one variant of the problem.
Sanket Patil Representations
57. Let’s look at a few cases
n w(n)
1
2
3
4
5
6
7
8
1
1
3
1
3
5
7
1
1
2
3 2
1
3
1
4 2
1
1
5
4 3
2
1
6
5
4 3
2
3
3
5
7
9
11
13
15
1
9
10
11
12
13
14
15
16
Figure: The survivor w(n) for different values of n
Sanket Patil Representations
58. Do you see a pattern?
It’s obvious that under the given conditions, all even
numbered people get killed in the first round. So the survivor
is always found in an odd numbered position.
Something interesting is happening for certain values of n
such as 1, 2, 4,etc, (marked with the golden yellow line).
w(n) is always 1 for these n.
These are powers of 2. So, when n = 2m, m >= 0 it looks like
w(n) = 1 regardless of m.
Between two golden yellow lines—that is between two groups
of powers of 2—survivor number increases by 2 before
“wrapping around” to 1.
Sanket Patil Representations
60. Exercises
Alternative Solutions
Can you arrive at a solution by forming recurrence relations?
[Hint: This is a recursive problem if you think about it.]
Can you use modulo arithmetic to arrive at this solution?
[Hint: Look at the circular arrangement. It is amenable to
clock arithmetic.]
Sanket Patil Representations
61. Binary Representation
n = 789 = 29 + 277 = (1100010101)b
w(n) = 2 · 277 + 1 = 555 = (1000101011)b
Figure: You can get the same result by moving MSB to LSB!
Sanket Patil Representations
62. Bitwise Algorithm
While the previous method is fairly straightforward, you can
achieve the same by a couple of simple bitwise operations
regardless of how big n is.
Write a program in your favourite programming language and
verify this for different values of n.
Can you see why this works?
Sanket Patil Representations
63. Proof Sketch
Proof.
1 Any n can be represented in binary as,
n = bmbm−1bm−2 . . . b1b0, where each bi ∈ 0, 1
2 But since n = 2m + l, the Most Significant Bit (MSB),
bm = 1. Thus, n = 1bm−1bm−2 . . . b1b0
3 Similarly, the remaining part l can be represented as,
l = 0bm−1bm−2 . . . b1b0 (E.g. if n = 15, n = 23 + 7,
8 ≡ 1000, and 7 ≡ 0111)
4 Multiply l by 2. This is the same as a left shift operation.
Thus, 2 · l = bm−1bm−2 . . . b1b00 (E.g.,
2 · l = 7 · 2 = 14 ≡ 1110 )
5 2 · l + 1 = bm−1bm−2 . . . b1b01 = bm−1bm−2 . . . b1b0bm
(Since, bm = 1, from Step 2).
6 But 2 · l + 1 = w(n). Thus, w(n) = bm−1bm−2 . . . b1b0bm.
Sanket Patil Representations
64. Exercises
1 We looked at an instance of the problem with a starting
position, p = 1, and a “skip”, k = 2. Generalize Josephus
Problem. Find the solution for any (n, p, k)
2 What is the time and space complexity for the first method?
And for the bitwise method?
3 Can you find a bitwise method for the generalized problem?
4 This is a lovely combinatorial problem. Highly instructive.
Now, think of some applications.
Sanket Patil Representations
65. Problem 3: The Good Old Balance
Figure: Weighing Balance with Weights
Source: Wikipedia
Sanket Patil Representations
66. The Balance Problem
Minimum Number of Weights
Suppose you have a weighing balance that you can use to measure
objects of different weights. Let’s assume that you can measure
only integral weights, not fractional ones. What is the minimum
number of weights required to weigh objects whose weights range
from 1 kg to 40 kg?
Sanket Patil Representations
67. Key Insights
It’s a balance with two pans. Not a spring balance, not a
weighing scale.
That is to say, there are three states in which a weight can be:
left pan, outside, right pan.
You can put weights on either or both pans. Not only can you
add two weights, you can subtract also.
Instead of 40, were you to weigh up to 4, you would do it as
follows: 1, 2 =3 -1, 3, 4 = 3 + 1
Sanket Patil Representations
68. Solution Approach
This is akin to constructing numbers using a ternary number
system. (Yes, there are 10 kinds of people in the world.)
Except, the alphabet is not the usual {0, 1, 2}, but it’s,
α = {−1, 0, 1}
α = {−1, 0, 1} ≡ {left pan, outside, right pan}
So, the original puzzle now reduces to: how many ternary
digits do you need to construct 40 ternary numbers?
40 = 27 + 13 + 9 + 1 = 33 + 32 + 31 + 30
You need the weights, w = {1, 3, 9, 27}
Try a few:
37 = 27 + 9 + 1
35 = 27 + 9 − 1
14 = 27 − (9 + 3 + 1)
Sanket Patil Representations
69. Exercises: Generalizations
We chose n = 40, which could be neatly partitioned using
powers of 3. Can you find the solution for any n?
What happens if only additions were allowed? That is you can
add weights to only one pan.
We solved this for a balance with two pans, k = 2. Can you
solve it for any k? (k = 1 is binary, whereas k = 4 is quinary
— base 5)
This is a fun problem. But can you think of any real
applications?
Sanket Patil Representations
70. And Now for Something
Completely Different
Figure: If you don’t know how to solve a problem, model it using Graph
Theory. Now you have a combinatorial problem. That might not make it
easier to solve the problem, but definitely looks good.
Source: Spiked Math Comics
71. The Balance Problem and DHTs
I can think of at least one extremely interesting application of
the previous problem. It’s in Distributed Hash Tables (DHT).
(If you don’t know what DHT is, don’t worry, we will discuss
it in the next talk.)
The first step is to model the problem as a Graph Theoretic
problem.
Shameless Plug: This problem inspired a part of my research
work in optimal network design during my PhD. I’m going to
briefly present that next.
Sanket Patil Representations
72. (Balanced) Base−b Networks
A class of Distributed Hash Tables inspired by the previous
puzzle.
The construction technique is derived from representations of
numbers in different bases.
Generalization of the well known Chord DHT.
Question
What is the graph theoretic interpretation of additive vs
subtractive weights from the previous problem?
Sanket Patil Representations
73. Representation-1: The Number Line
-13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13
-13 130
Figure: A Segment of the number line
Constructing numbers is the same as moving along a number
line.You can go from 7 to 8, by taking one step to the right.
OTOH, if you want to move to -5, you take 12 steps to the
left.
This is the same as adding or subtracting weights—but you
only have a single weight of 1.
However, here we are looking at a segment of the number line
[−13, 13].
Sanket Patil Representations
74. You can think of the number line as an undirected line graph
extending infinitely. That means you can traverse in both
directions.
It’s a line graph with 27 nodes, with each number forming one
node. The values represent the names of nodes. They can be
anything.
The diameter of this graph is 27—it takes 27 steps to reach
Node 13 from Node -13.
Sanket Patil Representations
75. Representation-2: The ”Wrap around” Number Line
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
0
-13 13
Figure: Number line wrapped around
Let’s wrap around the segment of the number line.
Now suddenly the distances are halved on average.
And you have two ways of reaching a node (a number) from
another — one shorter and the other one longer.
Sanket Patil Representations
77. Construction Algorithm
Let’s add some more short cuts. In fact, let’s use the solution
from the balance problem.
For every node, add an edge to a node that is at a distance of
30, 31, and so on.
Since, 13 = 9 + 3 + 1,from Node 1, we have edges to 2, 4,
and 10.
Do the same at every node. Each node connects to nodes that
are at a distance of 1, 3, and 9 nodes away going clockwise.
When you are done, you will get the network in the next slide.
It’s “balanced” because you can go both forwards and
backwards.
Sanket Patil Representations
79. Reaching from one node to another
In this network, you can reach any node from any other in a
maximum of 3 hops.
For example, the distance between Node 4 and Node -4 on
the circle is −8.
The number -8 is represented in balanced ternary as, (−1)01
or ¯101.
In terms of routing over the balanced ternary network this is
equivalent to taking the first skip (9 steps) backward from 4
to -5; then take the last skip (1 step) forward to reach -4.
Note that this is in principle the equivalent of weighing 8 (9 -
1) in the original problem.
Sanket Patil Representations
81. The Ternary Network
What if you weren’t allowed to subtract? This is the
equivalent of saying edges are now directed.
Ternary networks use the regular ternary alphabet {0, 1, 2}
(no “balanced”).
You can construct directed graphs using a similar technique as
we described before.
Sanket Patil Representations
82. Properties and Generalization
You can generalize this to any base b.
Given a base–b, and a k, k ∈ Z+, the number of nodes that
can be packed in a balanced base–b network is, n = bk.
The diameter of such a network with an alphabet l is,
d = max {|i| ∈ l} · k, where max {|i| ∈ l} ≈ b
2 . That is to say,
d ≈ b
2 logb n.
Given a base–b, and a k, k ∈ Z+, the number of nodes that
can be packed in a network is, n = bk.
The diameter of such a network is, d = max {|i| ∈ l} · k,
where max {|i| ∈ l} = b − 1. That is to say,
d = (b − 1) logb n.
Sanket Patil Representations
84. The Geometry of DHTs
If some of the above is unclear / confusing, don’t worry about
it. We will look at DHTs and their underlying geometrical
structures in more detail in the next session.
We will discuss the interplay of metric spaces, geometry, and
graph theoretic representations as applied to DHTs, which are
underpinning of most distributed systems.
Sanket Patil Representations
85. References and Further Reading
1 A nice intuitive explanation of the Josephus Problem Source:
Numberphile YouTube Channel
2 Concrete Mathematics: A Foundation for Computer Science.
R. Graham, D. Knuth, and O. Patashnik. Addison-Wesley,
Reading, (1989)
3 Designing optimal network topologies under multiple efficiency
and robustness constraints. My PhD Thesis. Source:
Shodhganga
Book Recommendations
Concrete Mathematics. Highly recommended for anyone who
wants to hone mathematical thinking.
What’s the Point of Maths?Informative and entertaining book
for kids and adults alike.
Flatland: A Romance of Many Dimensions by Edwin Abbott
Abbott.
Sanket Patil Representations
86. Thank you!
Feedback
Please feel free to share your feedback with me. over email,
Twitter, LinkedIn, or my website.
License
I’m distributing this under Creative Commons License. Feel free
reuse., modify, distribute this material (with suitable attribution).
If you want the source files, send me an email.
Sanket Patil Representations
87. Fin
“May you live in interesting times.”
[An ancient Chinese curse.]