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.pdfarishmarketing21
 
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.pdfarpaqindia
 
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.pdffreddysarabia1
 
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.pdffantoosh1
 
Aj unit2 notesjavadatastructures
Aj unit2 notesjavadatastructuresAj unit2 notesjavadatastructures
Aj unit2 notesjavadatastructuresArthik Daniel
 
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.pdfanithacells
 
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.docxStewartt0kJohnstonh
 
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 {.pdfAnkitchhabra28
 
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.pdfaccess2future1
 
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.pdfshettysachin2005
 
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.docxlez31palka
 
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.pdfaryan9007
 
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.pdfmanojmozy
 
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...One97 Communications Limited
 
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.pdfRAJATCHUGH12
 
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.pdfsonunotwani
 

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 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.pdfadhityalapcare
 
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-.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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-.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 
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.pdfadhityalapcare
 

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

Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 

Recently uploaded (20)

Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 

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.