Question: please code this in java, I am not getting the right answer. 1. Consider a deck of n cards where n is even and each


please code this in java, I am not getting the right answer.
1. Consider a deck of n cards where n is even and each card is uniquely labeled from 1 to n. A shuffle is performed when the deck is divided into two stacks and the stacks are interlaced so that a new stack is formed by alternately taking cards from each stack. 5 5 1 For instance: a deck of ten cards is in order when the card labeled O is on the top of the deck and the card labeled 9 is on the bottom of the deck. Dividing the deck in half produces two stacks of the cards - one stack with cards 0 through 4, the other with cards 5 through 9. Interlacing the stacks produces a deck in the following order: 5 9 The number of times needed to shuffle the deck until it returns to its original order is called the reorder count. Note that the reorder count for a deck of ten cards is six: Shuffle number Original 1 2 3 4 5 6 5 4 2 3 6 1 OON + ON OOO 3 4 5 6 7 NAO - won vo ANWA UOCO - 6 2 7 3 8 4 9 1 8 3 7 2 6 0 0 - 0 M N a CD - 0 ON +-MONO O- NOOOOO 6 3 2 5 6 7 3 5 7 9 5 2 9 9 A deck is modeled by the following incomplete declaration for the Deck class: public class Deck { private int[] cards; public Deck(int numCards) { /* code not shown */ } public boolean inOrder() { /* to be implemented in part (a) */ ) public void shuffle() { /* to be implemented in part (b) */ ) public int reorderCount() { /* to be implemented in part (c) */ } (a) Write the Deck method inorder. Method inorder should retum true if the cards in the deck are in numerical order from 0 to cards.length 1 and should return false otherwise. Cards are in numerical order if cards[k] == k for all 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
