Questions tagged [bit-strings]

Use this tag for questions related to array data structures that compactly store bits.

A bit string (also known as a bit array, bit map, bit set, or bit vector) is an array data structure that compactly stores bits. It can be used to implement a simple set data structure. A bit string is effective at exploiting bit-level parallelism in hardware to perform operations quickly.

A typical bit string stores kw bits, where w is the number of bits in the unit of storage, such as a byte or word, and k is some nonnegative integer. If w does not divide the number of bits to be stored, some space is wasted due to internal fragmentation.

212 questions
12
votes
4 answers

How many bit strings of length 8 start with "1" or end with "01"?

A bit string is a finite sequence of the numbers $0$ and $1$. Suppose we have a bit string of length $8$ that starts with a $1$ or ends with an $01$, how many total possible bit strings do we have? I am thinking for the strings that start with a 1,…
11
votes
2 answers

Injection from binary strings with $i$ bits to $i+1$ bits

I want to find an injection $F$ from binary strings length $n$ with $i$ bits turned on to $i+1$ bits turned on, with the condition that if $F(S)=S'$, then $S'$ can be obtained from $S$ by simply turning one additional bit on. Naturally, it is…
10
votes
1 answer

Counting Binary Strings (No block decompositions)

The main question goes : How many binary strings of length $n$ are there that do not contain an odd string of $0$'s as a maximal substring? (So $1001$ is okay but $10001$ is not) A maximal substring is the substring of maximum length consisting of…
sidhant
  • 300
  • 1
  • 10
9
votes
3 answers

Logic behind bitwise operators in C

I came across bitwise operations in C programming, and I realized that XOR operator can be used to swap 2 numbers in their binary bases. For example let $$i=(65)_{10}=(1000001)_{2}, \text{ and } j=(120)_{10}=(1111000)_{2}$$. Let $\oplus$ be the XOR…
8
votes
2 answers

How do I cook my food efficiently

What is the optimal strategy for flipping N pork tenderloins? The Setup Today, I decided to pan-sear some pork tenderloin. I sliced the piece into $N=15$ roughly identical cylinders and arranged them on the hot pan. After a couple of minutes, it was…
7
votes
2 answers

What is the least prime which has 32 1-bits?

On the many prime number investigation sites across the web I haven't been able to find the answer. Also my math isn't good enough to compute it from first principles. So, what is the least prime that has 32 1-bits? Of course this refers to its base…
6
votes
2 answers

Counting bit strings with given numbers of higher-order bit flips

Background information Bit flips Given a bit string, we say that bit flip happens when $0$ changes to $1$ or $1$ changes to $0$. To find bit flips, we can shift the string by $1$ and xor that new string with the original one. The resulting string…
6
votes
1 answer

What is the max length string that can be formed using k distinct characters so that all of its substrings are unique.

Given k distinct characters , what is the max length string that can be formed using these characters one or more time so that all the sub-string whose size is greater than one are unique. Eg - For k = 3 {a,b,c} A string of max 10 length can be…
6
votes
2 answers

Count number of exact matching sequences

Consider all pairs of binary strings $P$ and $T$. Let the length of $P$ be $n$ and the length of $T$ be $2n-1$. For each such pair, we can check if $P$ is exactly equal to each of the $n$ substrings of $T$ in order from left to right and output a…
user66307
5
votes
2 answers

Bit strings and probability

Given a bit string of length $n$, I should develop a probabilistic algorithm that answers one of the following questions: Does the bit string have more zeros than ones? Does the bit string have more ones than zeros? Does the number of zeros (/ones…
5
votes
3 answers

Let $b_{n}$ denote the number of compositions of $n$ into $k$ parts, where each part is one or two. Find the generating series for $b_{n}$

I am stuck with this combinatorics problems - Let $n$ be a positive integer and let $b_{n}$ denote the number of compositions of $n$ into $k$ parts, where each part is one or two. For example, $(1, 2, 1, 2, 1)$ and $(2, 2, 1, 1, 1)$ are two…
5
votes
2 answers

What is the number of binary strings of length N with exactly R runs of ones, with C total ones?

I'm concerned with the total number of ones, and the total number of runs, but not with the size of any of the runs. For example, $N=8$, $R=3$, $C=5$ includes 11101010, 01101011 among the 24 total possible strings. I can compute these for small $N$…
5
votes
4 answers

Number of q-ary strings of length m which do not contain k consecutive zeros

A finite q-ary-alphabet is given $$A_q = {0,1,2,...,q-1}.$$ Now I am considering the set of all finite strings over the alphabet $A_q$. I am interested on the number $$N(m,k)_{A_q}$$ of strings of length $m$ which do not contain $k$ consecutive…
4
votes
1 answer

Average length of longest duplicated substring in a random binary string of length N

What is the average length of longest substring occurring at more than one position in a uniformly random binary string S of length N ? For example, n answer 1 0/2 2 2/4 3 10/8 4 26/16 For n=4 0000 3 0001 2 0010 1 0011 1 0100 1 0101 …
4
votes
1 answer

Substring of a bit string probability

Given a fixed bit string $A$ of length $k$ and a randomly generated bit string $B$ of length $n > k$, meaning each bit of $B$ has probability $1/2$ to be zero or one respectively, how can one determine the probability that $A$ is a substring of…
Sebastian
  • 435
1
2 3
14 15