Answer: The shell sort is based on insertion sort. Here the list of elements are divided into smaller sub list which are sorted based on insertion sort.
Its best case time complexity is O(n* logn) and worst case is O(n* log^2 n)
Explanation:
Shell sort is an inplace sorting here we begin by dividing the list into sublist and sorting the list with insertion sort. We create interval for dividing the list into sub list until we reach the smallest interval of 1.
The best case is O(n* logn).
Answer:
public class num8 {
public static void main(String[] args) {
System.out.println("Average Temperature in New York is 85 degrees fahrenheit");
System.out.println("Average Temperature in Denver is 88 degrees fahrenheit");
System.out.println("Average Temperature in Phoenix is 106 degrees fahrenheit");
// Calculating the new average Temperatures
System.out.println("The New Average Temperature in New York " +
"is "+ ((0.02*85)+85 )+ " degrees fahrenheit");
System.out.println("The New Average Temperature in Denver " +
"is " +((0.02*88)+88 )+ " degrees fahrenheit");
System.out.println("The New Average Temperature in Phoenix " +
"is "+((0.02*106)+106 )+ " degrees fahrenheit");
}
}
Explanation:
- Using Java first display the previous average temperatures for the three cities as given in the question
- Then calculates the new average temperature by multiplying by 0.02, because of a 2 percent increase in the average temperature
- Display the new temperature using the System.out,println
Answer:
TCP is a connection-oriented protocol, whereas UDP is a connectionless protocol. The speed for TCP is slower while the speed of UDP is faster.