Answer:
The essence including its issue is listed in the interpretation subsection below.
Explanation:
- Representing means the practice of someone using abstract, tangible as well as pictorial symbols as well as phrases and related circumstances to discuss ideas and express comprehension.
- Representing fractions could indeed be overcome in almost the same manner as the positive factors of twice represented integers are using the negative factors of two to summarize to essentially fractional amounts.
Answer:
Java.
Explanation:
public class Card
{
String Suit;
int value;
public Card(int value, String Suit) {
self.value = value;
// Check Suits value
if ((Suit == "hearts") || (Suit == "spades") || (Suit == "clubs") || (Suit == "diamonds"))
self.Suit = Suit;
else {
Suit = "none";
throw new IllegalArgumentException("no card of this type exists.");
}
}
public String getSuit() {
return Suit;
}
public int getValue() {
return value;
}
public void print() {
System.out.println("%d of %s", value, Suit);
}
}
public class Deck {
}
Answer:
(a) What is the best case time complexity of the algorithm (assuming n > 1)?
Answer: O(1)
(b) What is the worst case time complexity of the algorithm?
Answer: O(n^4)
Explanation:
(a) In the best case, the if condition will be true, the program will only run once and return so complexity of the algorithm is O(1)
.
(b) In the worst case, the program will run n^4 times so complexity of the algorithm is O(n^4).
Answer:
4160000 bytes
Explanation:
One page = 52 lines of text
One line of text = 80 characters
=> One page = 80 x 52 = 4160 characters
Therefore, 500 pages of text will have 4160 x 500 characters = 2080000 characters.
Since 1 character takes up 2 bytes of computer memory, it impleies that a 500 page novel will take up 2080000 x 2 bytes = 4160000 bytes.
Answer:
public class Calculator {
private int total;
private int value;
public Calculator(int startingValue){
// no need to create a new total variable here, we need to set to the our instance total variable
total = startingValue;
value = 0;
}
public int add(int value){
//same here, no need to create a new total variable. We need to add the value to the instance total variable
total = total + value;
return total;
}
/**
* Adds the instance variable value to the total
*/
public int add(){
// no need to create a new total variable. We need to add the value to the instance total variable
total += value;
return total;
}
public int multiple(int value){
// no need to create a new total variable. We need to multiply the instance total variable by value.
total *= value;
return total;
}
//We need to specify which value refers to which variable. Otherwise, there will be confusion. Since you declare the parameter as value, you need to put this keyword before the instance variable so that it will be distinguishable by the compiler.
public void setValue(int value){
this.value = value;
}
public int getValue(){
return value;
}
}
Explanation:
I fixed the errors. You may see them as comments in the code