Answer:
- import java.util.Arrays;
- import java.util.Scanner;
-
- public class Main {
- public static void main(String[] args) {
- int numArr [] = new int[10];
- Scanner input = new Scanner(System.in);
- System.out.print("Input number: ");
- int num = input.nextInt();
- int i = 0;
- while(num != -1){
- numArr[i] = num;
- i++;
- System.out.print("Input number: ");
- num = input.nextInt();
- }
-
- selectionSortDescendTrace(numArr);
- }
-
- public static void selectionSortDescendTrace(int [] arr){
- for(int i =0 ; i < arr.length - 1; i++){
- int largest = arr[i];
- int largeIndex = i;
-
- for(int j= i + 1; j < arr.length; j++ ){
- if(arr[j] > largest){
- largest = arr[j];
- largeIndex = j;
- }
- }
-
- int temp = arr[i];
- arr[i] = arr[largeIndex];
- arr[largeIndex] = temp;
- System.out.println(Arrays.toString(arr));
- }
- }
- }
Explanation:
The solution code is written in Java.
First, we work on the selectionSortDescendTrace method that takes one input array (Line 21). In the method, we create a nested loops. In the outer loop, we set the current element indexed by i as the largest value and use another variable largeIndex to track the index of largest value (Line 23 -24).
We create inner loop to traverse through the subsequent number after current index-i and compared each of the element by the current largest value (Line 26 - 30). If any of the subsequent element is larger than the current largest value, set the element as largest value and update the largeIndex accordingly (Line 27 - 29).
After completion of inner loop, we swap the position of the current found largest number with the element indexed by current i (Line 33 - 35). Print the partially sorted array (Line 36).
The answer is Radio-Frequency Identification. The use of electromagnetic energy to transmit information between a reader (transceiver) and a processing device is Radio-Frequency Identification (RFID). It is an <span>electronic devices that consist of a small chip and an antenna. The </span>RFID<span> device serves the same </span>purpose<span> as a bar code or a magnetic strip on the back of a credit card or ATM card; it provides a unique identifier for that object.</span>
<span>The tool iused to view stars in galaxies far from the Milky Way is the B. Hubble Space Telescope. This telescope is one of the largest telescopes to be launched in space, and has contributed a vast amount of discoveries and data that are valuable in astronomical research. The telescope is able to capture image intense high-resolution images, capturing entities from large distances.</span>
Answer:
Required code is given below:
Explanation:
def add_to_dict(dictt, key,value):
if key in dictt.keys():
print("Error. Key already exists.")
else:
dictt[key]=value
return dictt
def remove_from_dict(dictt,key):
try:
dictt[key]
dictt.pop(key, None)
return dictt
except KeyError:
print("No such key exists in the dictionary.")
def find_key(dictt,key):
try:
value=dictt[key]
print("Value: ", value)
except KeyError:
print("Key not found.")