what is the complexity of Bitwise operations( &, |, ^, ~, <<, >> ) ?

thank you in advance.

Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems.
×

# | User | Rating |
---|---|---|

1 | MiFaFaOvO | 3681 |

2 | tourist | 3567 |

3 | Um_nik | 3527 |

4 | ecnerwala | 3458 |

5 | maroonrk | 3409 |

6 | 300iq | 3317 |

7 | Petr | 3272 |

8 | LHiC | 3229 |

9 | Benq | 3226 |

10 | TLE | 3223 |

# | User | Contrib. |
---|---|---|

1 | Errichto | 197 |

2 | antontrygubO_o | 188 |

3 | pikmike | 183 |

4 | Ashishgup | 182 |

5 | vovuh | 179 |

6 | Radewoosh | 167 |

7 | Um_nik | 165 |

8 | tourist | 163 |

9 | McDic | 162 |

10 | Monogon | 158 |

what is the complexity of Bitwise operations( &, |, ^, ~, <<, >> ) ?

thank you in advance.

↑

↓

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jul/03/2020 01:57:15 (i3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

O(1). They are obviously faster than +, -, *, /.

An answer you might want is

O(1) or "constant time", in terms of the number of processor ticks per operation.For a more detailed view, you may also find these tables interesting: gmplib.org/%7Etege/x86-timing.pdf.

How it work?

I mean how it can do it in o(1) ?

The same way it does addition.

For example, "bitwise xor" is binary addition without carry, just as "addition" is binary addition with carry. To wonder how to do one is the same as to wonder how to do the other. If you are interested in the specifics, a google search like this will help.

when you say the complexity of +, -, and two more expensive functions /, * are O(1); so while they are much slower than &,|,^,~,<<,>> so they are O(1) too.but of course when you check them more definitely you can see +, — are O(log) (= log 2 ^ 32 or 64 => 32 or 64), and * is O(log ^ 2) (32 ^ 2 or 64 * 2) and i don't know what "/" does to discuss about the complexity :D.and for this reason you say the processors do about 10 ^ 8 operations per second while it is much more(about 10 ^ 12 i think anyone who knows the exact number plz say it).so you can see using assembly and other low-level languages can cause more optimization(because you declare your own functions and prevent from unnecessary operation)while it causes more more code than usual.