How is it possible for the network layer (L3) to operate in connectionless, best effort manner? Hint: think upper layer
In: Computer Science
What command lists the MAC address on a computer? how do you find it on a mobile devices?
In: Computer Science
Implement a function that returns all the items in a binary search tree in order inside a std::vector. Use the following class and function definition:
class BTNode {
public:
int item;
BTNode *left;
BTNode *right;
BTNode(int i, BTNode *l=nullptr, BTNode *r=nullptr):item(i),left(l),right(r){}
};
BTNode *root = nullptr;
std::vector<int> inorder_traversal(BTNode *node) {
// implement
}
If the BST has no values, return a vector with no items in it.
#include <iostream>
#include <vector>
class BTNode {
public:
int item;
BTNode *left;
BTNode *right;
BTNode(int i, BTNode *l=nullptr, BTNode
*r=nullptr):item(i),left(l),right(r){}
};
BTNode *root = nullptr;
std::vector<int> inorder_traversal(BTNode *node) {
// implement
}
int main()
{
root = new BTNode(10, new BTNode(0), new BTNode(100));
std::vector<int> res = inorder_traversal(root);
for(auto &i : res) {
std::cout << i << ", ";
}
std::cout << std::endl;
return 0;
}
In: Computer Science
The following is an infinite loop:
for (int i = 0; i < 10; i++);
System.out.println(i + 4);
TRUE OR FALSE?
In: Computer Science
In python design a simple program that lets the user enter the total rainfall for each of the last 10 years into an array. The program should calculate and display the total rainfall for the decade, the average yearly rainfall, and the years with the highest and lowest amounts. Have screenshot with indentation and output display with explantion.Include comments
In: Computer Science
Again, recall Little’s Law. An escalator can be used two ways: A person can stand and let the escalator take her to the other end. Or the person can walk the escalator, reaching the other end faster. Suppose by walking a person reaches the other end in 60% of the time she takes just standing. However, when all walk the escalator, they need more space between them to avoid bumping into each other. Thus, the number of persons who can be on the escalator at the same time reduces by 50%. Which method (everyone standing vs. everyone walking) allows escalator to be used by most people per unit of time? Explain briefly. For full credit, you must use Little's Law to prove it.
In: Computer Science
A.) 1. Write a loop that prints the numbers 1-25i.e.
B.) 1 2 3 4... 252. Write a loop that prints all the even numbers between 1 and 50i.e. 2 4 6 8... 483.
C.) Create a list of the following fruits: oranges, apples, grapes and mangos and cherries. Write a loop that prints out every other fruit starting with oranges.i.e. oranges grapes and cherries.
In: Computer Science
Implement a function to find a node in a binary search tree. Using the following class and function definition:
class BTNode {
public:
int item;
BTNode *left;
BTNode *right;
BTNode(int i, BTNode *l=nullptr, BTNode *r=nullptr):item(i),left(l),right(r){}
};
BTNode *root = nullptr;
BTNode* find(int i) {
// implement
}
If a node with a matching value is found, return a pointer to it. If no match is found, return nullptr.
#include <iostream>
class BTNode {
public:
int item;
BTNode *left;
BTNode *right;
BTNode(int i, BTNode *l=nullptr, BTNode
*r=nullptr):item(i),left(l),right(r){}
};
BTNode *root = nullptr;
BTNode *find(int item)
{
return nullptr;
}
int main()
{
root = new BTNode(10, new BTNode(1), new BTNode(20));
BTNode *t1 = find(10);
if (t1)
std::cout << "Found " << t1->item <<
std::endl;
else
std::cout << "Should have found 10." <<
std::endl;
BTNode *t2 = find(1);
if (t1)
std::cout << "Found " << t2->item <<
std::endl;
else
std::cout << "Should have found 1." << std::endl;
BTNode *t3 = find(20);
if (t3)
std::cout << "Found " << t3->item <<
std::endl;
else
std::cout << "Should have found 20." <<
std::endl;
BTNode *t4 = find(100);
if (t4)
std::cout << "Should have found 20." << std::endl;
else
std::cout << "Did not find 100." << std::endl;
return 0;
}
In: Computer Science
Write a class called Person that has two private data members - the person's name and age. It should have an init method that takes two values and uses them to initialize the data members. It should have a get_age method.
Write a separate function (not part of the Person class) called basic_stats that takes as a parameter a list of Person objects and returns a tuple containing the mean, median, and mode of all the ages. To do this, use the mean, median and mode functions in the statistics module. Your basic_stats function should return those three values as a tuple, in the order given above.
For example, it could be used as follows:
p1 = Person("Kyoungmin", 73)
p2 = Person("Mercedes", 24)
p3 = Person("Avanika", 48)
p4 = Person("Marta", 24)
person_list = [p1, p2, p3, p4]
print(basic_stats(person_list)) # should print a tuple of three
values
The files must be named: basic_stats.py
In: Computer Science
Write the MIPS assembly code that creates the 32-bit constant 0010 0000 0000 0001 0100 1001 0010 0100two and stores that value to register $t1, and print the value of $t1 to stdout in binary - i.e., as a 32 bit sequence of '1's and '0's (use the MIPS syscall functionality for I/O).
Please don't answer if you don't know how to solve it, and don't just copy the previous answer.
In: Computer Science
create a stack class based on an array of type double of fixed size. In the class,
The array should have the default size of 5.
The array size should be settable via a constructor.
The following methods must be implemented:
push – inserts a value a the top of the stack
pop – returns the top value, removing it from the stack
isEmpty – returns true if the stack is empty, false otherwise
isFull - – returns true if the stack is full, false otherwise
Please notice you must use an array not an arraylist or any other list. Im having trouble with a couple parts of it. Thanks
Also use java
In: Computer Science
what are the different factors affecting the effectiveness of data communication? justify your reason for choosing these factors.
In: Computer Science
USE JAVA PLEASE
A Phone class has 4 instance variables
Model name ("iPhone12","Galaxy")
RAM (number of gigs such as 8 and12)
Storage (number of gigs such as 128 and 512)
Screen of type class Screen as described below.
A Screen has 3 instance variables:
Screen type ("AMOLED", "LCD")
Screen size (decimal number such as 6.2 and 10.1)
Screen ppi (448, 630, 300)
Q1) Code two class-shell for both classes. The names and types of the instance variables have deliberately been left up to you (14m)
Q2) Code a 6-parameter contractor for class Phone (12m)
Do not rely on any auto-initialisation
You can assume mutators exist for all instance variables
Q3) Code the toString method that should print all the specifications of the object that is invoked on. (8m)
Q4) Code a method called normalize() that accepts an array of integers 'intAr' and returns an array of doubles 'doubleAr'. The returned array must have the same length as the input. The method should convert any range of values in 'intAr' into 0..1 range. (10m)
For example:
if intAr=[-100,-50,0,50,100], doubleAr=[0.0,0.25,0.5,0.75,1.0]
How to normalize data?
where:
doubleAr[i] is the ith element in the output array doubleAr
intAr[i] is the ith element in the input array intAr
min(intAr) is the minimum value in the input array intAr
max(intAr) is the maximum value in the input array intAr
In: Computer Science
What are the limitations of Karnaugh Maps? Explain with an example
In: Computer Science
Write a pyhton program to read from a file the names and grades of a class of students, to calculate the class average, the maximum, and the minimum grades. The program should then write the names and grades on a new file identifying the students who passed and the students who failed. The program should consist of the following functions:
a) Develop a dataInput() function that reads data from a file and stores it and returns it as a dictionary. The function has one argument which is the name of the file where the data is entered. Each line on the file should contain the record of one student holding his or her name and the corresponding grade.
b) Write a second function dataStats() that iterates over the list or dictionary and determines the statistics on the average, minimum, and maximum of the grades and return these statistics as a list.
c) Write a third function dataEval() that will iterate over the dictionary or list and write on a new file named Class_Results.txt the names of students whose grades are greater or equal to 60, preceded by the message “Passing Students”. Then the names of students whose grades are lower than 60 should written on the file, preceded by the message “Failing Students”. Finally, the class statistics should be written on the file, also preceded by the message “Class Statistics”.
d) Write a main program that coordinates the operation of the three developed functions. The program should inform the user of what is its function and request from the user the name of the file where class names and grades are written. Form you own data file, Class_Data.txt that have the following entries : Galia, 96 -Elias, 81 -Hussein, 84 -Joseph, 80 -Tarek, 93 -Joe, 81 -Fidele, 71 -Shant, 95 -Ali, 67 -Firas, 70 -Giorgiou, 55 -Hashem, 72
In: Computer Science