How might you adapt your code to check for sequences

Assignment Help C/C++ Programming
Reference no: EM132248939

void handleReport(UInt8 *buffer, UInt16 length);

A mouse packet has the following structure:

B0: report format
B1: reserved
B2: dX (bits[7:0])
B3: dY (bits[7:0])
B4[1:0]: Left/Right button states
B4[3:2]: dX (bits[9:8])
B4[5:4]: dY (bits[9:8])
B4[7:6]: timestamp (ms) bits[1:0]
B5: timestamp (ms) bits[9:2]
B6: timestamp (ms) bits[17:10]

1) Write one or more functions that extract the mouse deltas, button state, and timestamp from the device.
2) The 18-bit packet timestamp reflects a device timestamp in milliseconds. It will roll over after a few minutes. The host can accommodate a 32-bit timestamp that is updated with values from the incoming packet. Write code that detects the timestamp rollover in the incoming packets, and extends it to 32 bits.

Please complete the following task in C, C++, or Objective-C. You are free to use whatever data structures and design you prefer. Please prioritize optimizing for speed over memory and provide the space and time complexities of your solution in big-O notation.

1) create a deck of cards

2) shuffle the deck of cards, and display the cards (in their shuffled order)

3) reshuffle the deck, and display the cards (in their shuffled order)

4) look for any 2-card sequence that was also present in the previous shuffle. If any are found, print the identified cards and go back to step 3

5) when two back to back shuffles do not contain a duplicate sequence, you're done.

Questions:

1) How might you adapt your code to check for sequences of 3, 4, or more cards from the previous shuffle?

2) How might you adapt your code to check for combinations of N cards, rather than sequences? In a combination, the order of cards does not matter. In a sequence, the order of cards does matter.

3) How might you adapt your code to check for card sequences that were present in any previous shuffle? (i.e. comparing against all previous shuffles, not just the most recent one)

4) Would you do differently if you were now optimizing for memory over speed?

Verified Expert

This solution uses bit extraction techniques from bytes which are provided by buffer to extract Mouse deltas and button states. Since Mouse deltas (dX,dY) are partially separated in different Bytes, they are extracted using functions and then combined with XOR technique. The returned variable isolated the required bits in single variable.Deck of cards implementation in codes is challenging task due to nature of cards and complexity of playing the game. There are numerous approaches to create the deck and then innumerable methods to perform on the cards depending on game being played.

Reference no: EM132248939

Questions Cloud

Advantages or disadvantages to the tool selected : Consider adding further advantages or disadvantages to the tool selected.
How you are going to manage customers expectations : Propose actions you will need to take, in light of those impacts, across your business functions in order to protect your firm's assets.
Determine activity sequencing on projects : Why is it important to determine activity sequencing on projects?
What do you like best about the description : After you post your descriptive paragraph, respond to one other student's description. Can you imagine yourself in the scene described? Why or why not?
How might you adapt your code to check for sequences : How might you adapt your code to check for card sequences that were present in any previous shuffle - How might you adapt your code to check for sequences
Personal information and uses it without your permission : Identity theft occurs when someone steals your personal information and uses it without your permission.
Should the government be able to take your property : Throughout this module, you studied the topic of eminent domain, which is the power to take private property, without permission from the owner.
Development process similarity and or dissimilarity : So far in systems analysis and design , the main focus has been traditional applications at companies we utilize using laptops/computers.
Descriptive comments in your python code : You should submit a script file and a plain text output file (.txt) that contains the test output. Multiple file uploads are permitted.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd