Question: 1. Write a Java program that uses ArrayList and Iterator. It should input from user the names and ages of your few friends in a


1. Write a Java program that uses ArrayList and Iterator. It should input from user the names and ages of your few friends in a loop and add into ArrayList. Finally, it should use Iterator to display the data in a proper format. [Hint-Lecture 02: Slide 8] LitofuyFriend Sitemmeandafixo Klad Al-anni 25 Doyouwattalande fiend(y)?y Sitemadage (fiwezi 1] Ralzed Alami 21.1 Do youwattadinote fiendy)?y Eite meandag [fiex2 Salem Almani 23.7 Doyouwatbaidante fiend ya)?n Haec the data youated 0 Khid Al-haun 225 1. Ralced Alana 21.1 2 Salem Almtm 3.7 Sample run of the program -) 2. Calculate the execution time of the following program: [Hint-Lec 03: Slides 18] Cost Repetition Statement i=1; sumn = 0; while (an) { j=1; while ( jn) sumn=suin + i; j=j+1; i=i+1; Total Cost = T(n) = Time complexity (UPPER BOUND) = Page 1 of 2 3. Write a Java program that inputs size of array N and N numbers in the array. It should use Insertion sort to sort the array and then display it. Then, ask a number X to search in the array. It should use Binary search and then print the result of search. [Hint-Lab 03] Seading and Sating Alain File size of anay?5 Bite Sumbes: 55 82 24 9.1 33 Sortedanzy 24, 33, 55, 8.2, 9.1 Bite anmbertseach? 82 82 Foundatime:3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
