Consider the following page reference string:
1,2,3,5,4,2,1,5,4,2,6,3,1,2,6,3,1,2,4,7,5,4,3,5
How many page faults would occur for replaement by LRU, FIFO, optimal, for
four frames? All frames are
initially empty and first unique page reference causes a page fault. Draw the frame for each page reference.
In: Computer Science
In lecture we discussed Milgram’s 1967 experiment; he picked 300 people at random in Nebraska and asked them to send a letter to a stockbroker in Boston, by way of relaying the letter through a chain of people. The rule is that every person has to know the next person they are sending the 1 letter to on a first name basis. He found that on average each letter went through the hands of 6.4 people before reaching the stockbroker. This is where the expression ”six degrees of separation” comes from. When you tell your friend Dirk about this experiment he says he is not surprised. Dirk says that often, when he tells something to a friend, a couple of days later he hears back the same information from someone else! You decide to test whether the six degrees of separation principle can also be applied to oneself. Let’s imagine that “friendships” on Facebook are a good representation of Milgram’s rule for being on first-name terms with somebody. Assume you are given access to all of the friendship links on Facebook as a graph (where nodes are accounts, and links are “friends”). Design an algorithm to determine if there is a chain of at most 7 friends (because the average number in Milgram’s experiment was 6.4) such that Dirk is friends with both the first and the last person. You may assume that the graph is undirected. For full credit your algorithm should run in time O(m + n) (where n and m are the number of nodes and edges, respectively).
Hint: MODIFY/ USE BFS please helP!
In: Computer Science
In C++
Write a function called findBestSimScore that takes a genome and a sequence and returns the highest similarity score found in the genome as a double.
Note: the term genome refers to the string that represents the complete set of genes in an organism, and sequence to refer to some substring or sub-sequence in the genome.
Your function MUST be named findBestSimScore
Your function should take two parameters in this order:
a string parameter for the genome (complete set of genes)
a string parameter for the sequence (sub-sequence of the genome)
Your function should return the highest similarity score as a double.
Your function should not print anything.
The best similarity scores is [0.0,1.0]
Our sequence is "ACT", which is a string of length 3. That means we need to compare our sequence with all the 3 character long sub-sequences (substrings) in the genome.
Examples:
|
genome sub-sequence |
sequence |
similarity score |
|
|
ATACGC |
ACT |
0.33 |
|
|
ATACGC |
ACT |
0 |
|
|
ATACGC |
ACT |
0.66 |
← findBestMatch returns 0.66, since that is the highest similarity score found |
|
ATACGC |
ACT |
0 |
In: Computer Science
In C++
Write a function called findMatchedGenome that takes three genomes and a sequence and prints the list of matched genomes
Checking these cases must be performed in the order specified
above. First check for empty genomes and sequence followed by a
check for different lengths.
Helper functions (the functions used in your
findMatchedGenome) should be written in the answer
box as well.
For example:
| Test | Result |
|---|---|
//For empty sequence
findMatchedGenome("TTC","GCC","TCT",""); |
Genomes or sequence is empty. |
In: Computer Science
1. For the following C statement, write the corresponding RISC-V assembly code. Assume that the C variables a, b, and c, have already been placed in registers x10, x11, and x12 respectively. Use a minimal number of RISC-V assembly instructions. a = b + (c − 2);
2. Write a single C statement that corresponds to the two RISC-V assembly instructions below. add e, f, g add e, h, e
3. Assume that registers x5 and x6 hold the values 0xA000000000000000 and 0x2000000000000000, respectively.
(1) What is the value of x30 for the following assembly code? add x30, x5, x6
(2) For the contents of registers x5 and x6 as specified above, what is the value of x30 for the following assembly code? sub x30, x5, x6
(3) For the contents of registers x5 and x6 as specified above, what is the value of x30 for the following assembly code? add x30, x5, x6 add x30, x30, x6
In: Computer Science
C PROGRAMMING
Identify and correct the errors in each of the following. [Note: There may be more than one
error in each piece of code.]
a)
if ( sales => 5000 )
puts( "Sales are greater than or equal to $5000" )
else
puts( "Sales are less than $5000 )
b)
int x = 1, product = 0;
while ( x <= 10 ); {
product *= x;
++x;
}
c)
While ( x <= 100 )
total =+ x;
++x;
d)
while ( y < 10 ) {
printf( "%d\n", y );
}
In: Computer Science
you are to write a program in Java, that reads in a set of descriptions of various geometric shapes, calculates the areas and circumferences of the shapes, and then prints out the list of shapes and their areas in sorted order from smallest to largest area. There are four possible shapes: Circle, Square, Rectangle, and Triangle. The last is always an equilateral triangle. The program should read from standard input and write to standard output. The program should read until the end of input is reached, i.e., there is no sentinel value to mark the end of input. There are at most 100 shapes in the input. Each line of the input contains a description of one shape and contains three or four fields separated by a single space. The first field is the name of the particular object (some String). The second field is the type of the shape (one of "Circle", "Square", "Rectangle", or "Triangle" - also a string.) The third field is the size: the radius of the circle, the size of a side of the square, the length of the rectangle, or the size of a side of the triangle. Only the rectangle has a fourth field - the height of the rectangle. The program should read in the input, compute both the area and circumference (or perimeter) of the shape, then sort the shapes by their areas, and print out the shapes in order from smallest to largest area.
Your program must: • Read from standard input and write to standard output. • Work on any size lists up to and including 100, not just the sizes in the example below. • Be efficient. • Have a base class, Shape, for a generic shape. This class must a method, getShape(String desc) which takes the description of a shape (including the name of the object) as described above and returns an appropriate Shape object, a getArea method, a getCircumference method, and a toString method. • Have four subclasses of Shape: Circle, Square, Rectangle, and Triangle.
In: Computer Science
Project title: Automated attendance system using facial recognition system
Describe in detail about this title of project
Research Depth :
- Depth of literature review
- Feasibility of the proposed project
- Implementation plan, methods and strategies
- Incorporating previous comments
In: Computer Science
USING JAVA
Consider the following methods:
StringBuilder has a method append(). If we run:
StringBuilder s = new StringBuilder();
s.append("abc");
The text in the StringBuilder is now "abc"
Character has static methods toUpperCase() and toLowerCase(), which
convert characters to upper or lower case. If we run Character x =
Character.toUpperCase('c');, x is 'C'.
Character also has a static isAlphabetic() method, which returns
true if a character is an alphabetic character, otherwise returns
false.
You will also need String's charAt() method, which returns the
character at a given index in the String. For example,
"Godzilla".charAt(1) returns 'o'.
Write an application as follows:
public static String getNonAlpha() takes a String as parameter,
builds a StringBuilder consisting of only the nonalphabetic
characters in the String, and returns a String based on the
StringBuilder (eg, sb.toString())
public static String getUpper() takes a String, builds a
StringBuilder of the upper case versions of all the alphabetic
characters in the String, and returns a String based on the
StringBuilder.
Write JUnit tests to verify that the above methods are correct
In: Computer Science
Convert the following decimal numbers to 16-bit 2’s complement binary. Display your result in hexadecimal.
a.3030
b.404
c.5050
d.-5050
e.-20000
Show work with steps
In: Computer Science
Programming languages
Explain orthogonality and its importance.
In: Computer Science
For this activity, you will use a top-down approach to create part of a specification for development of a video game. The game can be any genre or theme that you’d like, but for this exercise, you should choose a single platform (smartphones, iPads, PS4, PC, etc.).
Your “roadmap” should cover the following elements:
Cover the specifications for the software needs and requirements
of the project, presented in a top-down approach (starting with the
“big picture” and breaking down from there into the smaller
requirements). Remember that not all software needs are programming
related. For each need or requirement, propose a software solution.
You don’t have to specify the exact program you would use (for
example, you could say “word processor” instead of “Microsoft
Word”).
You may use any requirement tracking technique or tool you like in
building the requirements list. One program, platform, application,
or piece of software can meet many different needs.
In a separate section, you should describe how you will apply
prototyping techniques and analysis tools to improve the final
product. Again, this discussion should consider what, if any, tools
you will need to implement prototyping.
You can structure the specification however you think best, as long
as it maintains a top-down perspective. Suggested formats include a
flowchart style or a tiered outline.
You can refer to online resources or independent research for this
activity.
In: Computer Science
Create a Java method findLongestPalindrome that takes a Scanner scn as its parameter and returns a String. It returns the longest token from scn that is a palindrome (if one exists) or the empty string (otherwise). (Implementation note: Use the built in isPalindrome method. This method calls for an optimization loop.)
Where the isPalindrome Method takes a String s as a parameter and returns a boolean. It returns true if s reads the same forwards and backwards, i.e., is a Palindrome, and returns false otherwise.
I only need help creating the findLongestPalindrome method, I already have the isPalindrome method.
In: Computer Science
Write a program named StringWorks.java that asks the user to input a line of text from the keyboard. Ask the user if they want their answers case sensitive or not. You output should be
You need to remove punctuation. Use the Character.isLetterOrDigit() method.
Sample output:
Please type in a sentence:
I love java, and Java loves me! That is cool, yes?
Do you want case sensitivity? (y/n):
n
List of words: i love java and java loves me that is cool yes
Sorted alphabetically: and cool i is java java love loves me that yes
Sorted backwards: yes that me loves love java java is i cool and
Shuffled: java that cool is i love and loves me java yes
Without duplicates, sorted alphabetically: and cool i is java love loves me that yes
In: Computer Science
Extend the definition of the class clockType by overloading the pre-increment and post-increment operator function as a member of the class clockType.
Write the definition of the function to overload the post-increment operator for the class clockType as defined in the step above.
Main.cpp
//Program that uses the class clockType.
#include <iostream>
#include "newClock.h"
using namespace std;
int main()
{
clockType myClock(5, 6, 23);
clockType yourClock;
cout << "Line 3: myClock = " << myClock <<
endl;
cout << "Line 4: yourClock = " << yourClock
<< endl;
cout << "Line 5: Enter time in the form "
<< "hrs:mins:secs ";
cin >> myClock;
cout << "Line 7: New value of myClock = "
<< myClock << endl;
++myClock;
cout << "Line 9: After increment myClock is "
<< myClock << endl;
yourClock.setTime(13, 35, 38);
cout << "Line 11: Now yourClock = "
<< yourClock << endl;
if (myClock == yourClock)
cout << "Line 13: myClock and yourClock "
<< "are equal" << endl;
else
cout << "Line 15: myClock and yourClock "
<< "are not equal" << endl;
if (myClock <= yourClock)
cout << "Line 17: myClock is less than "
<< "yourClock" << endl;
else
cout << "Line 19: myClock is not less "
<< "than yourClock" << endl;
cout << "Line 20: Testing post increment operator"
<< endl;
yourClock = myClock++;
cout << "Line 22: myClock = " << myClock <<
endl;
cout << "Line 23: yourClock = " << yourClock
<< endl;
return 0;
}
newClock.cpp
//Implementation file newClock.cpp
#include <iostream>
#include "newClock.h"
using namespace std;
//Overload the pre-increment operator.
//Overload the post-increment operator.
//Overload the equality operator.
bool clockType::operator==(const clockType& otherClock)
const
{
return (hr == otherClock.hr && min == otherClock.min
&& sec == otherClock.sec);
}
//Overload the not equal operator.
bool clockType::operator!=(const clockType& otherClock)
const
{
return (hr != otherClock.hr || min != otherClock.min
|| sec != otherClock.sec);
}
//Overload the less than or equal to operator.
bool clockType::operator<=(const clockType& otherClock)
const
{
return ((hr < otherClock.hr) ||
(hr == otherClock.hr && min < otherClock.min) ||
(hr == otherClock.hr && min == otherClock.min
&&
sec <= otherClock.sec));
}
//Overload the less than operator.
bool clockType::operator<(const clockType& otherClock)
const
{
return ((hr < otherClock.hr) ||
(hr == otherClock.hr && min < otherClock.min) ||
(hr == otherClock.hr && min == otherClock.min
&&
sec < otherClock.sec));
}
//Overload the greater than or equal to operator.
bool clockType::operator>=(const clockType& otherClock)
const
{
return ((hr > otherClock.hr) ||
(hr == otherClock.hr && min > otherClock.min) ||
(hr == otherClock.hr && min == otherClock.min
&&
sec >= otherClock.sec));
}
//Overload the greater than or equal to operator.
bool clockType::operator>(const clockType& otherClock)
const
{
return ((hr > otherClock.hr) ||
(hr == otherClock.hr && min > otherClock.min) ||
(hr == otherClock.hr && min == otherClock.min
&&
sec > otherClock.sec));
}
void clockType::setTime(int hours, int minutes, int
seconds)
{
if (0 <= hours && hours < 24)
hr = hours;
else
hr = 0;
if (0 <= minutes && minutes < 60)
min = minutes;
else
min = 0;
if (0 <= seconds && seconds < 60)
sec = seconds;
else
sec = 0;
}
void clockType::getTime(int& hours, int& minutes,
int& seconds) const
{
hours = hr;
minutes = min;
seconds = sec;
}
//Constructor
clockType::clockType(int hours, int minutes, int seconds)
{
setTime(hours, minutes, seconds);
}
//Overload the stream insertion operator.
ostream& operator<<(ostream& osObject, const
clockType& timeOut)
{
if (timeOut.hr < 10)
osObject << '0';
osObject << timeOut.hr << ':';
if (timeOut.min < 10)
osObject << '0';
osObject << timeOut.min << ':';
if (timeOut.sec < 10)
osObject << '0';
osObject << timeOut.sec;
return osObject; //return the ostream object
}
//overload the stream extraction operator
istream& operator>> (istream& is, clockType&
timeIn)
{
char ch;
is >> timeIn.hr; //Step a
if (timeIn.hr < 0 || timeIn.hr >= 24) //Step a
timeIn.hr = 0;
is.get(ch); //Read and discard :. Step b
is >> timeIn.min; //Step c
if (timeIn.min < 0 || timeIn.min >= 60) //Step c
timeIn.min = 0;
is.get(ch); //Read and discard :. Step d
is >> timeIn.sec; //Step e
if (timeIn.sec < 0 || timeIn.sec >= 60) //Step e
timeIn.sec = 0;
return is; //Step f
}
newClock.h
//Header file newClock.h
#ifndef H_newClock
#define H_newClock
#include <iostream>
using namespace std;
class clockType
{
friend ostream& operator<<(ostream&, const
clockType&);
friend istream& operator>>(istream&,
clockType&);
public:
void setTime(int hours, int minutes, int seconds);
//Function to set the member variables hr, min, and sec.
//Postcondition: hr = hours; min = minutes; sec = seconds
void getTime(int& hours, int& minutes, int& seconds)
const;
//Function to return the time.
//Postcondition: hours = hr; minutes = min; seconds = sec
clockType operator++();
//Overload the pre-increment operator.
//Postcondition: The time is incremented by one second.
clockType operator++(int);
// Overload the post increment operator
// Postcondition: Time is incremented by one
second.
bool operator==(const clockType& otherClock) const;
//Overload the equality operator.
//Postcondition: Returns true if the time of this clock
// is equal to the time of otherClock,
// otherwise it returns false.
bool operator!=(const clockType& otherClock) const;
//Overload the not equal operator.
//Postcondition: Returns true if the time of this clock
// is not equal to the time of otherClock,
// otherwise it returns false.
bool operator<=(const clockType& otherClock) const;
//Overload the less than or equal to operator.
//Postcondition: Returns true if the time of this clock
// is less than or equal to the time of
// otherClock, otherwise it returns false.
bool operator<(const clockType& otherClock) const;
//Overload the less than operator.
//Postcondition: Returns true if the time of this clock
// is less than the time of otherClock,
// otherwise it returns false.
bool operator>=(const clockType& otherClock) const;
//Overload the greater than or equal to operator.
//Postcondition: Returns true if the time of this clock
// is greater than or equal to the time of
// otherClock, otherwise it returns false.
bool operator>(const clockType& otherClock) const;
//Overload the greater than operator.
//Postcondition: Returns true if the time of this clock
// is greater than the time of otherClock,
// otherwise it returns false.
clockType(int hours = 0, int minutes = 0, int seconds =
0);
//Constructor to initialize the object with the values
//specified by the user. If no values are specified,
//the default values are assumed.
//Postcondition: hr = hours; min = minutes;
// sec = seconds;
private:
int hr; //variable to store the hours
int min; //variable to store the minutes
int sec; //variable to store the seconds
};
#endif
In: Computer Science