What are the functions of data bases and data ware houses?
In: Computer Science
In: Computer Science
In Python, I've created a Node class for implementing a singly linked list.
My Code:
class Node:
def __init__(self,initdata):
self.data = initdata
self.next = None
def getData(self):
return self.data
def getNext(self):
return self.next
def setData(self,newdata):
self.data = newdata
def setNext(self,newnext):
self.next = newnext
class SinglyLinkedList:
def __init__(self):
self.head = None
def add(self,key):
addkey = Node(key)
addkey.setNext(self.head)
self.head = addkey
Now the question is: Create an append method that is O(1) by modifying the constructor of the SinglyLinkedList class by adding another instance variable. You will need to make a modification to the add method as well.
In: Computer Science
Why should someone study data science? How data science is a great career field?
I need 600 words.
I need original content, so don't copy please.
In: Computer Science
Discuss whether the spiral model is appropriate for each of the following software projects or not. If not, suggest a better model and provide justifications for your choice.
Project 1: a software team were asked to develop a large-scale human resource software. The project manager identified several major technical risks that need to be mitigated.
Project 2: a software team were asked to develop a small web application for older people to help them apply for health insurance. The team are not sure about how to make it easy for older people to interact with the application.
In: Computer Science
Q1 / Consider a system consisting of four resources of the same type that are shared by three processes, each of which needs at most two resources. Show that the system is deadlock-free.
Q2 / Sometimes, segmentation and paging are joint into one scheme. Why, explain in your words.
In: Computer Science
I need convert this java code to C language. There is no string can be used in C. Thank you!
import java.util.Scanner;
public class Nthword
{
public static void main( String args[] )
{
String line;
int word;
Scanner stdin = new Scanner(System.in);
while ( stdin.hasNextLine() )
{
line = stdin.nextLine();
word = stdin.nextInt(); stdin.nextLine(); // get rid of the newline
after the int
System.out.println( "Read line: \"" + line + "\", extracting
word [" + word + "]" );
System.out.println( "Word #" + word + " is: " + extractWord( line,
word ) );
}
stdin.close();
System.out.println( "\nEnd of processing" );
}
// returns the first word of the string
private static String extractWord( String theLine, int word )
{
int start;
int end;
int spaces = 1;
String result = "";
// search for the nth non-blank character
for (start = 0; start < theLine.length() && spaces <
word; start++)
{
if ( Character.isSpaceChar( theLine.charAt( start ) ) )
{
spaces++;
}
}
// only need to continue if we haven't gone past the end of the
string
if ( start<theLine.length() )
{
// the next blank character is the end
for ( end=start ; end<theLine.length() &&
!Character.isSpaceChar( theLine.charAt( end ) ) ; end++ )
;
// we now have the word
result = theLine.substring( start, end );
}
return( result );
}
}
In: Computer Science
2) Explain the difference between TREE-SEARCH and GRAPH-SEARCH. Support your answer with an example.
In: Computer Science
The Power of Unified Communications
Chapter 7 highlights the power of the "Network." Advances in networking technology have made the internet possible and have provided the underpinning for a revolution in communications. The Macy's RFID (radio frequency identification) case study at the beginning of the chapter highlights the power of wireless networking in particular. As defined by the text, Unified Communications allows companies to merge disparate modes of communication into a single service. This is akin to the technology that underpins the "triple play" packages offered by cable and telecommunications providers alike which combines video, internet, and phone in one package.
By doing a search of the internet or by other research methods, find an example, or a case study, of an organization that has used Unified Communications to their advantage.
Ponder these questions:
1) What business problem was this organization trying to solve?
2) What was the current state of their communications technology infrastructure?
3) What unified communications technologies did they decide to deploy? What were the key components of this system?
4) How did they improve their business by implementing unified communications?
5) What do you believe the future holds for unified communications?
In: Computer Science
In: Computer Science
Create a table of all three of these trigonometric functions for angles from 0 to 2p, with a spacing of 0.1 radian. Your table should contain a column for the angle and then for the sine, cosine, and tangent. ((python))
In: Computer Science
I am working on a project for my Computer Science course. I am trying to create a Battleship game where a user names two coordinates on a grid and is then told whether this results in a "Hit" or a "Miss". Once the ship has been hit a certain number of times (based on the size of the ship) the ship is sunk. I have written all the code but it now fails to execute when I try to run it. Could someone please help me to get this program working properly? I will paste the code below:
battleship.h:
#ifndef BATTLESHIP_H_
#define BATTLESHIP_H_
// coordinates (location) of the ship and shots
class location {
public:
void locationreset(void); // void constructor, assigns -1 to
X
void pick(void); // picks a random location
void fire(void); // asks the user to input the
// coordinates of the next shot
void print(void) const; // prints location in format "a1"
// returns true if the two locations match
friend bool compare(location, location);
private:
static const int fieldSize = 5; // the field (ocean) is fieldSize X
fieldSize
int x; // 1 through fieldSize
char y; // 'a' through fieldSize
};
// contains ship's coordinates (location) and whether is was
sunk
class ship {
public:
ship(void); // void constructor, sets sunk=false
bool match(location) const; // returns true if this location
matches
// the ship's location
bool isSunk(void) const { return(sunk); }; // checks to see if the
ship is sunk
void sink(void); // sets "sunk" member variable of the ship to
true
void setLocation(location); // deploys the ship at the specified
location
void printShip(void) const; // prints location and status of the
ship
private:
location loc;
bool sunk;
};
// contains the fleet of the deployed ships
class fleet {
public:
void deployFleet(void); // deploys the ships in random
locations
// of the ocean
bool operational(void) const; // returns true if at least
// one ship in the fleet is not sunk
bool isHitNSink(location); // returns true if there was a
deployed
// ship at this location (hit) and sinks it
// otherwise returns false (miss)
void printFleet(void) const; // prints out locations of ships in
fleet
private:
static const int fleetSize = 5; // number of battleships
bool check(location); // returns true if one of the ship's
locations
// matches the ship, returns false
// if none-match
ship ships[fleetSize]; // battleships of the fleet
};
#endif /* BATTLESHIP_H_ */
//////////////////////////////////////////////////////////////////////////////////////////////////////////
battleship.cpp:
#include <iostream>
#include <ctime>
#include <cstdlib>
#include "battleship.h"
using namespace std;
void location::locationreset(void) {
x = -1;
y = 'x';
}
void location::pick(void) {
x = rand() % fieldSize + 1;
y = rand() % fieldSize;
switch (y) {
case 0: y = 'a'; break;
case 1: y = 'b'; break;
case 2: y = 'c'; break;
case 3: y = 'd'; break;
case 4: y = 'e'; break;
}
}
void location::fire(void) {
cout << "input the coordinates of the next shot
"; cin >> y >> x;
}
void location::print() const {
cout << y << x;
}
bool compare(location loc1, location loc2) {
return (loc1.x == loc2.x && loc1.y ==
loc2.y);
}
ship::ship(void) {
sunk = false;
}
bool ship::match(location shiploc) const {
return compare(loc, shiploc);
}
void ship::sink(void) {
sunk = true;
}
void ship::setLocation(location shiploc) { //
deploys the ship at the specified location
loc = shiploc;
}
void ship::printShip(void) const { // prints location and status
of the ship
loc.print();
if (sunk == true)
cout << "sunk";
else if (sunk == false)
cout << "not sunk" <<
endl;
}
void fleet::deployFleet(void) { // deploys the ships in random
locations of the ocean
location loc; loc.locationreset();
for (int i = 0; i < fleetSize; i++) {
loc.pick();
ships[i].setLocation(loc);
}
}
bool fleet::operational() const { // returns true if at least
one ship in the fleet is not sunk
for (int i = 0; i < fleetSize; ++i)
if (ships[i].isSunk() ==
false)
return
true;
return false;
}
bool fleet::isHitNSink(location shiploc) { //
returns true if there was a deployed
for (int i = 0; i < fleetSize; ++i) {
if (ships[i].match(shiploc) == true
&& ships[i].isSunk() == false)
{
ships[i].sink();
return
true;
}
else
return
false;
}
}
void fleet::printFleet(void) const { // prints out locations of
ships in fleet
for (int i = 0; i < fleetSize; ++i)
ships[i].printShip();
}
bool fleet::check(location shiploc) {
for (int i = 0; i < fleetSize; ++i)
if (ships[i].match(shiploc))
{
return
true;
}
else
{
return
false;
}
}
////////////////////////////////////////////////////////////////////////////
main.cpp:
#include "battleship.h"
#include <iostream>
using namespace std;
int main() {
srand(time(NULL));
char answer;
fleet myFleet; //computer's ships
myFleet.deployFleet(); // fleet is deployed at random
locations
cout << "Do ships' positions and status need to
be printed? (y for yes)" << endl;
cin >> answer;
if (answer == 'y')
myFleet.printFleet();
while (myFleet.operational() == true) {
cout << "there are still
ships up";
location userShot;
userShot.locationreset();
cout << "Input location(a-e
1-5): ";
userShot.fire();
if (myFleet.isHitNSink(userShot) ==
true)
cout <<
"hit";
else
cout <<
"miss";
cout << "Do ships' positions
and status need to be printed? (y for yes, q to quit)";
cin >> answer;
if (answer == 'y')
myFleet.printFleet();
else if (answer == 'q')
break;
}
}
In: Computer Science
given an array A = {a1, a2, ... ,
an}
find the number of the continuous subarrays of gcd one
continuous subarrays of gcd one means gcd(ai,
ai+1, ... , aj) = 1
for example {2, 4, 6, 3} or {1} are continuous subarrays of gcd
one
In: Computer Science
Need this in C++:
Suppose that you are given a set of words; and two words from the set: word 1 and word 2.
Write a program which will transform word 1 into word 2 by changing a single letter in word 1 at a time.
Every transition that word 1 takes will have to be in the set of words.
You must output the smallest sequence of transitions possible to convert word 1 into word 2.
You may assume that all the words in the dictionary are the same length.
The first line will be word 1 and word 2 separated by a comma, followed by the set of words. The set of words will be terminated by a ‘-1’.
Input:
DOG,GOD
DOG
BOG
GOG
ABH
GOD
THU
IOP
-1
Output:
DOG -> GOG -> GOD
Input:
HOUSE,JOUKS
MOUSE
HIUKE
HIUKS
HOUSH
LOUSE
HOZKS
SOUSE
HOUKS
HOUSE
HOUKE
JOUKZ
JOUKS
HOIKE
-1
Output:
HOUSE -> HOUKE -> HOUKS -> JOUKS
In: Computer Science
In Ruby
A dentist appointment schedule validation software
Implement a superclass Appointment and sub classes OneTime, Day and Month. An appointment has a description (for example, "Root Canal"), and dates information (you can use Date object or int Year, Int Month, Int Day). Fill an array of Appointment objects with a mixture of appointments.
Write a method OccursOn inside each of the sub classes that checks whether the appointment occurs on that date (OneTime), day (Day) or month (Month). Ask the user to enter a date to check (for example, 2006 10 5), and ask to user if they want to check against OneTime, Day or Month appointment. Based on what the user selected, OccursOn inside each of the sub class should run and display any matching appointment and associated descriptions.
Hint: For OneTime subclass, OccursOn need three inputs (Year, Month and Day) to validate, for Day subclass, OccursOn needs one input (Day) to validate, and for Month subclass, OccursOn need one input (Month) to validate. OccursOn is different for different subclasses.
In: Computer Science