Is there a quantum circuit (preferably on Quirk as an example) that will enable me to find the maximum from two inputs?


  • input A: 11011
  • input B: 11100

Expected output: 11100

  • 1
    $\begingroup$ Hi and welcome to Quantum Computing SE. Could you please add more details? How to decide which input is the right one? Is there any function you can use for determination of the expected output? $\endgroup$ – Martin Vesely Nov 12 '20 at 7:54
  • $\begingroup$ Maybe this article would be helpful: arxiv.org/abs/quant-ph/9607014 $\endgroup$ – Martin Vesely Nov 12 '20 at 7:55

The easiest way is with a temporary comparison to decide which input to copy over:


If you want it to run without the extra output register, you can instead CSWAP the inputs based on the comparison bit, sorting them. You can't uncompute the comparison bit until you unsort them though.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.