SlideShare a Scribd company logo
1 of 4
Download to read offline
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static java.lang.System.out;
public class homework {
public static void main(String[] args) {
List<Integer> list = new ArrayList<>();
for (int i = 0; i < 10; i++)
list.add(int) (Math.random()* 10) + 1);
Collections.sort(list);
System.out.println("The list id : " + list);
int index =linearSearch(list, 10);
if (index >+ 0)
System.out.println("Linear search: the number 5 was found at index " + index);
else
System.out.println("Linear search: the number 5 is not found ");
List<String> names = new ArrayList<>();
names.add("Tyson");
names.add("John");
names.add("Edgar");
names.add("LouLou");
Collections.sort(list);
System.out.println("The names are : " + names);
index = linearSearch(names, "JOhn");
if (index >= 0)
System.out.println("Linear search: Edgar was found at index " + names);
else
System.out.println("Linear search: Edgar is not found" + names);
}
public static <E> int linearSearch(List<E> lsit, E data) {
for (int i = 0; i < list.size(); i++)
if (list.get(i).equals(data))
return i;
return -1;
}
}
Chapter 14 - Linear Search and Binary Search - Assignment Due Wednesday by 11:59pm P
Points 100 Submitting a text entry box or a file upload Allowed Attempts 1 Available until Mar
1 at 11:59pm Modify the binarySearch method shown in the video lecture so that it's generic.
Test it with at least two types to make sure it works. Hint 1: Examine the review problem and its
solution, which modifies the linear search algorithm in the same way. Hint 2: Your binarySearch
method signature should be: "private static < E extends Comparable > boolean binarySearch(List
list, E data): Turn in the following, - The source files (no zip file, just the individual java files). -
A screen shot of your program in action. It should show the result of the test run.
import java-util-ArrayList- import java-util-Collections- import java-.pdf

More Related Content

Similar to import java-util-ArrayList- import java-util-Collections- import java-.pdf

Refer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdfRefer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdf
arishmarketing21
 
JAVALAB #8 - ARRAY BASED LISTSThe next exercise is based on this.pdf
JAVALAB #8 - ARRAY BASED LISTSThe next exercise is based on this.pdfJAVALAB #8 - ARRAY BASED LISTSThe next exercise is based on this.pdf
JAVALAB #8 - ARRAY BASED LISTSThe next exercise is based on this.pdf
arpaqindia
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
freddysarabia1
 
I need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdfI need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdf
fantoosh1
 
Array based based implementation of the List ADT It uses an array o.pdf
Array based based implementation of the List ADT It uses an array o.pdfArray based based implementation of the List ADT It uses an array o.pdf
Array based based implementation of the List ADT It uses an array o.pdf
anithacells
 
1. import java.util.Scanner; public class Alphabetical_Order {.pdf
1. import java.util.Scanner; public class Alphabetical_Order {.pdf1. import java.util.Scanner; public class Alphabetical_Order {.pdf
1. import java.util.Scanner; public class Alphabetical_Order {.pdf
Ankitchhabra28
 
output and explain There is Mylist There is MyArrayList pa.pdf
output and explain There is Mylist There is MyArrayList pa.pdfoutput and explain There is Mylist There is MyArrayList pa.pdf
output and explain There is Mylist There is MyArrayList pa.pdf
access2future1
 
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfimport java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
shettysachin2005
 
ReverseList.javaimport java.util.ArrayList;public class Rever.pdf
 ReverseList.javaimport java.util.ArrayList;public class Rever.pdf ReverseList.javaimport java.util.ArrayList;public class Rever.pdf
ReverseList.javaimport java.util.ArrayList;public class Rever.pdf
aryan9007
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdf
manojmozy
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
RAJATCHUGH12
 

Similar to import java-util-ArrayList- import java-util-Collections- import java-.pdf (20)

Refer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdfRefer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdf
 
JAVALAB #8 - ARRAY BASED LISTSThe next exercise is based on this.pdf
JAVALAB #8 - ARRAY BASED LISTSThe next exercise is based on this.pdfJAVALAB #8 - ARRAY BASED LISTSThe next exercise is based on this.pdf
JAVALAB #8 - ARRAY BASED LISTSThe next exercise is based on this.pdf
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
 
practical 9.docx
practical 9.docxpractical 9.docx
practical 9.docx
 
I need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdfI need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdf
 
Aj unit2 notesjavadatastructures
Aj unit2 notesjavadatastructuresAj unit2 notesjavadatastructures
Aj unit2 notesjavadatastructures
 
Oop lecture7
Oop lecture7Oop lecture7
Oop lecture7
 
Array based based implementation of the List ADT It uses an array o.pdf
Array based based implementation of the List ADT It uses an array o.pdfArray based based implementation of the List ADT It uses an array o.pdf
Array based based implementation of the List ADT It uses an array o.pdf
 
Please add-modify the following to the original code using C# 1- Delet.docx
Please add-modify the following to the original code using C# 1- Delet.docxPlease add-modify the following to the original code using C# 1- Delet.docx
Please add-modify the following to the original code using C# 1- Delet.docx
 
1. import java.util.Scanner; public class Alphabetical_Order {.pdf
1. import java.util.Scanner; public class Alphabetical_Order {.pdf1. import java.util.Scanner; public class Alphabetical_Order {.pdf
1. import java.util.Scanner; public class Alphabetical_Order {.pdf
 
output and explain There is Mylist There is MyArrayList pa.pdf
output and explain There is Mylist There is MyArrayList pa.pdfoutput and explain There is Mylist There is MyArrayList pa.pdf
output and explain There is Mylist There is MyArrayList pa.pdf
 
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfimport java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
 
Write a program that creates a LinkedList object of 10 characters- the.docx
Write a program that creates a LinkedList object of 10 characters- the.docxWrite a program that creates a LinkedList object of 10 characters- the.docx
Write a program that creates a LinkedList object of 10 characters- the.docx
 
ReverseList.javaimport java.util.ArrayList;public class Rever.pdf
 ReverseList.javaimport java.util.ArrayList;public class Rever.pdf ReverseList.javaimport java.util.ArrayList;public class Rever.pdf
ReverseList.javaimport java.util.ArrayList;public class Rever.pdf
 
07 java collection
07 java collection07 java collection
07 java collection
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdf
 
WAP to store 10 numbers in an array and find out the largest and the smallest...
WAP to store 10 numbers in an array and find out the largest and the smallest...WAP to store 10 numbers in an array and find out the largest and the smallest...
WAP to store 10 numbers in an array and find out the largest and the smallest...
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
 
i am looking for help on the method AddSorted and the method Copy only.pdf
i am looking for help on the method AddSorted and the method Copy only.pdfi am looking for help on the method AddSorted and the method Copy only.pdf
i am looking for help on the method AddSorted and the method Copy only.pdf
 

More from adhityalapcare

In 2019 there were $3-4 trillion in mergers and acquisitions worldwide.pdf
In 2019 there were $3-4 trillion in mergers and acquisitions worldwide.pdfIn 2019 there were $3-4 trillion in mergers and acquisitions worldwide.pdf
In 2019 there were $3-4 trillion in mergers and acquisitions worldwide.pdf
adhityalapcare
 
In 2015 - the Hawai'i State Legislature passed a bill that sets a goal.pdf
In 2015 - the Hawai'i State Legislature passed a bill that sets a goal.pdfIn 2015 - the Hawai'i State Legislature passed a bill that sets a goal.pdf
In 2015 - the Hawai'i State Legislature passed a bill that sets a goal.pdf
adhityalapcare
 

More from adhityalapcare (20)

In 2022- Lisa and Fred- a married couple- had taxable income of $305-4.pdf
In 2022- Lisa and Fred- a married couple- had taxable income of $305-4.pdfIn 2022- Lisa and Fred- a married couple- had taxable income of $305-4.pdf
In 2022- Lisa and Fred- a married couple- had taxable income of $305-4.pdf
 
In 2021- Montana Corp- entered into a contract to begin work on a two-.pdf
In 2021- Montana Corp- entered into a contract to begin work on a two-.pdfIn 2021- Montana Corp- entered into a contract to begin work on a two-.pdf
In 2021- Montana Corp- entered into a contract to begin work on a two-.pdf
 
In 2022 - Laureen is currently single- She paid $2-800 of qualified tu.pdf
In 2022 - Laureen is currently single- She paid $2-800 of qualified tu.pdfIn 2022 - Laureen is currently single- She paid $2-800 of qualified tu.pdf
In 2022 - Laureen is currently single- She paid $2-800 of qualified tu.pdf
 
In 2020- Rocket inc- had reported a deferred tax asset of $106 million.pdf
In 2020- Rocket inc- had reported a deferred tax asset of $106 million.pdfIn 2020- Rocket inc- had reported a deferred tax asset of $106 million.pdf
In 2020- Rocket inc- had reported a deferred tax asset of $106 million.pdf
 
implementation of virtual care Detailed Communication plan is compile.pdf
implementation of virtual care  Detailed Communication plan is compile.pdfimplementation of virtual care  Detailed Communication plan is compile.pdf
implementation of virtual care Detailed Communication plan is compile.pdf
 
In 2019 there were $3-4 trillion in mergers and acquisitions worldwide.pdf
In 2019 there were $3-4 trillion in mergers and acquisitions worldwide.pdfIn 2019 there were $3-4 trillion in mergers and acquisitions worldwide.pdf
In 2019 there were $3-4 trillion in mergers and acquisitions worldwide.pdf
 
implement trylexcept excepsion handler to catch all errors drom the fo.pdf
implement trylexcept excepsion handler to catch all errors drom the fo.pdfimplement trylexcept excepsion handler to catch all errors drom the fo.pdf
implement trylexcept excepsion handler to catch all errors drom the fo.pdf
 
In 2012- Northland had real GDP of $4-21 billion and a population of 2.pdf
In 2012- Northland had real GDP of $4-21 billion and a population of 2.pdfIn 2012- Northland had real GDP of $4-21 billion and a population of 2.pdf
In 2012- Northland had real GDP of $4-21 billion and a population of 2.pdf
 
In 2015 - the Hawai'i State Legislature passed a bill that sets a goal.pdf
In 2015 - the Hawai'i State Legislature passed a bill that sets a goal.pdfIn 2015 - the Hawai'i State Legislature passed a bill that sets a goal.pdf
In 2015 - the Hawai'i State Legislature passed a bill that sets a goal.pdf
 
In 2015- Los Angeles sued Wells Fargo for unethical customer conduct-.pdf
In 2015- Los Angeles sued Wells Fargo for unethical customer conduct-.pdfIn 2015- Los Angeles sued Wells Fargo for unethical customer conduct-.pdf
In 2015- Los Angeles sued Wells Fargo for unethical customer conduct-.pdf
 
In 2001- the federal government enacted a law that forbade any student.pdf
In 2001- the federal government enacted a law that forbade any student.pdfIn 2001- the federal government enacted a law that forbade any student.pdf
In 2001- the federal government enacted a law that forbade any student.pdf
 
In 2000 - the CPI was 152-5- and the price of an economics textbook wa.pdf
In 2000 - the CPI was 152-5- and the price of an economics textbook wa.pdfIn 2000 - the CPI was 152-5- and the price of an economics textbook wa.pdf
In 2000 - the CPI was 152-5- and the price of an economics textbook wa.pdf
 
In 1994- 52- of parents with children in high school felt that it was.pdf
In 1994- 52- of parents with children in high school felt that it was.pdfIn 1994- 52- of parents with children in high school felt that it was.pdf
In 1994- 52- of parents with children in high school felt that it was.pdf
 
In 1626- Dutchman Peter Minuit purchased Manhattan Island from a local.pdf
In 1626- Dutchman Peter Minuit purchased Manhattan Island from a local.pdfIn 1626- Dutchman Peter Minuit purchased Manhattan Island from a local.pdf
In 1626- Dutchman Peter Minuit purchased Manhattan Island from a local.pdf
 
In 1945- the United Nation was formed to replace _____- Responses- NAT.pdf
In 1945- the United Nation was formed to replace _____- Responses- NAT.pdfIn 1945- the United Nation was formed to replace _____- Responses- NAT.pdf
In 1945- the United Nation was formed to replace _____- Responses- NAT.pdf
 
imported a data file with 7 variables how can i take two variables cal.pdf
imported a data file with 7 variables how can i take two variables cal.pdfimported a data file with 7 variables how can i take two variables cal.pdf
imported a data file with 7 variables how can i take two variables cal.pdf
 
Imagine that you are an environmental scientist who has been hired to.pdf
Imagine that you are an environmental scientist who has been hired to.pdfImagine that you are an environmental scientist who has been hired to.pdf
Imagine that you are an environmental scientist who has been hired to.pdf
 
ILLUSTRATION 21 P Company Pro Forma Balance Sheet Giving Effect to Pro.pdf
ILLUSTRATION 21 P Company Pro Forma Balance Sheet Giving Effect to Pro.pdfILLUSTRATION 21 P Company Pro Forma Balance Sheet Giving Effect to Pro.pdf
ILLUSTRATION 21 P Company Pro Forma Balance Sheet Giving Effect to Pro.pdf
 
Ifyou have an embryo composed of multiple layers of cells- You examine.pdf
Ifyou have an embryo composed of multiple layers of cells- You examine.pdfIfyou have an embryo composed of multiple layers of cells- You examine.pdf
Ifyou have an embryo composed of multiple layers of cells- You examine.pdf
 
If you have the following resources- a- Programmer analyst b- Software.pdf
If you have the following resources- a- Programmer analyst b- Software.pdfIf you have the following resources- a- Programmer analyst b- Software.pdf
If you have the following resources- a- Programmer analyst b- Software.pdf
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
cupulin
 

Recently uploaded (20)

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 

import java-util-ArrayList- import java-util-Collections- import java-.pdf

  • 1. import java.util.ArrayList; import java.util.Collections; import java.util.List; import static java.lang.System.out; public class homework { public static void main(String[] args) { List<Integer> list = new ArrayList<>(); for (int i = 0; i < 10; i++) list.add(int) (Math.random()* 10) + 1); Collections.sort(list); System.out.println("The list id : " + list); int index =linearSearch(list, 10); if (index >+ 0) System.out.println("Linear search: the number 5 was found at index " + index); else
  • 2. System.out.println("Linear search: the number 5 is not found "); List<String> names = new ArrayList<>(); names.add("Tyson"); names.add("John"); names.add("Edgar"); names.add("LouLou"); Collections.sort(list); System.out.println("The names are : " + names); index = linearSearch(names, "JOhn"); if (index >= 0) System.out.println("Linear search: Edgar was found at index " + names); else
  • 3. System.out.println("Linear search: Edgar is not found" + names); } public static <E> int linearSearch(List<E> lsit, E data) { for (int i = 0; i < list.size(); i++) if (list.get(i).equals(data)) return i; return -1; } } Chapter 14 - Linear Search and Binary Search - Assignment Due Wednesday by 11:59pm P Points 100 Submitting a text entry box or a file upload Allowed Attempts 1 Available until Mar 1 at 11:59pm Modify the binarySearch method shown in the video lecture so that it's generic. Test it with at least two types to make sure it works. Hint 1: Examine the review problem and its solution, which modifies the linear search algorithm in the same way. Hint 2: Your binarySearch method signature should be: "private static < E extends Comparable > boolean binarySearch(List list, E data): Turn in the following, - The source files (no zip file, just the individual java files). - A screen shot of your program in action. It should show the result of the test run.