CSCI 375 Homework #2
.pdf
keyboard_arrow_up
School
CUNY John Jay College of Criminal Justice *
*We aren’t endorsed by this school
Course
380
Subject
Computer Science
Date
May 11, 2024
Type
Pages
4
Uploaded by SargentBatPerson1055 on coursehero.com
Nicholas Reyes
CSCI 375-
February 24, 2024
Homework #2 (Due by Feb 29, 2024): Exercise Problems for Chapter 3 (3.1 ~ 3.5), Chapter 4
(4.1 ~ 4.6)
3.1 Using the program shown in Figure 3.30, explain what the output will be at LINE A.
The parent value for “LINE A” would have an output of 5. The child “value” initially starts off
as 5 in the beginning of the code used in figure 3.30. Later on it adds 15, then finishes its job by
returning 0. The parent function waits until the child function is finished in order to execute itself
due to the “wait (NULL)” function. The parent does not change the value of “value” so then
“LINE A” returns 5.
3.2 Including the initial parent process, how many processes are created by the program shown
in Figure 3.31?
The answer is 8 processes are created by the program shown in figure 3.3. Each individual fork()
system call creates a new process which splits into two. The answer would be 7 but the question
says to include the initial parent process so that would make it 8.
3.3 Original versions of Apple’s mobile iOS operating system provided no means of concurrent
processing. Discuss three major complications that concurrent processing adds to an operating
system.
Some of the problems that concurrent processing adds to an operating system is that switching
from one process to the next is time consuming, this requires for the current values to be saved
for the initial process and then the values of the next process to be loaded. Another complication
that becomes evident is if the next process requires a large amount of memory space then the
current process would need to be moved back to the hard disk in order to make room for the
switch, which again is time consuming. And another complication would be
3.4 Some computer systems provide multiple register sets. Describe what happens when a
context switch occurs if the new context is already loaded into one of the register sets. What
happens if the new context is in memory rather than in a register set and all the register sets are
in use?
If the new context is already loaded into one of the register set, the current register set pointer is
simply changed to point towards the set containing the new context.
If the new context happens to be in memory rather than in a register set and all the registers are
in use, then one of the contexts in the current register sets that are in use have to be moved into
the memory in order for it to take its spot. This takes a little bit more time then if it were to
already be loaded into one of the register sets.
3.5 When a process creates a new process using the fork() operation, which of the following
states is shared between the parent process and the child process?
a. Stack
b. Heap
c. Shared memory segments
The answer is Shared memory segments. Only the memory segments would be shared between
the parent process and the child process because they both access the same memory in order to
perform their tasks.
4.1 Provide three programming examples in which multithreading provides better performance
than a single-threaded solution.
1.
A web server that serves each requests in separate threads
2.
Matrix multiplication where multiple parts of the matrix can be worked on at the
same time
3.
A debugger where one thread is used to monitor user input, another thread runs
the application and another monitors the errors
4.2 Using Amdahl’s Law, calculate the speedup gain of an application that has a 60 percent
parallel component for
(a) two processing cores
(b) four processing cores.
a. With two processing cores we get a speedup of 1.42 times.
S = 40%
N = 2
Speedup = 1/((S)+(1-S/N))
=1/((0.40)+(0.60/2))=1/0.70=1.42
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
Transcribed Image Text
7-a) Danish works as a constructor. Like all constructors, he is also a beer fan. He likes beer so much that has K cups of beer daily. However, having more than K cups doesn't suit him, because the excess beer won't allow him to sleep at night. Danish's working day is divided into N periods. For every period, he knows how many kilobytes of weight he can lift. During each of the periods, Danish can either have or not to have one bottle of beer. If he is having a bottle of beer in some period, the amount of work in this period drops to zero. But he also gets a productivity boost, if he decides to skip beer during a period and the last bottle of beer, he had was no more than D periods ago, the amount of work during such a period is M times the usual.
arrow_forward
Output for Sample Input 1
3+
Copy
arrow_forward
C++
A robot is initially located at position (0; 0) in a grid [?5; 5] [?5; 5]. The robot can move randomly in any of the directions: up, down, left, right. The robot can only move one step at a time. For each move, print the direction of the move and the current position of the robot. If the robot makes a circle, which means it moves back to the original place, print "Back to the origin!" to the console and stop the program. If it reaches the boundary of the grid, print \Hit the boundary!" to the console and stop the program.
A successful run of your code may look like:Down (0,-1)Down (0,-2)Up (0,-1)Left (-1,-1)Left (-2,-1)Up (-2,0)Left (-3,0)Left (-4,0)Left (-5,0)Hit the boundary!
or
Left (-1,0)Down (-1,-1)Right (0,-1)Up (0,0)Back to the origin!
About: This program is to give you practice using the control ow, the random number generator, and output formatting. You may use <iomanip> to format your output. You may NOT use #include "stdafx.h".
arrow_forward
BIRZEIT UNIVERSITY
COMP242 – Project# 2
Buying/Selling Shares of Stocks
Buying and selling shares of stocks of listed companies is a typical task to do
among investors. Of course, this would result in a capital gain (or loss) when the
shares are sold. This is computed as the difference between the shares' selling price
and the price was originally paid to buy it.
When an investor has a single share of stock, the process is easy. However,
when (s)he sells multiple shares of stocks, bought over a period of time and possibly
with different prices, the first step is to identify which shares of stocks are to be
sold. There are two accounting principles (protocols) that are followed depends on
the market of stocks: the shares bought last to be sold first, and the other is to sell
the shares that stayed the longest.
You are required to implement a program to calculate the possible capital
gain/loss using these two protocols. This would facilitate the process for investors
to know which market…
arrow_forward
CODING LANGUAGE: R (similar to python)
R is a programming language for statistical computing and graphics supported by the R Core Team and the R Foundation for Statistical Computing.
The Behdel TestThe Bechdel test asks whether a work of fiction features at least two women who talk to each otherabout something other than a man, and there must be two women named characters.In this mini analysis we work with the data used in the FiveThirtyEight story titled:"The Dollar-And-Cents Case Against Hollywood's Exclusion of Women"https://fivethirtyeight.com/features/the-dollar-and-cents-case-against-hollywoods-exclusion-of-women/Start with loading the packages: fivethirtyeight, tidyverse1. What information does this dataset contain? What commands did you use to see this?For our purposes of analysis we will focus our analysis on movies released between 1990 and 2013.bechdel90_13 <- bechdel %>%filter(between(year, 1990, 2013))2. How many movies are in our filtered data set?The…
arrow_forward
The code box below defines a variable route as a list of directions to navigate a maze. Each instruction is one of the following four basic commands:
• higher. move one step in the positive y direction
• lower: move one step in the negative y direction
• left: move one step in the negative x direction
right: move one step in the positive x direction
●
Define a function move that takes two arguments, a location (as a tuple of x and y coordinates) and an instruction (higher, lower, left, right) as a string. Given the
provided location, it should return the new location (as a tuple of x and y coordinates) when following the specified instruction. If the instruction is invalid, the old
location should be returned.
Use the function move to determine the final position when starting from the point (-2, -1) and following all instructions in the list route. Assign this final position
to the variable final_location.
Reset answer
1 route = ['right', 'higher', 'left', 'lower', 'higher', 'left',…
arrow_forward
Python Language
Q2: Ginormous Campus
The campus is pretty big. There are n buildings scattered around it, numbered from 0 to n-1. These buildings are so far away from each other that the only way to get from one to another is to take a campus bus.
There are m campus bus routes. The i-th one (0 <= i < m) takes you from building u_i to building v_i (but not the other way around). These buses run very frequently.
Professor Zingaro is deciding where to hold his CS lectures. He believes a building x is accessible from a building y if you can get from y to x taking at most two buses. For his students’ convenience, he wants to hold his lectures in the most accessible building. Help him out by telling him how many buildings the most accessible building is accessible from. In addition, list all buildings that are the most accessible.
Input
The first line of the input contains two space-separated integers n and m, denoting the number of buildings and bus routes, respectively.
m lines…
arrow_forward
Remaining Time: 31 minutes, 51 seconds.
¥ Question Completion Status:
What is the error in the below code? Provide your explanation.
#include
using namespace std;
class parent{
private:
int i, j;
public:
parent (int i, int j)
class child: public parent {
public
void show(){
cout<<" i = "<arrow_forward
GRADED ACTIVITY #6 (M8.1): REPETITION CONTROL STRUCTURE (WHILE, DO-WHILE)
Instruction:
A mathematician named Ulam proposed generating a sequence of numbers from any
positive integer N greater than 1 using the following procedure:
If N is 1, stop.
If N is even, replace it with N/2.
If N is odd, replace it with 3 * N + 1.
Continue with this process until N reaches 1.
Here are some examples of the Ulam sequence for the first few integers.
2, 1
3, 10, 5, 16, 8, 4, 2, 1
4, 2, 1
5, 16, 8, 4, 2, 1
6, 3, 10, 5, 16, 8, 4, 2, 1
Write a Java program using while/do-while that accepts as input an integer value N
(assume N> 1) and prints out the Ulam sequence that begins with the input value N.
Sample Input/Output:
Depicted below are sample outputs when the program is executed (the items in bold
characters are input from the user, while the items in bold italic are calculated and
printed by the program):
Input N: 14
Ulam Sequence:
Input N: 5
Ulam Sequence:
5, 16, 8, 4, 2, 1
14, 7, 22, 11, 34, 17,…
arrow_forward
Consider the following code segment and answer questions 14 and 15.
class Point {
public:
Point (double x = -99, double y = -99) { this -> xM = x; this -> yM = y;}
double getx () {return xM; }
double gety () {return yM; }
void setx (double x) {this -> xM = x; }
void sety (double y) {this -> yM = y; }
private:
double xM, yM;
};
14. What is the output of the following code snippet:
Point pl (100);
cout << pl.getx() << "
" << pl.gety();
a. The output of the program is: -99 -99
b. The output of the program is: 100 100
c. The output of the program is: -99 100
d. The output of the program is: 100 -99
e. None of the above. It doesn't compile because constructor of Point needs two arguments.
15. How many times does the constructor of class Point get called by the following code snippet:
Point a (100, 200);
Point b[6];
Point *c = new Point;
Point *d = new Point (300, 400);
a. Four times
b. Three times
c. Nine times
d. Two times
e. None of the above
arrow_forward
Homework 5
CMP 167: Programming Methods I Lehman College, City University of New York
Homework 5-1
I
Write a program with a loop that iterates as long as an int variable called num is less or equal to 50.
Num must be initialized with a value of 1 and incremented by 1 with each iteration.
Each iteration of the loop must print all appropriate sentences for that number according to the following
1. If num is odd,
output: num is an odd number
2. If num is even,
output: num is an even number output: num is divisible by 2
3. If num is divisible by 2,
4. If num is divisible by 5,
output: num is divisible by 5
5. If num is divisible by 8,
output: num is divisible by 8
6. If num is divisible by 11,
output: num is divisible by 11
Please note that your class should be named FirstLoop.
arrow_forward
Sevens rule, zeros drooldef seven_zero(n):Seven is considered a lucky number in Western cultures, whereas zero is what nobody wants to be. We now bring these two opposites briefly together with positive integers that consist of some solid sequence of sevens, followed by some (possibly empty) solid sequence of zeros. Examples of such integers are 7, 77777, 7700000, 77777700, or 700000000000000. A surprising theorem proves that for any positive integer n, there exist infinitely many integers of such seven-zero form that are divisible by n. This function should return the smallest such seven-zero integer.
This exercise is about efficiently generating all numbers of the constrained form of sevens and zeros in strictly ascending order to guarantee finding the smallest working such number. This logic might be best written as a generator to yield such numbers. The body of this generator consists of two nested loops. The outer loop iterates through the number of digits d in the current number.…
arrow_forward
JAVA LANGUAGE
Body Mass Index Version 2.0
by CodeChum Admin
Recall that according to the National Heart, Lung, and Blood Institute of the National Institutes of Health, body mass index (BMI) is a measure of body fat based on height and weight that applies to adult men and women. It is used to monitor one's health by determining whether one is underweight, overweight, has normal weight or is obese. It is computed based as follows (when using standard weight in pounds and height in inches):
BMI = 703 x (weight/(height2))
Furthermore, people with BMI scores that are less than 18.5 are said to be underweight. Those with scores between 18.5–24.9 (inclusive) are of normal weight. Those with scores between 25–29.9 (inclusive) are said to be overweight. And those with scores 30 or higher are obese.
Input
The input is composed of two positive integers representing the weight in pounds and the height in inches.
140·65
Output
A single line containing two values: the computed…
arrow_forward
Problem 2: Write a java program that contains:
a) The method public static int numberOccurrences(int a, int b) which returns an integer
designating the number of appearance of the digit b in the number a. (b must between
0 and 9).
b) Write a test program (main) that asks the user to enter an integer number and a digit
then invokes (calls) numberOccurrences method.
Sample run 1:
Enter a number: 11941.
Enter a digit: 1
The number of appearance of 1 in 11941 is 3
Sample run 1:
Enter a number: 257
Enter a digit: 5
arrow_forward
In C programming language write
Task 2: Hangman gameWrite a terminal based on the game of Hangman. In a hangman game, the player is given a wordthat they need to guess, with each letter of the word represented by an underscore/blank. Theplayer tries to guess a letter of the word by entering it into the terminal. If the letter is correct, theblank corresponding to that letter is filled in. If the letter is incorrect, a part of a stick figure isdrawn. The player has a limited number of incorrect guesses before the stick figure is fully drawnand the game is lost. The player wins the game if they guess all the letters of the word before thestick figure is fully drawn.The program should have an array of possible words to choose from. A different word should berandomly chosen from the array every time we run the program.Others: Do not use GOTO statements
arrow_forward
The card that wins the trick
def winning_card(cards, trump=None):
Playing cards are again represented as tuples of (rank,suit) as in the cardproblems.py lecture example program. In trick taking games such as whist or bridge, four players each play one card from their hand to the trick, committing to their play in clockwise order starting from the player who plays 0irst into the trick. The winner of the trick is determined by the following rules:
If one or more cards of the trump suit have been played to the trick, the trick is won by the highest ranking trump card, regardless of the other cards played.
If no trump cards have been played to the trick, the trick is won by the highest card of the suit of the 0irst card played to the trick. Cards of any other suits, regardless of their rank, are powerless to win that trick.
Ace is the highest card in each suit.
Note that the order in which the cards are played to the trick greatly affects the outcome of that trick, since the 0irst…
arrow_forward
utogwVUfWNJvmW7MGwYrTyRrJDu-ioEw19ELum82_RuHi-A/formResponse?pli=1
Consider a grade-averaging scheme in which the final average of a student's scores is computed differently
from the traditional average if the student has completed a make-up assignment: drop the lowest score and
compute the new average.
The following table shows several example scores and how they would be average using the scheme
described above.
Student Scores
Make-Up Completed?
Final Average
50, 50, 20, 80, 53
No
(50 + 50 + 20 + 80 + 53)/5.0 = 50.6
30, 80, 85, 87
Yes
(80 + 85+ 87)/3.0 = 84.0
75, 85, 10, 60, 90
Yes
(75 + 85+ 60 + 90)/4.0 = 77.5
Consider the following incomplete StudentRecord class. Each studentRecord object stores a list of that
student's scores and contains methods to compute that student's final average.
public class StudentRecord
private int [] scores; // contains scores.length values
// scores.length > 1
// constructors and other data fields not shown
// returns the average (arithmetic mean)…
arrow_forward
Computer Science
using java The program has to evaluate arithmetic expressions using a BST for thatpurpose. The rules are the following:The program asks the user to enter an arithmetic expression in the infixformat. Then the program builds a BST for that expression. After buildingthe BST, a menu will be present to the user allowing him to: traverse the BST in inorder, traverse the BST in postorder, traverse the BST in preorder.Users will choose among the options present. The result will be thedisplay of the original arithmetic expression and the new one thatdepends on the option chosen. The program should repeat as long as theuser wants.
arrow_forward
main.cpp
1 @include
2 using namespace std;
int maxResult()
4-(
int maxVal = 0;
6.
for (int i = 0; i <= n; i += a)
{
for (int j = e; j <= n i;j += b)
!!
10
(float)(n - (i + j)) / (float)(c);
11
float z =
12
if (floor (z)
{
int x = i / a;
int y
13
ceil(z))
14
15
16
j/ b;
max (maxVal, x + y + (int)z);
17
maxVal =
18
19
20
21
22
return maxVal;
23 }
24
int main()
26 {
25
27
28 cout << maxResult( );
29
30
return 0;
31 }
Input
Compilation failed due to following erors)
main.cpp:7:23: error: 'n was not declared in this scope
7 for (int i = 0; i <= n; i t a)
main.cpp:7:31: error: 'a' was not declared in this scope
7 for (int i 0; i <= n; i t a)
main.cpp:9:36: error: 'b' was not declared in this scope
for (int j = 0; j <- n i; j b)
%3D
main.cpp:11:45: error: was not declared in this scope
arrow_forward
Program Specifications Write a program to play an automated dice game that uses two dice (GVDie class provided). The player rolls both dice and either wins one credit, loses one credit, or sets a goal for future rolls. Current round ends when player wins or loses a credit. Game ends when credits are zero.Note: this program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress.Step 0. Read starter template and do not change the provided code. Two GVDie objects are created. A random seed is read from input and passed to a die. This supports automated testing and creates predictable results that would otherwise be random. Starting credits is read from input.
Step 1 . Roll both dice. Player wins one credit by rolling 7 or 11. Player losses one credit by rolling 2, 3, or 12. Otherwise, credits do not change and the player's goal is set to the dice total. The player's…
arrow_forward
C++
Create a class Student that contains three members: roll no, name and mark, and three functions. Write a first inputStudent() function to get data of student class. Write a second getMark() function that returns a student’s mark. Write a third display() function that displays a student’s data. In a main() function, you need to declare 40 students and get data of all students by using inputStudent() function. And also use a pointer array to keep all students by mark greater than 50 and display the searching data of each student in that pointer array (Use the access operator -> to access a pointer points to member functions of the Student class).
arrow_forward
Write VBA CODE FOR THE FOLLOWING PROBLEM
Problem:
The Worksheet named Grades contains a place for students to record the grades they have received in their classes. Students put the number of each letter grade received in the B column. (For example, the worksheet currently shows that the student has taken 9 classes and made five As, one B, one C, one D, and one F as grades. You need to write a program that reads the grades from the worksheet and uses a function to calculate the student’s GPA. For this problem you can assume that all classes are worth the same number of credit hours. The function should send back the GPA to the calling procedure. The procedure will then put up a message box that gives the student their GPA and a message about their GPA, all in one message box. The message should be “You qualify for an internship” if the student has a GPA of at least 3.0. It should be “You’re in the danger zone” if the GPA is between 2.0 and 3.0. And it should be “You are on…
arrow_forward
Lucky Pairs
Richie and Raechal are participating in a game called "Lucky pairs" at the Annual Game Fair in their Company. As per the rules of the contest, two members form a team and Richie initially has the number A and Raechal has the number B.There are a total of N turns in the game, and Richie and Raechal alternatively take turns. In each turn, the player's number is multiplied by 2. Richie has the first turn. Suppose after the entire N turns, Richie’s number has become C, and Raechal’s number has become D, the final score of the team will be the sum of the scores (C+D) of both the players after N turns. Write a program to facilitate the quiz organizers to find the final scores of the team. Input and Output Format:The only line of input contains 3 integers A, B, and N.Output a single line that contains the integer that gives the final score of the team which will be the sum of the scores of both the players after N turns.Refer sample input and output for formatting specifications.…
arrow_forward
Please complete the code, in C++ to pass the tests, the first image is the assignment, the second screenshot provides the starter code. The Test case will be:
Sample Test Case:
Enter the size of the board: 7
Enter the number of tests: 500
Enter the random seed: 17
500
248 252
135 239 126
72 188 182 58
36 132 177 124 31
19 71 180 139 71 20
7 45 130 155 105 46 12
arrow_forward
PROGRAMMING LANGUAGE: C++
ALSO PUT SCREENSHOTS OF OUTPUTS
Write c++ code that print summery of exam result and decide either student should have makeup class or not .If more then 30% of class fails in exam it’s mean they need a makeup class otherwise they don’t need any makeup class. For class strength take input from user
arrow_forward
LAB 5.4 Nested LoopsBring in program nested.cpp from the Lab 5 folder (this is Sample Program 5.6from the Pre-lab Reading Assignment). The code is shown below:
// This program finds the average time spent programming by a student
// each day over a three day period.
// PLACE YOUR NAME HERE
#include <iostream>
using namespace std;
int main()
{
int numStudents;
float numHours, total, average;
int student, day = 0; // these are the counters for the loops
cout << "This program will find the average number of hours a day"
<< " that a student spent programming over a long weekend\n\n";
cout << "How many students are there ?" << endl << endl;
cin >> numStudents;
for (student = 1; student <= numStudents; student++)
{
total = 0;
for (day = 1; day <= 3; day++)
{
cout << "Please enter the number of hours worked by student "
<< student << " on day " << day << "." << endl;
cin >> numHours;
total…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- Transcribed Image Text 7-a) Danish works as a constructor. Like all constructors, he is also a beer fan. He likes beer so much that has K cups of beer daily. However, having more than K cups doesn't suit him, because the excess beer won't allow him to sleep at night. Danish's working day is divided into N periods. For every period, he knows how many kilobytes of weight he can lift. During each of the periods, Danish can either have or not to have one bottle of beer. If he is having a bottle of beer in some period, the amount of work in this period drops to zero. But he also gets a productivity boost, if he decides to skip beer during a period and the last bottle of beer, he had was no more than D periods ago, the amount of work during such a period is M times the usual.arrow_forwardOutput for Sample Input 1 3+ Copyarrow_forwardC++ A robot is initially located at position (0; 0) in a grid [?5; 5] [?5; 5]. The robot can move randomly in any of the directions: up, down, left, right. The robot can only move one step at a time. For each move, print the direction of the move and the current position of the robot. If the robot makes a circle, which means it moves back to the original place, print "Back to the origin!" to the console and stop the program. If it reaches the boundary of the grid, print \Hit the boundary!" to the console and stop the program. A successful run of your code may look like:Down (0,-1)Down (0,-2)Up (0,-1)Left (-1,-1)Left (-2,-1)Up (-2,0)Left (-3,0)Left (-4,0)Left (-5,0)Hit the boundary! or Left (-1,0)Down (-1,-1)Right (0,-1)Up (0,0)Back to the origin! About: This program is to give you practice using the control ow, the random number generator, and output formatting. You may use <iomanip> to format your output. You may NOT use #include "stdafx.h".arrow_forward
- BIRZEIT UNIVERSITY COMP242 – Project# 2 Buying/Selling Shares of Stocks Buying and selling shares of stocks of listed companies is a typical task to do among investors. Of course, this would result in a capital gain (or loss) when the shares are sold. This is computed as the difference between the shares' selling price and the price was originally paid to buy it. When an investor has a single share of stock, the process is easy. However, when (s)he sells multiple shares of stocks, bought over a period of time and possibly with different prices, the first step is to identify which shares of stocks are to be sold. There are two accounting principles (protocols) that are followed depends on the market of stocks: the shares bought last to be sold first, and the other is to sell the shares that stayed the longest. You are required to implement a program to calculate the possible capital gain/loss using these two protocols. This would facilitate the process for investors to know which market…arrow_forwardCODING LANGUAGE: R (similar to python) R is a programming language for statistical computing and graphics supported by the R Core Team and the R Foundation for Statistical Computing. The Behdel TestThe Bechdel test asks whether a work of fiction features at least two women who talk to each otherabout something other than a man, and there must be two women named characters.In this mini analysis we work with the data used in the FiveThirtyEight story titled:"The Dollar-And-Cents Case Against Hollywood's Exclusion of Women"https://fivethirtyeight.com/features/the-dollar-and-cents-case-against-hollywoods-exclusion-of-women/Start with loading the packages: fivethirtyeight, tidyverse1. What information does this dataset contain? What commands did you use to see this?For our purposes of analysis we will focus our analysis on movies released between 1990 and 2013.bechdel90_13 <- bechdel %>%filter(between(year, 1990, 2013))2. How many movies are in our filtered data set?The…arrow_forwardThe code box below defines a variable route as a list of directions to navigate a maze. Each instruction is one of the following four basic commands: • higher. move one step in the positive y direction • lower: move one step in the negative y direction • left: move one step in the negative x direction right: move one step in the positive x direction ● Define a function move that takes two arguments, a location (as a tuple of x and y coordinates) and an instruction (higher, lower, left, right) as a string. Given the provided location, it should return the new location (as a tuple of x and y coordinates) when following the specified instruction. If the instruction is invalid, the old location should be returned. Use the function move to determine the final position when starting from the point (-2, -1) and following all instructions in the list route. Assign this final position to the variable final_location. Reset answer 1 route = ['right', 'higher', 'left', 'lower', 'higher', 'left',…arrow_forward
- Python Language Q2: Ginormous Campus The campus is pretty big. There are n buildings scattered around it, numbered from 0 to n-1. These buildings are so far away from each other that the only way to get from one to another is to take a campus bus. There are m campus bus routes. The i-th one (0 <= i < m) takes you from building u_i to building v_i (but not the other way around). These buses run very frequently. Professor Zingaro is deciding where to hold his CS lectures. He believes a building x is accessible from a building y if you can get from y to x taking at most two buses. For his students’ convenience, he wants to hold his lectures in the most accessible building. Help him out by telling him how many buildings the most accessible building is accessible from. In addition, list all buildings that are the most accessible. Input The first line of the input contains two space-separated integers n and m, denoting the number of buildings and bus routes, respectively. m lines…arrow_forwardRemaining Time: 31 minutes, 51 seconds. ¥ Question Completion Status: What is the error in the below code? Provide your explanation. #include using namespace std; class parent{ private: int i, j; public: parent (int i, int j) class child: public parent { public void show(){ cout<<" i = "<
arrow_forward GRADED ACTIVITY #6 (M8.1): REPETITION CONTROL STRUCTURE (WHILE, DO-WHILE) Instruction: A mathematician named Ulam proposed generating a sequence of numbers from any positive integer N greater than 1 using the following procedure: If N is 1, stop. If N is even, replace it with N/2. If N is odd, replace it with 3 * N + 1. Continue with this process until N reaches 1. Here are some examples of the Ulam sequence for the first few integers. 2, 1 3, 10, 5, 16, 8, 4, 2, 1 4, 2, 1 5, 16, 8, 4, 2, 1 6, 3, 10, 5, 16, 8, 4, 2, 1 Write a Java program using while/do-while that accepts as input an integer value N (assume N> 1) and prints out the Ulam sequence that begins with the input value N. Sample Input/Output: Depicted below are sample outputs when the program is executed (the items in bold characters are input from the user, while the items in bold italic are calculated and printed by the program): Input N: 14 Ulam Sequence: Input N: 5 Ulam Sequence: 5, 16, 8, 4, 2, 1 14, 7, 22, 11, 34, 17,…arrow_forwardConsider the following code segment and answer questions 14 and 15. class Point { public: Point (double x = -99, double y = -99) { this -> xM = x; this -> yM = y;} double getx () {return xM; } double gety () {return yM; } void setx (double x) {this -> xM = x; } void sety (double y) {this -> yM = y; } private: double xM, yM; }; 14. What is the output of the following code snippet: Point pl (100); cout << pl.getx() << " " << pl.gety(); a. The output of the program is: -99 -99 b. The output of the program is: 100 100 c. The output of the program is: -99 100 d. The output of the program is: 100 -99 e. None of the above. It doesn't compile because constructor of Point needs two arguments. 15. How many times does the constructor of class Point get called by the following code snippet: Point a (100, 200); Point b[6]; Point *c = new Point; Point *d = new Point (300, 400); a. Four times b. Three times c. Nine times d. Two times e. None of the abovearrow_forwardHomework 5 CMP 167: Programming Methods I Lehman College, City University of New York Homework 5-1 I Write a program with a loop that iterates as long as an int variable called num is less or equal to 50. Num must be initialized with a value of 1 and incremented by 1 with each iteration. Each iteration of the loop must print all appropriate sentences for that number according to the following 1. If num is odd, output: num is an odd number 2. If num is even, output: num is an even number output: num is divisible by 2 3. If num is divisible by 2, 4. If num is divisible by 5, output: num is divisible by 5 5. If num is divisible by 8, output: num is divisible by 8 6. If num is divisible by 11, output: num is divisible by 11 Please note that your class should be named FirstLoop.arrow_forwardSevens rule, zeros drooldef seven_zero(n):Seven is considered a lucky number in Western cultures, whereas zero is what nobody wants to be. We now bring these two opposites briefly together with positive integers that consist of some solid sequence of sevens, followed by some (possibly empty) solid sequence of zeros. Examples of such integers are 7, 77777, 7700000, 77777700, or 700000000000000. A surprising theorem proves that for any positive integer n, there exist infinitely many integers of such seven-zero form that are divisible by n. This function should return the smallest such seven-zero integer. This exercise is about efficiently generating all numbers of the constrained form of sevens and zeros in strictly ascending order to guarantee finding the smallest working such number. This logic might be best written as a generator to yield such numbers. The body of this generator consists of two nested loops. The outer loop iterates through the number of digits d in the current number.…arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education