Questions tagged [bitwise]
Bitwise refers to a bitwise operation which operates on one or more bit patterns or binary numerals at the level of their individual bits.
347 questions
1
vote
1
answer
100
views
A Java program for compressing/decompressing files via Huffman algorithms (version 1.1.1)
Intro
(See the version 1.0.0.)
(See the GitHub repository.)
This time I have got rid of some generic classes and adapted the entire code base to deal with byte ...
5
votes
1
answer
464
views
A Java program for compressing/decompressing files via Huffman algorithms (version 1.0.0)
Intro
(See the version A Java program for compressing/decompressing files via Huffman algorithms (version 1.1.1).)
(The full repository is here. It contains also some unit tests that do not fit in ...
2
votes
1
answer
146
views
Huffman code builder in Java - computing prefix codes for arbitrary (generic) alphabets - Take II
Intro
(This is the continuation of HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets.)
(See the GitHub repository.)
This time:
I have fixed the misspelled ...
4
votes
2
answers
359
views
HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets
(See the continuation of this post at HuffmanEncoder.java - computing prefix codes for arbitrary (generic) alphabets - Take II.)
I have this Java implementation of the Huffmann encoding. It looks like ...
7
votes
6
answers
789
views
Computing the smallest number of the form floor(8^N / 7) that is greater or equal to a number
Is there a more direct way (loop-free) to compute this number than computing a level and then going back?
...
3
votes
2
answers
849
views
Three non-negative integer encoding techniques in Java
Intro
In this post, I will present three (3) non-negative integer encoding techniques:
Elias gamma coding
Elias delta coding
Golomb-Rice coding
Code
...
4
votes
0
answers
85
views
SHA1 Algorithm Implementation in Zig
I have implemented the SHA1 algorithm in Zig, as a learning exercise, to teach myself both Zig and the actual algorithm behind SHA1. Now the second part I think I understood well enough. The ...
10
votes
4
answers
1k
views
Linear version of std::bit_ceil that computes the smallest power of 2 that is no smaller than the input integer
I am not looking for feedback on the algorithm itself, but rather on the implementation; things like modern C++20 writing, style, proper ways to test and handle the validity of input (should I be ...
5
votes
5
answers
3k
views
Fast XOR of multiple integers
I need the bitwise XOR (exclusive-OR) of a list of integers (a function that is to ^ as sum is to ...
6
votes
2
answers
333
views
Bit manipulation to find a monochromatic clique on k vertices knowing all on k-1 vertices
I have a very hot segment of code in a large project. I've extracted the relevant segment and a toy example to illustrate it.
The project involves an unavoidable combinatorial explosion related to ...
13
votes
8
answers
2k
views
Counting Occurrences of a Specific 3-Bit Pattern in a Byte Array
I was asked this problem in an interview, and this is the solution I came up with. I was told it's not the most efficient solution, but I can't think of any other solution. This is the problem.
...
6
votes
2
answers
125
views
TypeScript Number Set
I originally premiered this code to the internet in this StackOverflow post, and per a recommendation through one of the comments, I am reposting it here.
I am making a floating-point number set ...
2
votes
0
answers
73
views
A machine learning model for predicting bit strings in Java
I have this GitHub repository (BitPredictor.java). Basically, I tried to harness a machine learning model for predicting bit strings. I have implemented it to the best of my understanding and have ...
5
votes
1
answer
297
views
String character changes (case insensitive) - Go
I saw this question on one of the socials, presented as an Apple interview question. I have had to paraphrase as it was not given in text format. (Credit: Instagram @greghogg5)
Given a string (S) ...
2
votes
0
answers
102
views
Implementing Generic, General, Specific and Portable Bitwise Operations
First my apologies. My mental faculties currently leave rather a lot to be desired and I have thus spend an inordinate amount of time on this pet project of mine, testing myself if you will.
I find it ...