Generate Power Set with Bitwise Operators | Code Tutorial

preview_player
Показать описание

The Code can be found at:

I do not claim to own any of the code explained in the video unless I explicitly mention that I own the code. It is usually inspired by various websites and I have tried to make some of my own changes for the sake of this tutorial.

Send me an email or comment below if you want to be credited.
Рекомендации по теме
Комментарии
Автор

"This is some crazy wodo shit"


LOL, my thoughts exactly when I found just the algorithm for this in a textbook with no explanation. I'm like what kind of wizardry is this. You explained this perfectly and I know I understand it.

funnypolitics
Автор

I am from India and not even my professor and any YouTube channel taught better than u. Appreciated u❤️.
U will have 1M subs in short time thats guaranteed.😉

aaryan
Автор

you cleared all doubts, i was stuck on this problem for 2 days and i was not able to find the best solution for this but you helped just by explaining every little detail of the code, i liked it please upload the videos soon

ritikgupta
Автор

This is my favorite explanation of a computer science topic lol

gg
Автор

Pretty awesome. The example actually helped me to understand that that bitwise operation actually splits combinationIndex into numbers which are greater than 1. For example, combinationIndex 3 generates : 000, 001, 010 and that means first and second character will be printed. Another example: for index : 14 (1110), it generates 0000, 0010, 0100, 1000 and that prints second, third and fourth character if my input set is set of characters.

algorithmimplementer
Автор

It did blow my mind. Thank you for the explanation.

LM-xsqh
Автор

Very helpful video, thanks for sharing!

kartikxramesh
Автор

Sir please explain if condition what we are comparing here?

praveenchandra
Автор

Thankyou so much sir...
It helps a lot...❤️

tanyabharti
Автор

for AND logic gate operation, it is only true if all are 1's not 0's

shashankmurthy
Автор

How can 1<<0 be 1 as shown in the last section 3 & (1<<0) whereas in the middle while doing same for I=0 and j=0 1<<0 is considered as 0 ???

cheshtasharma
Автор

This 5 row code do the same thing. But anyway thx for explanin bin it works ^^

def powerset(s):
x = len(s)
masks = [1 << i for i in range(x)]
for i in range(1 << x):
yield [ss for mask, ss in zip(masks, s) if i & mask]

erdemekinci
Автор

I understood this logic after 2 days, can someone tell me what is my level in coding?

dhananjay
Автор

The complexity of this algorithm is about O(2^n). Is there an algorithm that has something like O(n^2) or better?

koz_iorus
visit shbcf.ru