Question

Problem1 You are choreographing a circus show with various animals. For one act, you are given two kangaroos on a number lineExplanation o The two kangaroos jump through the following sequence of locations Jump 1 Jump 2 Jump3 Jump 4 Kangaroo 2 Jump 3Problem 2 Show that a set S is infinite if and only if there is a proper subset A of S such that there is a one-to-one corres

PLEASE ANSWER QUESTION 1 & 2. ALSO PLEASE SUBMIT CODE + PDF OF REPORT/ASSIGNMENT

Problem1 You are choreographing a circus show with various animals. For one act, you are given two kangaroos on a number line ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location z1 and moves at a rate of vl meters per jump. The second kangaroo starts at location z2 and moves at a rate of u2 meters per jump. You have to figure out a way to get both kangaroos at the same location at the same time as part of the show. If it is possible, return YES, otherwise return NO For example, kangaroo 1 starts at zl = 2 with a jump distance v1 = 1 and kangaroo 2 starts at x2 = 1 with a jump distance of v2-2. After one jump, they are both at z-3.(z1 vl 2+1 x22 1+2), so our answer is YES Input Format A single line of four space-separated integers denoting the respective values of 1, v1, 2, and v2. Constraints OSal z1). Because the second kangaroo moves at a faster rate (meaning v2 > vi) and is already ahead of the first kangaroo. the first kangaroo will never be able to catch up. Thus, we print NO
Problem 2 Show that a set S is infinite if and only if there is a proper subset A of S such that there is a one-to-one correspondence (e.g., one-to- one and onto) between A and S.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

IF YOU HAVE ANY DOUBTS COMMENT BELOW I WILL BE TTHERE TO HELP YOU..ALL THE BEST..

AS FOR GIVEN DATA.

close all
clear
clc

% Processing the input to create a vector
vec = input('Enter the input: ', 's');
vec = strsplit(strtrim(vec));
for i = 1:length(vec)
vec{i} = str2double(vec{i});
end
vec = cell2mat(vec);

% Basically, we need to figure out the value of k such that
% x1 + k*v1 = x2 + k*v2, where k need to be a positive integer (number of jumps)
% This gives, k*(v1 - v2) = (x2 - x1) => k = (x2 - x1)/(v1 - v2)
x1 = vec(1); v1 = vec(2); x2 = vec(3); v2 = vec(4);

if (x1 == x2 && v1 ~= v2) || (x1 ~= x2 && v1 == v2)
disp('NO')
else
if (x1 == x2 && v1 == v2)
disp('YES')
else
k = (x2 - x1)/(v1 - v2);
if floor(k) == k
disp('YES')
else
disp('NO')
end
end
end

Sample Output 1:

Enter the input: 2 1 2 1
YES

Sample Output 2:

Enter the input: 0 3 4 2
YES

Sample Output 3:

Enter the input: 1 1 2 1
NO

I HOPE YOU UNDERSTAND..

PLS RATE THUMBS UP..ITS HELPS ME ALOT..

THANK YOU...!!

Add a comment
Know the answer?
Add Answer to:
PLEASE ANSWER QUESTION 1 & 2. ALSO PLEASE SUBMIT CODE + PDF OF REPORT/ASSIGNMENT Problem1 You are choreographing a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Help with this coding problem. Please in python Thank you You are choreograhing a circus show with various animals. For...

    Help with this coding problem. Please in python Thank you You are choreograhing a circus show with various animals. For one act, you are given two kangaroos on a number line ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location x1 and moves at a rate of v1 meters per jump. The second kangaroo starts at location x2 and moves at a rate of v2 meters per jump. You have to figure...

  • This is my code for my game called Reversi, I need to you to make the...

    This is my code for my game called Reversi, I need to you to make the Tester program that will run and complete the game. Below is my code, please add comments and Javadoc. Thank you. public class Cell { // Displays 'B' for the black disk player. public static final char BLACK = 'B'; // Displays 'W' for the white disk player. public static final char WHITE = 'W'; // Displays '*' for the possible moves available. public static...

  • Hello, Could you please help me code this program in Java? It is important that all...

    Hello, Could you please help me code this program in Java? It is important that all rules are carefully followed. Using the PairOfDice class from PP 4.9, design and implement a class to play a game called Pig. In this game, the user competes against the computer. On each turn, the current player rolls a pair of dice and accumulates points. The goal is to reach 100 points before your opponent does. If, on any turn, the player rolls a...

  • MATLAB only please I am trying to get my getdatafuntion to work. I am also trying to get all my x...

    MATLAB only please I am trying to get my getdatafuntion to work. I am also trying to get all my x's, y's, and v's to popup in the command window so I can put in any value and it will find the value for me using the equation I put in. function project_9_sjl() % PROJECT_9_SJL project_9_sjl() is the driver function for the program. % %    Name: Scott Lawrence %   Date: 3/27/2019 %   Class: CMPSC 200 %   Description: Determine the optimal...

  • please label the first answerand the secone answer. thank you This is a two part question. YOU MUST GET BOTH PARTS C...

    please label the first answerand the secone answer. thank you This is a two part question. YOU MUST GET BOTH PARTS CORRECT TO EARN 5 POINTS PART 1: A firm is considering an unusual project of the selling of a machine today that will result in an immediate flow of $540 Without the use of the machine the firm will incur an annuity of expenditures or outlows of 567 per year that begin at the end of year one, and...

  • Anyone please help me solve the last part to find theortetical of V1 and V2 using the first page ...

    anyone please help me solve the last part to find theortetical of V1 and V2 using the first page type of collision thank you 4. Cartl has a mass of ml and a velocity of v0. Cart2 has a mass of m2 and is stationary. Cartl then hits cart 2. After the collision, the velocity of cartl is vl and the velocity of cart2 is v2. In any collision, what happens to the m Write an equation for the momentum...

  • can you please answer these questions for an assignment Thanks An arithmetic gradient series Select one:...

    can you please answer these questions for an assignment Thanks An arithmetic gradient series Select one: a. starts at zero at the end of the second period and then increases by a constant amount each period. b. starts at zero at the end of the first period and then increases by a constant amount each period. c. starts at zero at the end of the first period and then increases by an increasing amount each period. d. starts at zero...

  • a. You have 5 problems in this assignment. b. G++ compiler will be used to compile...

    a. You have 5 problems in this assignment. b. G++ compiler will be used to compile your source codes. c. Your program will be tested on Ubuntu 16.04. d. You are not allowed to use global variables in your implementation. e. Your program will get two arguments, input and output file names, from the command line: >> Your_Executable INPUT_FILE_NAME OUTPUT_FILE_NAME 1. Given a number ? , we initially have ?+1 different sets which are {0}, {1}, {2}, ... , {?}....

  • Please read the problem carefully and answer the 2 questions below code: /***************************************************************** * Program: palindrome.c...

    Please read the problem carefully and answer the 2 questions below code: /***************************************************************** * Program: palindrome.c * * Purpose: implements a recursive function for determining *   if a string is a palindrome * * Authors: Steven R. Vegdahl, Tammy VanDeGrift, Martin Cenek * *****************************************************************/ #include #include #include /***************************************************************** * is_palindrome - determines whether a string of characters is a palindrome * * calling sequence: *    result = is_palindrome(str, first_index, last_index) * * parameters - *    str - the string to test *    first_index -...

  • FINAL Project 1-) Please submit the solution of your final as Ms-word or PDF document 2-)...

    FINAL Project 1-) Please submit the solution of your final as Ms-word or PDF document 2-) Complete THREE QUESTIONS out of the four exam questions below. 3-) FOR EACH QUESTION, IT IS REQUIRED to include Ms-Word or Pdf file contains the following A. Source file and sample of your output screen shots. B. Up to one page of your program discussion. In the discussion, state the issues that you may have problem with if there is any. Why your program...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT