Solutions_Assignment #1_Max 503
.docx
keyboard_arrow_up
School
Illinois Institute Of Technology *
*We aren’t endorsed by this school
Course
503
Subject
Computer Science
Date
Feb 20, 2024
Type
docx
Pages
7
Uploaded by DukeFlagJaguar44 on coursehero.com
Max 503
Assignment #1
Instructions: Note 1: there may be many ways to solve a problem in R. As we progress, we will demonstrate progressively better ways to solve some of the same problems. R programmers may differ as to what constitutes “better.” Some may prefer elegance while others prefer speed or ease of comprehension. At this point, I recommend that you consider whether a solution seems optimal, but don’t worry too much about it. Getting a correct answer in any one of multiple possible ways is the most important outcome. Note 2:
When an analysis includes more than a few simple steps, it becomes difficult to remember what you’ve done and even more difficult for others to understand it. In the worst case, you might perform analyses with undocumented console commands or out-
of-sequence commands run from a code file. In that case, the code file doesn’t reflect the true sequence, and the results may be non-reproducible. If you run the code again, you may get a different answer because the steps are in a different order. Luckily, the R community has demonstrated leadership in addressing these issues and provided many powerful tools that can help. R Notebooks
is one of those tools. R Notebooks
Offered in RStudio, R Notebooks provide R Markdown live inside the RStudio environment. A notebook includes any text
you want to write, along with R code
and the *results*
of R code. When you execute R code in a notebook, the results are shown inside your document.
Here are a few tips: o
You can create Section headers by using 1, 2, or 3 number signs (#) at the beginning of a line, followed by text. For example: #1 R code …………
#2 R code ………… (you follow the sequence like this)
o
You can format text with asterixes. Use *one for italic*, or **two for bold**.
1
Max 503
Assignment #1
o
You can include R code by clicking the *Insert Chunk* button on the toolbar. Put your code between the lines with "```".
A Basic R Notebook To create an R Notebook, launch RStudio Select File
New File
R Notebook
The default R Notebook template will appear as an untitled document, as shown in the following figure: Note a few features of notebooks. At the top is a section with document settings, demarcated with three dashes, specifying the title (“R Notebook”, which you may edit
) and the targeted output format (HTML). Below that, there are two paragraphs of text, followed by an R code chunk with a gray background. 2
Max 503
Assignment #1
The R code chunk may contain any R commands, and they will be executed when the green “Run” (triangular) icon is clicked (or choose Code—Run Region—Run Current Chunk from the menu or shortcut keys). When we run the chunk in the default notebook, it plots the cars data set and shows the result inline in RStudio, as shown in the following figure :
Inline plot shown in the notebook by clicking the green “Run current chunk” icon
3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
10-
Which of the following statements about time complexity analysis is true?
a.
It is impossible for a correct algorithm to have a time complexity so high that it is impractical to use, but the program may feel "sluggish".
b.
When there are multiple possible input values with the same size, we usually only care about the input values which would cause the algorithm to run the fastest.
c.
Two different algorithms that solve a particular program correctly can have different time complexities.
d.
We usually only care about the behaviour of the algorithm as the input size gets small.
arrow_forward
Explain (the idea, when and how to use) the divide and conquer technique for algorithm design. Also, using this technique, design an algorithm for a problem of your choice.
arrow_forward
Q1
Dan has a list of problems suitable for the assignment. The difficulties of these problems are stored in a list of integers a. The i-th problem’s difficulty is represented by a[i] (the higher the integer, the more difficult the problem).
Dan is too busy eating saltines to worry about assignment decisions, so he asks Michael to select at least two problems from the list for the assignment. Since there are many possible subsets of the problems to consider and Michael has a life, he decides to consider only sublists (definition follows) of the list of problems.
To make grading the assignment easier, Michael wants to pick problems that don’t vary too much in difficulty. What is the smallest difference between the difficulties of the most difficult selected problem and the least difficult selected problem he can achieve by selecting a sublist of length at least 2 of the original list of problems?
Definition: A sublist of a list a is any list you can obtain by removing some (possibly 0)…
arrow_forward
S. Loyd popularised the 8 puzzle game in the 1870s. It is played on a three-by-three matrix with eight pieces labelled 1 through eight and one blank space. Your objective is to organise the tiles in the correct sequence. You may move any accessible tile horizontally or vertically (but not diagonally) into the vacant rectangle. Create a programme that uses the A* algorithm to answer the riddle. Begin by prioritising the sum of the number of movements made to reach this board location plus the number of tiles in the incorrect position. (Keep in mind that the number of movements you must make from a particular board location is at least as large as the number of possible moves.)Consider replacing other functions for the number of tiles in the incorrect location, such as the total of the Manhattan distances from each tile to its right position or the sums of these distances' squares.
arrow_forward
Solve the problems below. Copy the description of your Ferris wheel in the text box and include that as part of your initial Discussion post in Brightspace. Using "copy" from here in Mobius and "paste" into Brightspace should work.
Hint: This is similar to Question 48 in Section 8.1 of our textbook. We covered this section in "5-1 Reading and Participation Activities: Graphs of the Sine and Cosine Functions" in Module Five. You can check your answers to part a and c to make sure that you are on the right track.
A Ferris wheel is 30 meters in diameter and completes 1 full revolution in 8 minutes.
A Ferris wheel is 30 meters in diameter and boarded from a platform that is 1 meter above the ground. The six o’clock position on the Ferris wheel is level with the loading platform. The wheel completes 1 full revolution in 8 minutes. The function h(t)ht gives a person’s height in meters above the ground tt minutes after the wheel begins to turn.
a. Find the amplitude, midline, and…
arrow_forward
Solve the problems below. Copy the description of your Ferris wheel in the text box and include that as part of your initial Discussion post in Brightspace. Using "copy" from here in Mobius and "paste" into Brightspace should work.
Hint: This is similar to Question 48 in Section 8.1 of our textbook. We covered this section in "5-1 Reading and Participation Activities: Graphs of the Sine and Cosine Functions" in Module Five. You can check your answers to part a and c to make sure that you are on the right track.
A Ferris wheel is 30 meters in diameter and completes 1 full revolution in 8 minutes.
A Ferris wheel is 30meters in diameter and boarded from a platform that is 1 meter above the ground. The six o’clock position on the Ferris wheel is level with the loading platform. The wheel completes 1 full revolution in 8 minutes. The function h(t)ht gives a person’s height in meters above the ground tt minutes after the wheel begins to turn.
a. Find the amplitude, midline, and…
arrow_forward
Correct answer will be upvoted else downvoted. Computer science.
single activity, you should supplant each digit d of the number with the decimal portrayal of integer d+1. For instance, 1912 becomes 21023 in the wake of applying the activity once.
You need to find the length of n subsequent to applying m tasks. Since the appropriate response can be exceptionally enormous, print it modulo 109+7.
Input
The main line contains a solitary integer t (1≤t≤2⋅105) — the number of experiments.
The main line of each experiment contains two integers n (1≤n≤109) and m (1≤m≤2⋅105) — the underlying number and the number of activities.
Output
For each experiment output the length of the subsequent number modulo 109+7.
arrow_forward
[Job sequencing using deadlines]Let us suppose that there are n jobs (J1, J2, … Jn) each of which takes a unit oftime to be processed by a machine and there is just one single machine to processthe jobs. Let us suppose that (d1, d2, d3, …dn) are the deadlines in units of times to complete the jobs and (p1, p2, p3, …pn) are the profits earned if the jobs are processed within the deadline. The objective is obviously to select those jobs and complete them within their deadlines so that maximum profit is earned.Design a greedy method to obtain the optimal sequence of jobs that will earnmaximum profits. Demonstrate it on the case where there are four jobs, with n = 4,deadlines given by (d1 = 2, d2 = 1, d3 = 3, d4 = 1) and profits earned as (p1 = 100,p2 = 20, p3 = 50, p4 = 40).
arrow_forward
1.10 LAB: Warm up: Basic output with variables
This zyLab activity prepares a student for a full programming assignment. Warm up exercises are typically simpler and worth fewer points than a full programming assignment, and are well-suited for an in-person scheduled lab meeting or as self-practice.
A variable like user_num can store a value like an integer. Extend the given program as indicated.
Output the user's input. (2 pts)
Output the input squared and cubed. Hint: Compute squared as user_num * user_num. (2 pts)
Get a second user input into user_num2, and output the sum and product. (1 pt)
Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs.
Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64 !! Enter another integer: 5 4 + 5 is 9 4 * 5 is 20
arrow_forward
During problem solving, do you use primarily algorithms or heuristics? What are the advantages of each?
arrow_forward
Design Assignment: Texas Hold 'em poker game
2 to 8 human or computer players
Each player has a name and stack of chips
Computer players have a difficulty setting: easy, medium, hard
Summary of each hand:
Dealer collects ante from appropriate players, shuffles the deck, and deals each player a hand of 2 cards from the deck.
A betting round occurs, followed by dealing 3 shared cards from the deck.
As shared cards are dealt, more betting rounds occur, where each player can fold, check, or raise.
At the end of a round, if more than one player is remaining, players' hands are compared, and the best hand wins the pot of all chips bet so far.
Create the Use Cases for this system
Create a Use Case diagram for this system
arrow_forward
a)(i). People often use recursive algorithms. Discuss the difference between direct recursion and indirect recursion. In which situations would a direct or indirect recursion be a better choice to use?(ii). Two Level 200 IT students, James and Morris, are discussing how to compare two algorithms for solving a given problem. James suggests that they should use the execution times of the algorithms as criterion; but Morris insists that they should use the number of statements the algorithms execute as criterion. (α)Explain the reasons why both criteria they are considering are not good for comparing algorithms. (β)Recommend an ideal solution/criterion that they should rather use for comparing algorithms. Give a practical example to illustrate your answer.
arrow_forward
1) The question copy pasted down below code in python.
The term "expert system" can refer to a computer program that is capable of decision making and can be used for diagnostics and classification. Furthermore, since the underlying knowledge used by the system is typically provided by a human expert, a rudimentary expert system is a relatively simple project. For this assignment, you will practice with branching control structures by creating your own expert system that uses user input to "guess" film titles. Please note that, if your submission cannot identify the movie in 7 guesses or less, then your questions are poorly constructed and will be penalized. As a clarifying example, the partial transcript such an expert system might follow for the subgenre of "Animated Christmas Special" could be as follows (with user input in red): In order to complete this task, you will need to: choose two movie "subgenres" from http://www.filmsite.org/subgenres2.html¹ choose at least ten movies for…
arrow_forward
Please help step by step with R program with a final code for understanding thank you. ASAP
arrow_forward
Please help step by step with R program with a final code for understanding thank you.
arrow_forward
17. What is the critical path for the following diagram ?
Start F K I End
Start F G J End
Start F G I End
Start A B C D End
Start A B E C D End
Start F K I G J End
arrow_forward
Performance Task: Search for other problems considered solvable and unsolvable. Show proof that each of these problems is either Turing acceptable or not.
arrow_forward
PERFECT CUBES AND SQUARES PROBLEMSThe product of some integer with itself is called a perfect square. A perfect cube isthe result of multiplying an integer three times by itself. Assume that a perfectcube greater than 2000 is considered a large perfect cube, the ones between 500and 2000 (inclusive) are medium perfect cubes and the ones below 500 are smallprefect cubes. A perfect cube is associated with a perfect square if the sameinteger is either cubed or squared i.e. the perfect square 4 (2x2) is associated withthe perfect cube 8 (2x2x2)Write a program which:1. Asks the user to enter a perfect square.2. Finds the associate perfect cube.3. Determines whether the found perfect cube is small, medium or large.4. Informs the user if the input is not a perfect square.5. Ask the user is they would like to continue or not. Use a while loop to dothis.For example,Example 1:Enter perfect square: 36216 is a small perfect cubeContinue (Y/N): YEnter perfect square: 4008000 is a large perfect…
arrow_forward
Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science.
You are given a variety of n integers a1, a2, ..., an, and a set b of k unmistakable integers from 1 to n.
In one activity, you might pick two integers I and x (1≤i≤n, x can be any integer) and allocate ai:=x. This activity should be possible provided that I doesn't have a place with the set b.
Compute the base number of tasks you ought to perform so the cluster an is expanding (that is, a1<a2<a3<⋯<an), or report that it is inconceivable.
Input
The principal line contains two integers n and k (1≤n≤5⋅105, 0≤k≤n) — the size of the exhibit an and the set b, individually.
The subsequent line contains n integers a1, a2, ..., an (1≤ai≤109).
Then, at that point, if k≠0, the third line follows, containing k integers b1, b2, ..., bk (1≤b1<b2<⋯<bk≤n). On the off chance that k=0, this line is skipped.
Output
In case it is difficult to make the exhibit…
arrow_forward
what is memoization and when/how can it be useful in solving a given problem?
arrow_forward
Correct answer will be upvoted else Multiple Downvoted. Computer science.
Berland local ICPC challenge has quite recently finished. There were m members numbered from 1 to m, who contended on a problemset of n issues numbered from 1 to n.
Presently the article is going to happen. There are two issue creators, every one of them will tell the instructional exercise to precisely k back to back errands of the problemset. The creators pick the section of k continuous errands for themselves autonomously of one another. The sections can correspond, meet or not cross by any means.
The I-th member is keen on paying attention to the instructional exercise of all continuous errands from li to ri. Every member consistently decides to pay attention to just the issue creator that tells the instructional exercises to the most extreme number of assignments he is keen on. Leave this greatest number alone artificial intelligence. No member can pay attention to both of the creators, regardless of…
arrow_forward
Correct answer will be upvoted else downvoted. Computer science.
You are given two positive (more noteworthy than nothing) integers x and y. There is a variable k at first set to 0.
You can play out the accompanying two kinds of tasks:
add 1 to k (i. e. allocate k:=k+1);
add x⋅10p to k for some non-negative p (i. e. relegate k:=k+x⋅10p for some p≥0).
Track down the base number of tasks depicted above to set the worth of k to y.
Input
The main line contains one integer t (1≤t≤2⋅104) — the number of experiments.
Each experiment comprises of one line containing two integer x and y (1≤x,y≤109).
Output
For each experiment, print one integer — the base number of tasks to set the worth of k to y.
arrow_forward
10.Good day, please help me with this. will give helpful rating after. promise This subject is on Numerical Methods and Analysis. Write your complete solution to the given problem below.
arrow_forward
It is the best algorithm design method when the solution to a problem can be viewed as the result of a sequence of decisions.
a
Dynamic Programming
b
Greedy method
c
Divide and Conquer
d
Incremental
arrow_forward
0 Judging rules can be difficult – even for an objective computer program. In football (orsoccer as some people call it), the official rules say that the referee can allow the playto continue ‘when the team against which an offence has been committed will benefitfrom such an advantage’ and penalize ‘the original offence if the anticipated advantagedoes not ensue at that time’ (Federation Internationale de Football Association 2003).How would you implement this rule? What difficulties are involved in it?
arrow_forward
Exercise
The Strategy pattern is a design pattern used to encapsulate different behaviors and/or algorithms. The idea is to allow you to swap those strategies at will during the execution of a program. The architecture of the program remains the same. According to Gamma et al., the “Strategy pattern is intended to define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.” In this assignment, you are to design, then implement a program in C++ that uses the Strategy pattern to solve the following problem. You would like to provide a system for your customer that allows them to choose any one of three types of sorting algorithms (bubbleSort, insertionSort, quickSort, ). Each of these sort algorithms provides a function ( sort() ) to sort information. You would like to allow your customer to select any one of these sorting algorithms and allow them to change the default algorithm dynamically.…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
A+ Guide To It Technical Support
Computer Science
ISBN:9780357108291
Author:ANDREWS, Jean.
Publisher:Cengage,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Related Questions
10-
Which of the following statements about time complexity analysis is true?
a.
It is impossible for a correct algorithm to have a time complexity so high that it is impractical to use, but the program may feel "sluggish".
b.
When there are multiple possible input values with the same size, we usually only care about the input values which would cause the algorithm to run the fastest.
c.
Two different algorithms that solve a particular program correctly can have different time complexities.
d.
We usually only care about the behaviour of the algorithm as the input size gets small.
arrow_forward
Explain (the idea, when and how to use) the divide and conquer technique for algorithm design. Also, using this technique, design an algorithm for a problem of your choice.
arrow_forward
Q1
Dan has a list of problems suitable for the assignment. The difficulties of these problems are stored in a list of integers a. The i-th problem’s difficulty is represented by a[i] (the higher the integer, the more difficult the problem).
Dan is too busy eating saltines to worry about assignment decisions, so he asks Michael to select at least two problems from the list for the assignment. Since there are many possible subsets of the problems to consider and Michael has a life, he decides to consider only sublists (definition follows) of the list of problems.
To make grading the assignment easier, Michael wants to pick problems that don’t vary too much in difficulty. What is the smallest difference between the difficulties of the most difficult selected problem and the least difficult selected problem he can achieve by selecting a sublist of length at least 2 of the original list of problems?
Definition: A sublist of a list a is any list you can obtain by removing some (possibly 0)…
arrow_forward
S. Loyd popularised the 8 puzzle game in the 1870s. It is played on a three-by-three matrix with eight pieces labelled 1 through eight and one blank space. Your objective is to organise the tiles in the correct sequence. You may move any accessible tile horizontally or vertically (but not diagonally) into the vacant rectangle. Create a programme that uses the A* algorithm to answer the riddle. Begin by prioritising the sum of the number of movements made to reach this board location plus the number of tiles in the incorrect position. (Keep in mind that the number of movements you must make from a particular board location is at least as large as the number of possible moves.)Consider replacing other functions for the number of tiles in the incorrect location, such as the total of the Manhattan distances from each tile to its right position or the sums of these distances' squares.
arrow_forward
Solve the problems below. Copy the description of your Ferris wheel in the text box and include that as part of your initial Discussion post in Brightspace. Using "copy" from here in Mobius and "paste" into Brightspace should work.
Hint: This is similar to Question 48 in Section 8.1 of our textbook. We covered this section in "5-1 Reading and Participation Activities: Graphs of the Sine and Cosine Functions" in Module Five. You can check your answers to part a and c to make sure that you are on the right track.
A Ferris wheel is 30 meters in diameter and completes 1 full revolution in 8 minutes.
A Ferris wheel is 30 meters in diameter and boarded from a platform that is 1 meter above the ground. The six o’clock position on the Ferris wheel is level with the loading platform. The wheel completes 1 full revolution in 8 minutes. The function h(t)ht gives a person’s height in meters above the ground tt minutes after the wheel begins to turn.
a. Find the amplitude, midline, and…
arrow_forward
Solve the problems below. Copy the description of your Ferris wheel in the text box and include that as part of your initial Discussion post in Brightspace. Using "copy" from here in Mobius and "paste" into Brightspace should work.
Hint: This is similar to Question 48 in Section 8.1 of our textbook. We covered this section in "5-1 Reading and Participation Activities: Graphs of the Sine and Cosine Functions" in Module Five. You can check your answers to part a and c to make sure that you are on the right track.
A Ferris wheel is 30 meters in diameter and completes 1 full revolution in 8 minutes.
A Ferris wheel is 30meters in diameter and boarded from a platform that is 1 meter above the ground. The six o’clock position on the Ferris wheel is level with the loading platform. The wheel completes 1 full revolution in 8 minutes. The function h(t)ht gives a person’s height in meters above the ground tt minutes after the wheel begins to turn.
a. Find the amplitude, midline, and…
arrow_forward
Correct answer will be upvoted else downvoted. Computer science.
single activity, you should supplant each digit d of the number with the decimal portrayal of integer d+1. For instance, 1912 becomes 21023 in the wake of applying the activity once.
You need to find the length of n subsequent to applying m tasks. Since the appropriate response can be exceptionally enormous, print it modulo 109+7.
Input
The main line contains a solitary integer t (1≤t≤2⋅105) — the number of experiments.
The main line of each experiment contains two integers n (1≤n≤109) and m (1≤m≤2⋅105) — the underlying number and the number of activities.
Output
For each experiment output the length of the subsequent number modulo 109+7.
arrow_forward
[Job sequencing using deadlines]Let us suppose that there are n jobs (J1, J2, … Jn) each of which takes a unit oftime to be processed by a machine and there is just one single machine to processthe jobs. Let us suppose that (d1, d2, d3, …dn) are the deadlines in units of times to complete the jobs and (p1, p2, p3, …pn) are the profits earned if the jobs are processed within the deadline. The objective is obviously to select those jobs and complete them within their deadlines so that maximum profit is earned.Design a greedy method to obtain the optimal sequence of jobs that will earnmaximum profits. Demonstrate it on the case where there are four jobs, with n = 4,deadlines given by (d1 = 2, d2 = 1, d3 = 3, d4 = 1) and profits earned as (p1 = 100,p2 = 20, p3 = 50, p4 = 40).
arrow_forward
1.10 LAB: Warm up: Basic output with variables
This zyLab activity prepares a student for a full programming assignment. Warm up exercises are typically simpler and worth fewer points than a full programming assignment, and are well-suited for an in-person scheduled lab meeting or as self-practice.
A variable like user_num can store a value like an integer. Extend the given program as indicated.
Output the user's input. (2 pts)
Output the input squared and cubed. Hint: Compute squared as user_num * user_num. (2 pts)
Get a second user input into user_num2, and output the sum and product. (1 pt)
Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs.
Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64 !! Enter another integer: 5 4 + 5 is 9 4 * 5 is 20
arrow_forward
During problem solving, do you use primarily algorithms or heuristics? What are the advantages of each?
arrow_forward
Design Assignment: Texas Hold 'em poker game
2 to 8 human or computer players
Each player has a name and stack of chips
Computer players have a difficulty setting: easy, medium, hard
Summary of each hand:
Dealer collects ante from appropriate players, shuffles the deck, and deals each player a hand of 2 cards from the deck.
A betting round occurs, followed by dealing 3 shared cards from the deck.
As shared cards are dealt, more betting rounds occur, where each player can fold, check, or raise.
At the end of a round, if more than one player is remaining, players' hands are compared, and the best hand wins the pot of all chips bet so far.
Create the Use Cases for this system
Create a Use Case diagram for this system
arrow_forward
a)(i). People often use recursive algorithms. Discuss the difference between direct recursion and indirect recursion. In which situations would a direct or indirect recursion be a better choice to use?(ii). Two Level 200 IT students, James and Morris, are discussing how to compare two algorithms for solving a given problem. James suggests that they should use the execution times of the algorithms as criterion; but Morris insists that they should use the number of statements the algorithms execute as criterion. (α)Explain the reasons why both criteria they are considering are not good for comparing algorithms. (β)Recommend an ideal solution/criterion that they should rather use for comparing algorithms. Give a practical example to illustrate your answer.
arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
A+ Guide To It Technical Support
Computer Science
ISBN:9780357108291
Author:ANDREWS, Jean.
Publisher:Cengage,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
A+ Guide To It Technical Support
Computer Science
ISBN:9780357108291
Author:ANDREWS, Jean.
Publisher:Cengage,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr