Suppose Alice has picked three distinct integers and placed them into a stack S in random order.

Question:

Suppose Alice has picked three distinct integers and placed them into a stack S in random order. Write a short, straightline piece of pseudocode (with no loops or recursion) that uses only one comparison and only one variable x, yet that results in variable x storing the largest of Alice’s three integers with probability 2/3. Argue why your method is correct.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Data Structures and Algorithms in Java

ISBN: 978-1118771334

6th edition

Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser

Question Posted: