Draw the ERD in Chen notation corresponding to the following spec:
In: Computer Science
2.26 Homework 2-3 Write a program that prompts the user for a double value representing a radius. You will use the radius to calculate: circleCircumference = 2πr circleArea = Unknown node type: sup πrUnknown node type: sup sphereArea = Unknown node type: sup 4πrUnknown node type: sup sphereVolume = Unknown node type: sup 43πrUnknown node type: sup You must use π as defined in the java.lang.Math class. Your prompt to the user to enter the number of days must be: Enter radius: Your output must be of the format: Circle Circumference = circleCircumference Circle Area = circleArea Sphere Area = sphereArea Sphere Volume = sphereVolume Please make sure to end each line of output with a newline. Please note that your class should be named CircleSphere.
In: Computer Science
Refer to the MediCo case study to answer the following questions
For the To-Be or target architecture of the MediCo change
Question 4
Describe the Application Structure viewpoint in terms of
Stakeholders, Concerns, Purpose and Scope. Which specific core
elements will be included in this viewpoint? (10)
Question 5
Describe the Technology usage viewpoint in terms of Stakeholders,
Concerns, Purpose and Scope. Which specific core elements will be
included in this viewpoint? (10)
Question 6
Describe the Business Process Cooperation viewpoint in terms of
Stakeholders, Concerns, Purpose and Scope. Which specific core
elements will be included in this viewpoint? (10)
In: Computer Science
Written in MIPS assembly language
If given an array which is sorted in ascending order, as well as its length and a target value. You are asked to find the index of this target value in the array using binary search algorithm. Here is an example: array 1, 4, 6, 8, 10, 12 length 6 target 8 2 In this case, the returned result should be assigned to be 3, as array[3] is equal to target. (Note: The target will exist in this array and will not be the first or last element, so there is no need to consider corner cases.) This task should be easy for high-level programming languages, such as C++, Java or Python. However, in this lab, you are asked to implement it in assembly language. Writing programs in a low-level language helps you learn how high-level operations are handled by CPUs.. The size of the sorted array can be fairly large, up to 2048 elements. Please avoid storing temporary variables in data memory (store them in registers instead). In order to simply your future work you the operators and operands that you are allowed to used in your code are limited to those given below: lui, lw, sw, add, sub, addi, srl, sll, and, or, andi, ori, xor, nor, slt, beq, bne, j, t0-t7, s0-s7, zero. Use the template "lab1-template.s" on git and fill the blank starting from "main:" with your code. (Please DO NOT change anything else.) SPIM automatically makes the program counter pc point to the main function when initialized. Your answer should be stored in the address of result, which is 0x10010008 in the template. Check you code with the provided correct pairs of input and output before submission.
In: Computer Science
Hi!
I am trying to compare 2 files, and figure out which lines from infile2 are also in infile1, and output the line index, from infile2, of common lines. I would also want to see which lines (actual string line) are common.
Below is my c++ program, and I am not sure what I am doing wrong. Can someone tell me what I am doing wrong and how it can be fixed?
_________________________________________________________main.cpp
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
using namespace std;
int main(int argc, char *argv[]){
string myString1, myString2;
vector<string> string1, string2;
int i = 0;
int y = 0;
ifstream infile1("LeftShift2.txt");
ifstream infile2("LeftShift3.txt");
if(infile1.is_open() && infile2.is_open())
{
while(!infile1.eof() && !infile2.eof())
{
getline(infile1, myString1);
string1.push_back(myString1);
getline(infile2, myString2);
string2.push_back(myString2);
if(string1.at(i) != string2.at(y))
{
y++;
}
else if(string1.at(i) == string2.at(y))
{
i++;
}
}
cout<<"common line is at: " << y << endl;
cout<<"The common lines are: "<< string2.at(y) << endl;
}
infile1.close();
infile2.close();
return 0;
}
__________________________________________LeftShift2.txt
Adios amiga mia
Bella ciao
Si le monde etait aussi petit
On ne serait pas aussi grandiose
Pays du lait et du miel
Alors, on danse?!
-------------------------------------------------------------LeftShift3.txt
Pays du froid et des montagnes
Burundi
Pays du lait et du miel
Adios amiga mia
-------------------------------------------------------------Output (assume count line start at 0)
common line is at: 2
The common lines are: Pays du lait et du miel
common line is at: 3
The common lines are: Adios amiga mia
In: Computer Science
I have the following code
#include <stdio.h>
#include<string.h>
#define BUFLEN 128
typedef struct {
int numPhrases;
}SyncInfo;
char buffer[BUFLEN] ;
char *phrases[] = {"educated", "educated cat", "educated lion", "serious person" , "serious panda","curious student","curious art student", "obnoxious web developer"};
char localBuffer[BUFLEN];
int allVowelsPresent;
void *checker(void *param) {
int a=0, e=0, i=0, o = 0, u= 0 ;
int* n = (int*)param; // typecasting a void* to int*
//printf("%d\n",*n);
for (int q=0; q< (*n); ++q) { // dereferencing to get the value in int*
strcpy(localBuffer, buffer);
int length=strlen(localBuffer); // strlen is used to determine the length of localBuffer
for(int j=0 ; j<length;j++) // iterating over the whole length of localBuffer and checking if vowel present
{
if(localBuffer[j]=='a') a=1;
else if(localBuffer[j]=='e') e=1;
else if(localBuffer[j]=='i') i=1;
else if(localBuffer[j]=='o') o=1;
else if(localBuffer[j]=='u') u=1;
}
if(a&&e&&i&&o&&u) // if all are present ie none of the value of a, e, i, o ,u is 0 then all vowels are present
allVowelsPresent = 1 ;
else
allVowelsPresent = 0 ;
}
}
int main() {
SyncInfo syncinfo;
syncinfo.numPhrases = 8;
SyncInfo* p = &syncinfo; // defining pointer of type SyncInfo pointing to syncinfo
void* param = &p->numPhrases; // a void pointer as we have to pass void* in checker function
for (int i=0; i<syncinfo.numPhrases; ++i) {
strcpy(buffer, phrases[i]);
checker(param); // main() calling the checker function
printf("result of checking ’%s’: %d\n", phrases[i], allVowelsPresent) ;
}
}
In this code I didn't create a separate thread to do the checking , may someone implement and modify this. Also My checker function should have Syncinfo *s =(Syncinfo*) param please add that modification as well . The code works perfectly fine , just need to make some modification .
In: Computer Science
How does a WAN differ from a LAN and what must be taken into consideration in terms of communications media? Support your rationale.
In: Computer Science
I had a question like this but I forgot to add more and I could not edit it. So here is the new one with more explanation.
I am confused with my Python assignment. I have to write a specification for an email address, Then change the test strings in the code to one string with a valid email address and the other without a valid email address.
This my example/code that it is supposed to be used as a guide:
import re
def text_match(text):
patterns = '^\w+'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!')
print(text_match("My teacher’s email is [email protected]"))
print(text_match("My teacher has no email address"))
For some reason chegg does not want to indent my lines. the if and else statement should be properly indented in the example
In: Computer Science
import java.util.ArrayList;
/*
Lab-08: BinarySearchTree Implementation
Rules:
1. Allow Tester to iterate
through all nodes using the in-order traversal as the
default.
This
means, in Tester the following code should work for an instance of
this class
called bst
that is storing Student objects for the data:
BinarySearchTree_Lab08<String> bst = new
BinarySearchTree_Lab08<String>();
bst.add("Man");
bst.add("Soda"); bst.add("Flag");
bst.add("Home");
bst.add("Today"); bst.add("Jack");
for(String s : bst)
System.out.println(s);
2. You can not
use a size variable to keep track of the number of nodes
*/
/**
* Lab-08: BinarySearchTree Implementation
*
* @author
*
*/
public class BinarySearchTree_Lab08<T> {
//======================================================================================
Properties
private Node root;
//======================================================================================
Constructors
public BinarySearchTree_Lab08() {
}
// Constructor that takes an array of items and
populates the tree
public BinarySearchTree_Lab08(T[] items) {
}
//======================================================================================
Methods
public void add(T data) { // Implement
recursively and do NOT allow duplicates
}
// Returns the traversal of this tree as an
array
public ArrayList<T> preOrder_Traversal()
{
ArrayList<T> data = new
ArrayList<T>();
preOrder_Traversal(root,
data);
return data;
}
private void preOrder_Traversal(Node n,
ArrayList<T> data) {
}
public ArrayList<T> inOrder_Traversal()
{
ArrayList<T> data = new
ArrayList<T>();
inOrder_Traversal(root,
data);
return data;
}
private void inOrder_Traversal(Node n,
ArrayList<T> data) {
}
public ArrayList<T> postOrder_Traversal()
{
ArrayList<T> data = new
ArrayList<T>();
postOrder_Traversal(root,
data);
return data;
}
private void postOrder_Traversal(Node n,
ArrayList<T> data) {
}
public ArrayList<T> breadthFirst_Traversal()
{
return null;
}
// Since this is a binary SEARCH tree, you should
write
// an efficient solution to this that takes advantage
of the order
// of the nodes in a BST. Your algorithm should be, on
average,
// O(h) where h is the height of the BST.
public boolean contains(T data) {
return false;
}
// returns the smallest value in the tree
// or throws an IllegalStateException() if the
// tree is empty. Write the recursive version
public T min() { return min(root); }
// this method is done for you.
private T min(Node n) { // Write this
method.
return null;
}
// returns the largest value in the tree
// or throws an IllegalStateException() if the
// tree is empty. Write the recursive version
public T max() { return max(root); }
// this method is done for you.
private T max(Node n) { // Write this
method.
return null;
}
// Returns whether the tree is empty
public boolean isEmpty() {
return false;
}
// returns the height of this BST. If a BST is
empty, then
// consider its height to be -1.
public int getHeight() {
return -1;
}
// returns the largest value of all the leaves
// If the tree is empty, throw an
IllegalStateException()
// Note, this is different than max as this is the
max
// of all leaf nodes
public T maxLeaf() {
return null;
}
// counts the number of nodes in this BST
public int nodeCount() {
return -1;
}
// returns the "level" of the value in a
tree.
// the root is considered level 0
// the children of the root are level 1
// the children of the children of the root are level
2
// and so on. If a value does not appear in the tree,
return -1
// 15
// / \
// 10 28
// \ \
// 12 40
// /
// 30
// In the tree above:
// getLevel(15) would return 0
// getLevel(10) would return 1
// getLevel(30) would return 3
// getLevel(8) would return -1
public int getLevel(T n) {
return -1;
}
// A tree is height-balanced if at each node, the
heights
// of the node's two subtrees differs by no more than
1.
// Special note about null subtrees:
// 10
// \
// 20
// Notice in this example that 10's left subtree is
null,
// and its right subtree has height 0. We would
consider this
// to be a balanced tree. If the tree is empty, return
true;
public boolean isBalanced() {
return false;
}
//======================================================================================
Inner Node Class
private class Node {
private T data;
private Node left, right;
private Node(T data) {
this.data =
data;
left = right =
null;
}
}
}
In: Computer Science
Python
Design a class named IP_address to represent IP address objects. The IP_addressclass contains the following
For example, consider the following code fragment:
ip_key = '192.168.0.24' data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84), (20, 84)] size = 3 ip = IP_address(key, data_list, size)
The data_list contains a list of tuple objects. Each tuple consists of the time-period value and the packet-size. You should summarize this list and create a frequency list, a sum of the packet-size list and an average of the packet-size list. There are a lot of data for each time-period value. We calculate the total number of bytes that the source host sent for each 10-second interval. For example, the above data_list will be divided into 3 groups, such as (0-9 second), (10-19 second) and (20-29 second)
Therefore, the IP_address object should contain:
This will give
ip_key = '192.168.0.24' data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84), (20, 84)] size = 3 ip = IP_address(ip_key, data_list, size) print(ip.get_ip_address()) |
192.168.0.24 |
And
For example, consider the following code fragment:
ip_key = '192.168.0.24' data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84), (20, 84)] size = 3 ip = IP_address(key, data_list, size)
The data_list contains a list of tuple objects.
Therefore, the IP_address object should contain:
ip_key = '192.168.0.24' data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84), (20, 84)] size = 3 ip = IP_address(ip_key, data_list, size) print(ip.get_freq_list()) |
[[0, 10], [1, 10], [2, 1]] |
|
ip_key = '192.168.0.24' data_list = [(0, 84), (1, 84), (2, 84), (3, 84), (4, 84)] size = 3 ip = IP_address(ip_key, data_list, size) print(ip.get_freq_list()) |
[[0, 5], [1, 0], [2, 0]] |
|
ip_key = '192.168.0.2' data_list = [(33, 60), (34, 64), (34, 1500), (34, 712), (35, 52), (35, 60), (36, 52), (36, 287), (37, 52), (37, 52), (37, 52), (39, 60), (40, 643), (40, 52)] size = 5 ip = IP_address(ip_key, data_list, size) print(ip.get_freq_list()) |
[[0, 0], [1, 0], [2, 0], [3, 12], [4, 2]] |
In: Computer Science
In Java, What is gained by having a Tail reference/pointer in your Linked List?
A. The tail is superfluous and offers no benefits
B. The tail allows us to speed up a few operations and gives us an end point to look for
C.Since we have head and tail we can now do a Binary Search on the list
D. It only makes deleting from the end of the list faster
In: Computer Science
Write a C function hwkOneA, that takes a long int x as well as two integers n and m as arguments, and returns a long int. Here is the function declaration: long int hwkOneA (long int x, int n, int m); The function should swap nibble n and m of a long int x (64-bit integer). A nibble is a four-bit aggregation. For this problem, the index of the most significant nibble is 0, and the index of the least significant nibble is 15 (so 0 , =), loops, switches, function calls, macros, conditionals (if or ?:) You are allowed to use all bit level and logic operations, left and right shifts, addition and subtraction, equality and inequality tests, integer constants (<=255), INT_MIN and INT_MAX, and casting between data types. (20 points).
In: Computer Science
all python
Question One [2 * 2.5]
•The sum
•The difference
•The product
•The average
•The distance (absolute value of the difference)
•The maximum (the larger of the two)
•The minimum (the smaller of the two)
Hint: Python defines max and min functions that accept a sequence of values, each separated with a comma.
Example:
Enter a letter grade: B-
The numeric value is 2.7.
Grade = 99
if Grade>= 90:
print("A")
if Grade >=80 :
print("B")
if Grade >=70 :
print("C")
if Grade >=60:
print("D")
else:
print("Failed")
In: Computer Science
A direct-mapped cache consists of 8 blocks. Byte-addressable
main memory contains 4K blocks of 8 bytes each. Access time for the
cache is 22ns, and the time required to fill a cache slot from main
memory is 300ns. (This time allows us to determine the block is
missing and bring it into cache.) Assume a request is always
started in parallel to both cache and to main memory(so if it is
not found in cache, we do not have to add this cache search time to
the memory access). If a block is missing from cache, the entire
block is brought into the cache and the access is restarted.
Initially, the cache is empty.
-Compute the hit rate for a program that loops 4 times from
locations 0x0 to 0x43 (address 0 hex to address 43 hex).
-Compute the effective access time for this program.
In: Computer Science
Given the header file (grid.h) and the source file,(grid.cpp) create the file trap.cpp. Here are the requirements for trap.cpp:
Write a main program in a file called trap.cpp that solves the following scenario, using your Grid class:
Giant Mole People have risen from their underground lairs and are taking over the world. You have been taken prisoner and placed in an underground jail cell. Since the Mole People are blind and don't know how to build doors, your cell has one open exit (no door). Since you are deep underground, it is completely dark and you cannot see. Your task is to escape your prison to join the human resistance!
Your program should ask the user to input the number of rows, then columns, for the grid. (Note that this is the ONLY keyboard input for this program). Create a grid with the specified number of rows and columns, using the constructor with two parameters -- (this is the one that should automatically create a fenced-in grid containing one exit and a randomly placed mover). Display the initial grid. Since the placement of the exit and the mover is random, execution of this program will look a little different every time. Your task is to escape the trap! You will need to create an algorithm that will instruct the mover to find its way to the exit. (Hint: Think about how to use the Predicate functions before you move). Upon reaching the exit, you should print a message of success, like "We escaped!", and then output the final position of the mover. Keep the path toggled ON. You only need to display the initial setup grid and the final grid for this program.
Here is the header file grid.h:
#include <iostream>
using namespace std;
class Grid
{
public:
static const int NORTH = 0;
static const int WEST = 1;
static const int SOUTH = 2;
static const int EAST = 3;
Grid(); // build 1 x 1 grid with mover in only
// square, facing east
Grid(int r, int c); // build grid with r rows, c cols, blocks
around edge with random exit
// and random mover position and direction
Grid(int r, int c, int mr, int mc, int d); // build empty grid with r rows, c cols, and mover at row mr, col mc, and facing direction d
bool Move(int s); // move forward s spaces, if possible
void TogglePath(); // toggle whether or not moved path is shown
void TurnLeft(); // turn the mover to the left
void PutDown(); // put down an item at the mover's position
bool PutDown(int r, int c); // put down an item at (r,c), if possible
bool PickUp(); // pick up item at current position
bool PlaceBlock(int r, int c); // put a block at (r,c), if possible
void Grow(int gr, int gc); // grow the grid by gr rows, gc columns
void Display() const; // display the grid on screen. Accessors
bool FrontIsClear() const; // check to see if space in front of mover is clear
bool RightIsClear() const; // check to see if space to right of mover is clear
int GetRow() const; // return row of the mover
int GetCol() const; // return column of the mover
int GetNumRows() const; // return number of rows in the grid
int GetNumCols() const; // return number of columns in the grid
private:
char** grid;
int mover_r, mover_c, mover_d, maxRow, maxCol;
bool path;
};
Task
You will write a class called Grid, and test it with a couple of programs. A Grid object will be made up of a grid of positions, numbered with rows and columns. Row and column numbering start at 0, at the top left corner of the grid. A grid object also has a "mover", which can move around to different locations on the grid. Obstacles (which block the mover) and other objects (that can be placed or picked up) are also available. Here is a sample picture of a Grid object in its display format:
0 . . . This is a Grid object with 4 rows and 4 columns (numbered 0 - 3). . . > . The mover '>' is at row 1, column 2, facing east. . . . . The obstacle '#' is at row 3, column 1 . # . . The other item '0' is at row 0, column 0
The @ character indicates that the mover and an item (0) currently occupy the same position on the grid.
Program Details and Requirements
1) Grid class
Download this starter file: grid_starter.h and rename it as grid.h. Your member function prototypes are already given in this file. You will need to add appropriate member data. You will also need to define each of the member functions in the file grid.cpp. You may add whatever member data you need, but you must store the grid itself as a two-dimensional array. Maximum grid size will be 40 rows and 40 columns. (Note that this means dynamic allocation will NOT be needed for this assignment).
Meaning of Grid symbols
. empty spot on the grid 0 an item that can be placed, or picked up # a block (an obstacle). Mover cannot move through it < mover facing WEST > mover facing EAST ^ mover facing NORTH v mover facing SOUTH @ mover occupying same place as item (0)
A printed space ' ' in a grid position represents a spot that the mover has already moved through when the path display is toggled on
public Member function descriptions
You'll need the library cstdlib for the srand and rand functions. While it's not normally the best place to do it, you can go ahead and seed the random number generator here in the constructor in some appropriate way so that it's different for seperate program runs.
If you need a refresher on pseudo-random number generation, see this notes set from COP 3014: http://www.cs.fsu.edu/~myers/c++/notes/rand.html
In: Computer Science