In boolean algebra (P(S),+,.,’) we must have S as 1 and {} as 0 in every possible sub-boolean algebra to hold id elements. We must have S-x for every subset x⊆S to hold complements. It seems like counting every possible partitions in S which is Bell(|S|) if i was not wrong. For example the number of possible sub-boolean algebra of ⟨p({a,b,c,d}),∪,∩⟩ is Bell(4)=15 , is it right ? If it is how we can define a bijection between every n class partitions to boolean algebra with size n ?

# Tag: size

## Union by Rank vs Union by Size

I was studying Union Find, and according to Wikipedia, there are 2 types of Union: Union by rank and Union by size. My question is, what is the runtime different between the 2(if any)?

Intuitively it feels like Union by size would always be better, since each time we merge, we are increasing the rank of every node in one tree by 1, and to minimize overall runtime, we want to increase that one tree to be the one with smaller number of nodes, even though the final tree height might be greater.

But does this make a big difference in runtime?

## How to tell how big size of a buffer to choose? [migrated]

I’m learning about networking with Python and I’ve encountered something I don’t understand.

particularly:

`packet = server.recvfrom(2048)`

I understand that `.recv()`

and `.recvfrom()`

methods determine the size of a buffer to work with but sometimes I see 1024, 2048, … and I can’t seem to connect the dots correctly as to how to know what size of a buffer to choose. The learning resources I’m working with aren’t explaining this and I would like to know.

I also understand that a buffer is a temporary data storage allocated within RAM.

## How to decide sprite size for isometric tile textures?

I want to draw isometric tiles with arbitrary tile sizes. For example above picture there are 1×1 and 3×2 sized tiles.

The textures have arbitrary height because of decoration. `a`

is the tile’s height `b`

is texture’s height `c`

is tile’s width. I can’t figure out what the sprite size should be when I lay these out on screen.

Maybe I should have exact tile sizes cover the whole texture without decorations (a == b). But still what the sprite size should be?

## How to find the size of gaps between entries in an array so that the first and last element of the array is filled and the gaps are all of equal size?

I have an array a of n entries. I need to place a token on the first and last position of that array, so `a[0] = 1`

and `a[n-1] = 1`

.

I now want to place additional tokens into that array with a distance inbetween each index i where `a[i] = 1`

that is greater than 2 (so placing a token on every index is invalid as well as alternating using and not using an entry is invalid). Phrazed differently: I want that `sum(a) < n/2`

. The gap inbetween each token should be the same, so say with an array of size 16,

`a[0] = 1, a[3] = 1, a[6] = 1, a[9] = 1, a[12] = 1, a[15] = 1`

would be a solution with a gap size of 2 (distance of 3).

How do I find all gap sizes that are possible to fill said array with the given constraints?

Imagine a street inbetween two crossroads where a lamppost should be placed on each crossroad and then additional lampposts should be placed equidistant to each other and for some reason only natural number distances are allowed.

(The actual problem I want to solve is where to place Sea Lanterns in my Minecraft Project so do not disregard this problem as an assignment question I want a solution for.)

## How do you find all integers in a sorted array of size n that appear n/k times?

I try to find the solution to this problem: How do you find all integers in a sorted array of size n that appear n/k times in **less** than O(klogn) time?

I could only find this question, where O(klogn) solution was provided.

## What happens if a sender changes the TCP window size over multiple packets that have the same ACK number?

I’m currently doing research on evasion attacks that seek to bypass a Deep-learning based Network Intrusion Detection System.

In order to achieve this, I need to know what the constraints are for the TCP window size field in the TCP packet header. Imagine a client has just sent the last TCP-ACK packet to a server in order to complete the 3-way handshake. He then immediately proceeds to send a GET request to the server (these 2 packets are thus sent one after the other, and contain the same ACK-number).

What happens if the TCP window size in the TCP-ACK packet does not match the window size in the TCP packet containing the GET request? Will the receiver simply observe the last value for the window size that he obtained? Or will there be a violation in the TCP protocol in any way? You can assume that the change in window size is very small, and will not cause the buffer to be full.

More generally, if the client sends N uninterrupted packets (e.g. a heavy-load POST request), can he change the window size in each packet header without repercussions?

## Algorithm for enumerating over all possible pairs (by size)?

**Part A**

What is a possible algorithm for enumerating over all possible pairs, by size, between two enumerable, countably-infinte sets, $ X$ and$ Y$ , of words $ w$ ? Aka, starting with $ |x|min + |Y|min$ as the first element in the enumeration and then carrying on upwards?

**Part B** *(more the question I’m after)*

Is there a way to enumerate over all pairs $ (x,y)$ so that there is one element (in the enumeration) of each size and no more? And, as an extra condition, the enumerator needs to be able to do this encoding of the pairs it enumerates in a way such that it doesn’t "mangle" the pairs. To define mangle: I need to be able to extract (read) $ X$ and $ Y$ back out of any string in the enumeration in poly time (measured in length of string in the enumeration (aka $ |X|+|Y|+or -|bits|$ (depending on encoding used by enumerator)). So, whatever encoding the enumerator uses for its representation of the pairs…one needs to be able to decode that string back into $ (x,y)$ in poly time and there has to be at least one string of each length representing some valid pair. So, given a natural number $ b$ , there is an element of the enumeration that is of length $ b$ and we can decode that string of length $ b$ back into ($ x,y$ ) in less than $ b^k$ time (just as an aside, this also means that $ |x,y|<b^k$ ).

## Does a size large or larger creature killed by Negative Energy Flood rise as a medium sized zombie?

The spell Negative Energy Flood (XGtE pg. 163) states:

A target killed by this damage rises up as a zombie at the start of your next turn.

And also,

Statistics for the zombie are in the Monster Manual.

This seems to imply that the creature killed rises as a zombie *with exactly the statistics stated in the Monster Manual*.

If I kill a gargantuan (or anything larger than medium) creature with Negative Energy Flood, does it rise as a size medium zombie?

## Asymmetric encryption that preserves the plaintext size

I’m looking for an asymmetric encryption algorithm that preserves the size of the thong in clear text. The encrypted file must not be longer than the plaintext file and must not contain any special characters.

Do you have any ideas?