Write a program using Java to move the last element of a LL to the beginning of the list.
Using supply and demand diagrams, show the effect of the following events on the market for sweatshirts.
a. A drought in Egypt damages the cotton crop.
b. The price of leather jackets falls.
c. All universities require students to attend morning exercise classes in appropriate attire.
d. New knitting machines are invented
Write a Java program to find maximum product of two integers in a given array of integers.
Example:
Input :
nums = { 2, 3, 5, 7, -7, 5, 8, -5 }
Output:
Pair is (7, 8), Maximum Product: 56
Write a Java program to shuffle a given array of integers.
Write a Java program to form the largest number from a given list of non-negative integers.
Example:
Input :
nums = {1, 2, 3, 0, 4, 6}
Output:
Largest number using the given array numbers: 643210
Explain each of the following statements using supply and demand diagrams.
a. When there is a drought in southern Europe, the price of soft fruit rises in supermarkets throughout Europe.
b. When a report is published linking a product with an increased risk of cancer, the price of the product concerned tends to fall.
c. The United States announces that it intends to impose new sanctions on the Islamic Republic of Iran. The price of petrol in Europe rises and the price of a used Mercedes falls.
Write a Java program to rearrange a given array of unique elements such that every second element of the array is greater than its left and right elements.
Example:
Input :
nums= { 1, 2, 4, 9, 5, 3, 8, 7, 10, 12, 14 }
Output:
Array with every second element is greater than its left and right elements:
[1, 4, 2, 9, 3, 8, 5, 10, 7, 14, 12]
Are cigars substitutes or complements for cigarettes?
b. Using a supply and demand diagram, show what happens in the markets for cigars if the tax on cigarettes is increased.
c. If policymakers wanted to reduce total tobacco consumption, what policies could they combine with the cigarette tax?
Given two sorted arrays A and B of size p and q, write a Java program to merge elements of A with B by maintaining the sorted order i.e. fill A with first p smallest elements and fill B with remaining elements.
Write a Java program to arrange the elements of a given array of integers where all negative integers appear before all the positive integers.