Answer:
1.
class TIME
{
int hour , min , sec ;
public :
TIME()
{
hour=min=sec=0;
}
TIME( int h , int m , int s )
{
hour = h;
min = m;
sec = s;
}
void change ( int Hour)
{
hour = Hour;
}
void stdtime()
{
if(hour>12)
cout<<"The Standard time is"<<(hour-12)<<":"<<min<<":"<<sec<<"P.M\n";
else
cout<<"The Standard time is"<<hour<<":"<<min<<":"<<sec<<"A.M\n";
}
void miltime()
{
cout<<"The Military time is"<<hour<<":"<<min<<":"<<sec<<" hours\n";
}
};
void main()
{
TIME A , B(13,25,30);
A .stdtime();
A.change(23);
A.miltime();
B.stdtime();
B.change(9);
B.miltime();
}
2.
class elevator
{
int CurrentFloor;
int GoingUp;
int GoingDown;
public:
elevator()
{
CurrentFloor=0;
GoingUp=1;
GoingDown=-1;
}
elevator(int floor)
{
CurrentFloor=floor;
GoingUp=1;
GoingDown=-1;
}
void goUp(int y)
{
if( CurrentFloor>3)
cout<<"\nNO MORE FLOORS\n";
else
CurrentFloor=CurrentFloor+y*GoingUp;
}
void goDown(int x)
{
if(CurrentFloor<0)
cout<<"\nNO MORE FLOORS";
else
CurrentFloor=CurrentFloor+x*GoingDown;
}
};
void main()
{
elevator A(1);
A.goUp(1);
A.goUp(1);
A.goUp(1);
A.goDown(1);
A.goDown(1);
}
Answer:An initial condition is an extra bit of information about a differential equation that tells you the value of the function at a particular point. Differential equations with initial conditions are commonly called initial value problems.
The video above uses the example
{
d
y
d
x
=
cos
(
x
)
y
(
0
)
=
−
1
to illustrate a simple initial value problem. Solving the differential equation without the initial condition gives you
y
=
sin
(
x
)
+
C
.
Once you get the general solution, you can use the initial value to find a particular solution which satisfies the problem. In this case, plugging in
0
for
x
and
−
1
for
y
gives us
−
1
=
C
, meaning that the particular solution must be
y
=
sin
(
x
)
−
1
.
So the general way to solve initial value problems is: - First, find the general solution while ignoring the initial condition. - Then, use the initial condition to plug in values and find a particular solution.
Two additional things to keep in mind: First, the initial value doesn't necessarily have to just be
y
-values. Higher-order equations might have an initial value for both
y
and
y
′
, for example.
Second, an initial value problem doesn't always have a unique solution. It's possible for an initial value problem to have multiple solutions, or even no solution at all.
Explanation:
Answer:
public void trimToSize() {
modCount++;
if (size < elementData.length) {
elementData = (size == 0)
? EMPTY_ELEMENTDATA
: Arrays.copyOf(elementData, size);
}
}
Now, the running time for copyOf() function is O(N) where N is the size/capacity of the ArrayList. Hence, the time complexity of trimToSize() function is O(N).
Hence, the running time of building an N-item ArrayList is O(N^2).
Please find the sample code below.
CODE
==================
import java.util.ArrayList;
public class Driver {
public static void main(String[] args) throws Exception{
int N = 100000;
ArrayList<Integer> arr = new ArrayList<>(N);
long startTime = System.currentTimeMillis();
for(int i=0; i<N; i++) {
arr.add(i);
arr.trimToSize();
}
long endTime = System.currentTimeMillis();
double time = (endTime - startTime)/1000;
System.out.println("Total time taken = " + time + " seconds.");
}
}
Explanation:
Answer:
Device Health Attestation Services
Explanation:
Based on the scenario being described it can be said that the Windows Server role that can be used to automate this check is known as Device Health Attestation Services. This is a role that allows the administrator to automatically check if a device has the required trustworthy BIOS, TPM, or boot software enabled, as well as Bitlocker encryption.