SlideShare a Scribd company logo
1 of 1
Download to read offline
Urgent Please.
University of Bahrain College of Information Technology Department of Computer Science Second
Semester, 2022-2023 ITCS214 / ITCS215 / ITCS216 (Data Structures) Assignment 1 It is required
to develop an application in Java to represent Set as a data structure using Java built-in class
ArrayList. (A)Write a class called Set to represent a set as an ArrayList and implement various set
operations by using methods of class ArrayList. Assume that the elements of the set are integers.
This class will have the following instance variables: (a) an ArrayList object called list of type
Integer, (b) length: the actual number of elements in the 1 ist. This class will have the following
methods: (1) Constructor without any parameter (default constructor), which uses a default value
of 10 as capacity, creates Arraylist object 1i st and initializes length to 0. (2) Constructor with
parameter cap for capacity of the list. Create ArrayList object 1 ist of capacity equal to parameter
cap and initialize length to 0. (3) Instance method getLength, that returns length. (4) Instance
method i sEmpty to determine whether the set is empty or not. (5) Instance method addElement
that accepts a parameter element of type int. It will insert the element in the list at the end and also
increment length by one. (6) Instance method i sMember that accepts a parameter element of type
int. If element exists in the 1 ist, it will return true, else it will return false. (7) Instance method
subset that accepts a parameter aset of type Set. If aSet is a subset of "this object", it will return
true, else it will return false. Ex: Let A and B be two sets; A={7,4,20,15,12},B={12,15}. As all
elements of B are contained in A, therefore, B is a subset of A.(8) Instance method i sEqual that
accepts a parameter a Set of type Set. The method will return true, if aset is equal to "this object",
else it will return false. Two sets are equal, if they contain the same elements in any order. Ex: Let
A and B be two sets; A={7,4,20,15,12},B={4,7,12,15,20}. As sets A and B contain same elements,
but in different order, therefore, they are equal. (9) Instance method union having a parameter
aset of type Set. The method finds the union of aset with "this object" and returns the result as an
object of type set. Ex: Let A={10,4,20,15,12,18},B={8,10,25,15,20}, C=AB={10,4,20,15,12,18,8,25}
(10) Instance method intersection having a parameter aset of type Set. The method finds the
intersection of aset with "this object" and returns the result as an object of type set. Ex: Let A={10,
4,20,15,12,18},B={8,10,25,15,20}, C=AB={10,20,15} (11) Instance method called print() to print all
the elements of the set. (B) Write a class called SetApplication having only main method. Create
objects of class type Set using different constructors and call methods of class Set to test all
functionalities of class Set.

More Related Content

Similar to Urgent Please University of Bahrain College of Information .pdf

Similar to Urgent Please University of Bahrain College of Information .pdf (20)

15 ruby arrays
15 ruby arrays15 ruby arrays
15 ruby arrays
 
Java10 Collections and Information
Java10 Collections and InformationJava10 Collections and Information
Java10 Collections and Information
 
Java collections
Java collectionsJava collections
Java collections
 
Java.util
Java.utilJava.util
Java.util
 
unit 2.pptx
unit 2.pptxunit 2.pptx
unit 2.pptx
 
Collections
CollectionsCollections
Collections
 
Ppt lesson 12
Ppt lesson 12Ppt lesson 12
Ppt lesson 12
 
STRINGS IN JAVA
STRINGS IN JAVASTRINGS IN JAVA
STRINGS IN JAVA
 
ArrayList.docx
ArrayList.docxArrayList.docx
ArrayList.docx
 
Lec2
Lec2Lec2
Lec2
 
5 collection framework
5 collection framework5 collection framework
5 collection framework
 
Md08 collection api
Md08 collection apiMd08 collection api
Md08 collection api
 
Java collections notes
Java collections notesJava collections notes
Java collections notes
 
Array vs array list
Array vs array listArray vs array list
Array vs array list
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Computer programming 2 Lesson 13
Computer programming 2  Lesson 13Computer programming 2  Lesson 13
Computer programming 2 Lesson 13
 
WDD_lec_06.ppt
WDD_lec_06.pptWDD_lec_06.ppt
WDD_lec_06.ppt
 
Java R20 - UNIT-3.docx
Java R20 - UNIT-3.docxJava R20 - UNIT-3.docx
Java R20 - UNIT-3.docx
 
Collection and framework
Collection and frameworkCollection and framework
Collection and framework
 

More from adityacommunications2

US Civilian Labor Force Participation Rate Civlian Unemplo.pdf
US Civilian Labor Force Participation Rate Civlian Unemplo.pdfUS Civilian Labor Force Participation Rate Civlian Unemplo.pdf
US Civilian Labor Force Participation Rate Civlian Unemplo.pdfadityacommunications2
 
US set to lift covid19 testing requirements for travelers f.pdf
US set to lift covid19 testing requirements for travelers f.pdfUS set to lift covid19 testing requirements for travelers f.pdf
US set to lift covid19 testing requirements for travelers f.pdfadityacommunications2
 
URINARY SYSTEMI Nephron COLORING EXERCISE part it Draw a.pdf
URINARY SYSTEMI Nephron COLORING EXERCISE part it  Draw a.pdfURINARY SYSTEMI Nephron COLORING EXERCISE part it  Draw a.pdf
URINARY SYSTEMI Nephron COLORING EXERCISE part it Draw a.pdfadityacommunications2
 
US Civilian Labor Force Participation Rate Cilitian Unempl.pdf
US Civilian Labor Force Participation Rate Cilitian Unempl.pdfUS Civilian Labor Force Participation Rate Cilitian Unempl.pdf
US Civilian Labor Force Participation Rate Cilitian Unempl.pdfadityacommunications2
 
US Civilian Labor Force Participation Rate Cillian Unemplo.pdf
US Civilian Labor Force Participation Rate Cillian Unemplo.pdfUS Civilian Labor Force Participation Rate Cillian Unemplo.pdf
US Civilian Labor Force Participation Rate Cillian Unemplo.pdfadityacommunications2
 
Urgent Draw the EER diagram for the Hiking Database given .pdf
Urgent  Draw the EER diagram for the Hiking Database given .pdfUrgent  Draw the EER diagram for the Hiking Database given .pdf
Urgent Draw the EER diagram for the Hiking Database given .pdfadityacommunications2
 
Upan denetic analysis ot the canceromis tissue a mutated fo.pdf
Upan denetic analysis ot the canceromis tissue a mutated fo.pdfUpan denetic analysis ot the canceromis tissue a mutated fo.pdf
Upan denetic analysis ot the canceromis tissue a mutated fo.pdfadityacommunications2
 
UPS prides itself on having uptodate information on the pr.pdf
UPS prides itself on having uptodate information on the pr.pdfUPS prides itself on having uptodate information on the pr.pdf
UPS prides itself on having uptodate information on the pr.pdfadityacommunications2
 
Update include ltiostreamgt include ltfstreamgt .pdf
Update  include ltiostreamgt include ltfstreamgt .pdfUpdate  include ltiostreamgt include ltfstreamgt .pdf
Update include ltiostreamgt include ltfstreamgt .pdfadityacommunications2
 
Underground Sandwiches a sandwich shop has the following m.pdf
Underground Sandwiches a sandwich shop has the following m.pdfUnderground Sandwiches a sandwich shop has the following m.pdf
Underground Sandwiches a sandwich shop has the following m.pdfadityacommunications2
 
Update the Assignment 3 code to follow the guidelines below .pdf
Update the Assignment 3 code to follow the guidelines below .pdfUpdate the Assignment 3 code to follow the guidelines below .pdf
Update the Assignment 3 code to follow the guidelines below .pdfadityacommunications2
 
Understand processivity and fidelity Indicate if a given enz.pdf
Understand processivity and fidelity Indicate if a given enz.pdfUnderstand processivity and fidelity Indicate if a given enz.pdf
Understand processivity and fidelity Indicate if a given enz.pdfadityacommunications2
 
Unlike the theory of international trade or the theory of in.pdf
Unlike the theory of international trade or the theory of in.pdfUnlike the theory of international trade or the theory of in.pdf
Unlike the theory of international trade or the theory of in.pdfadityacommunications2
 
Unemployment which is when persons in an economy have lost.pdf
Unemployment  which is when persons in an economy have lost.pdfUnemployment  which is when persons in an economy have lost.pdf
Unemployment which is when persons in an economy have lost.pdfadityacommunications2
 
Unknown case study2 Your patient is a 26 yo male who presen.pdf
Unknown case study2 Your patient is a 26 yo male who presen.pdfUnknown case study2 Your patient is a 26 yo male who presen.pdf
Unknown case study2 Your patient is a 26 yo male who presen.pdfadityacommunications2
 
Una moneda justa se lanza seis veces Cul es la probabilid.pdf
Una moneda justa se lanza seis veces Cul es la probabilid.pdfUna moneda justa se lanza seis veces Cul es la probabilid.pdf
Una moneda justa se lanza seis veces Cul es la probabilid.pdfadityacommunications2
 
Una persona con diabetes T2 debe tratar de controlar los car.pdf
Una persona con diabetes T2 debe tratar de controlar los car.pdfUna persona con diabetes T2 debe tratar de controlar los car.pdf
Una persona con diabetes T2 debe tratar de controlar los car.pdfadityacommunications2
 
Una forma principal en la que los genes tienen un efecto sob.pdf
Una forma principal en la que los genes tienen un efecto sob.pdfUna forma principal en la que los genes tienen un efecto sob.pdf
Una forma principal en la que los genes tienen un efecto sob.pdfadityacommunications2
 
Una fuerte correlacin entre A y B implicara que B es causa.pdf
Una fuerte correlacin entre A y B implicara que B es causa.pdfUna fuerte correlacin entre A y B implicara que B es causa.pdf
Una fuerte correlacin entre A y B implicara que B es causa.pdfadityacommunications2
 
Unit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdf
Unit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdfUnit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdf
Unit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdfadityacommunications2
 

More from adityacommunications2 (20)

US Civilian Labor Force Participation Rate Civlian Unemplo.pdf
US Civilian Labor Force Participation Rate Civlian Unemplo.pdfUS Civilian Labor Force Participation Rate Civlian Unemplo.pdf
US Civilian Labor Force Participation Rate Civlian Unemplo.pdf
 
US set to lift covid19 testing requirements for travelers f.pdf
US set to lift covid19 testing requirements for travelers f.pdfUS set to lift covid19 testing requirements for travelers f.pdf
US set to lift covid19 testing requirements for travelers f.pdf
 
URINARY SYSTEMI Nephron COLORING EXERCISE part it Draw a.pdf
URINARY SYSTEMI Nephron COLORING EXERCISE part it  Draw a.pdfURINARY SYSTEMI Nephron COLORING EXERCISE part it  Draw a.pdf
URINARY SYSTEMI Nephron COLORING EXERCISE part it Draw a.pdf
 
US Civilian Labor Force Participation Rate Cilitian Unempl.pdf
US Civilian Labor Force Participation Rate Cilitian Unempl.pdfUS Civilian Labor Force Participation Rate Cilitian Unempl.pdf
US Civilian Labor Force Participation Rate Cilitian Unempl.pdf
 
US Civilian Labor Force Participation Rate Cillian Unemplo.pdf
US Civilian Labor Force Participation Rate Cillian Unemplo.pdfUS Civilian Labor Force Participation Rate Cillian Unemplo.pdf
US Civilian Labor Force Participation Rate Cillian Unemplo.pdf
 
Urgent Draw the EER diagram for the Hiking Database given .pdf
Urgent  Draw the EER diagram for the Hiking Database given .pdfUrgent  Draw the EER diagram for the Hiking Database given .pdf
Urgent Draw the EER diagram for the Hiking Database given .pdf
 
Upan denetic analysis ot the canceromis tissue a mutated fo.pdf
Upan denetic analysis ot the canceromis tissue a mutated fo.pdfUpan denetic analysis ot the canceromis tissue a mutated fo.pdf
Upan denetic analysis ot the canceromis tissue a mutated fo.pdf
 
UPS prides itself on having uptodate information on the pr.pdf
UPS prides itself on having uptodate information on the pr.pdfUPS prides itself on having uptodate information on the pr.pdf
UPS prides itself on having uptodate information on the pr.pdf
 
Update include ltiostreamgt include ltfstreamgt .pdf
Update  include ltiostreamgt include ltfstreamgt .pdfUpdate  include ltiostreamgt include ltfstreamgt .pdf
Update include ltiostreamgt include ltfstreamgt .pdf
 
Underground Sandwiches a sandwich shop has the following m.pdf
Underground Sandwiches a sandwich shop has the following m.pdfUnderground Sandwiches a sandwich shop has the following m.pdf
Underground Sandwiches a sandwich shop has the following m.pdf
 
Update the Assignment 3 code to follow the guidelines below .pdf
Update the Assignment 3 code to follow the guidelines below .pdfUpdate the Assignment 3 code to follow the guidelines below .pdf
Update the Assignment 3 code to follow the guidelines below .pdf
 
Understand processivity and fidelity Indicate if a given enz.pdf
Understand processivity and fidelity Indicate if a given enz.pdfUnderstand processivity and fidelity Indicate if a given enz.pdf
Understand processivity and fidelity Indicate if a given enz.pdf
 
Unlike the theory of international trade or the theory of in.pdf
Unlike the theory of international trade or the theory of in.pdfUnlike the theory of international trade or the theory of in.pdf
Unlike the theory of international trade or the theory of in.pdf
 
Unemployment which is when persons in an economy have lost.pdf
Unemployment  which is when persons in an economy have lost.pdfUnemployment  which is when persons in an economy have lost.pdf
Unemployment which is when persons in an economy have lost.pdf
 
Unknown case study2 Your patient is a 26 yo male who presen.pdf
Unknown case study2 Your patient is a 26 yo male who presen.pdfUnknown case study2 Your patient is a 26 yo male who presen.pdf
Unknown case study2 Your patient is a 26 yo male who presen.pdf
 
Una moneda justa se lanza seis veces Cul es la probabilid.pdf
Una moneda justa se lanza seis veces Cul es la probabilid.pdfUna moneda justa se lanza seis veces Cul es la probabilid.pdf
Una moneda justa se lanza seis veces Cul es la probabilid.pdf
 
Una persona con diabetes T2 debe tratar de controlar los car.pdf
Una persona con diabetes T2 debe tratar de controlar los car.pdfUna persona con diabetes T2 debe tratar de controlar los car.pdf
Una persona con diabetes T2 debe tratar de controlar los car.pdf
 
Una forma principal en la que los genes tienen un efecto sob.pdf
Una forma principal en la que los genes tienen un efecto sob.pdfUna forma principal en la que los genes tienen un efecto sob.pdf
Una forma principal en la que los genes tienen un efecto sob.pdf
 
Una fuerte correlacin entre A y B implicara que B es causa.pdf
Una fuerte correlacin entre A y B implicara que B es causa.pdfUna fuerte correlacin entre A y B implicara que B es causa.pdf
Una fuerte correlacin entre A y B implicara que B es causa.pdf
 
Unit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdf
Unit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdfUnit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdf
Unit 11 Forum 6 6 unread replies 6 6 replies Find a video .pdf
 

Recently uploaded

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 

Recently uploaded (20)

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 

Urgent Please University of Bahrain College of Information .pdf

  • 1. Urgent Please. University of Bahrain College of Information Technology Department of Computer Science Second Semester, 2022-2023 ITCS214 / ITCS215 / ITCS216 (Data Structures) Assignment 1 It is required to develop an application in Java to represent Set as a data structure using Java built-in class ArrayList. (A)Write a class called Set to represent a set as an ArrayList and implement various set operations by using methods of class ArrayList. Assume that the elements of the set are integers. This class will have the following instance variables: (a) an ArrayList object called list of type Integer, (b) length: the actual number of elements in the 1 ist. This class will have the following methods: (1) Constructor without any parameter (default constructor), which uses a default value of 10 as capacity, creates Arraylist object 1i st and initializes length to 0. (2) Constructor with parameter cap for capacity of the list. Create ArrayList object 1 ist of capacity equal to parameter cap and initialize length to 0. (3) Instance method getLength, that returns length. (4) Instance method i sEmpty to determine whether the set is empty or not. (5) Instance method addElement that accepts a parameter element of type int. It will insert the element in the list at the end and also increment length by one. (6) Instance method i sMember that accepts a parameter element of type int. If element exists in the 1 ist, it will return true, else it will return false. (7) Instance method subset that accepts a parameter aset of type Set. If aSet is a subset of "this object", it will return true, else it will return false. Ex: Let A and B be two sets; A={7,4,20,15,12},B={12,15}. As all elements of B are contained in A, therefore, B is a subset of A.(8) Instance method i sEqual that accepts a parameter a Set of type Set. The method will return true, if aset is equal to "this object", else it will return false. Two sets are equal, if they contain the same elements in any order. Ex: Let A and B be two sets; A={7,4,20,15,12},B={4,7,12,15,20}. As sets A and B contain same elements, but in different order, therefore, they are equal. (9) Instance method union having a parameter aset of type Set. The method finds the union of aset with "this object" and returns the result as an object of type set. Ex: Let A={10,4,20,15,12,18},B={8,10,25,15,20}, C=AB={10,4,20,15,12,18,8,25} (10) Instance method intersection having a parameter aset of type Set. The method finds the intersection of aset with "this object" and returns the result as an object of type set. Ex: Let A={10, 4,20,15,12,18},B={8,10,25,15,20}, C=AB={10,20,15} (11) Instance method called print() to print all the elements of the set. (B) Write a class called SetApplication having only main method. Create objects of class type Set using different constructors and call methods of class Set to test all functionalities of class Set.