Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(P8.1.3) Suppose we use a vector to represent a deck of n cards. We can cut the deck by taking n/2 cards from the middle

(P8.1.3) Suppose we use a vector to represent a deck of n cards. We can cut the deck by taking n/2 cards from the middle of the deck and putting this half-deck of cards on the top.

In MATLAB Complete the following function to perform this cut:

function sd = cu t ( d ) % Cut a deck o f c a r d s by moving h a l f t h e c a r d s from t h e m i d dle % t o t h e t o p . % d i s a v e c t o r whose l e n g t h i s a m u l t i p l e o f 4 . % sd i s t h e v e c t o r a f t e r c u t t i n g t h e deck d .

Write a script to find out whether the cards in a deck of 52 would cycle back to the original arrangement after repeated cuts as described above. If so, how many cuts are needed? Name your function file as cut.m and the script file to test cut as P813.m. Use vectorized operations instead of loops in function cut.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain employment branding.

Answered: 1 week ago

Question

How flying airoplane?

Answered: 1 week ago

Question

Understand the different approaches to job design. page 167

Answered: 1 week ago