Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class named Person that contains a string data field named ID for the person's ID and a LinkedList (from java.util.LinkedList ) data field

image text in transcribed

image text in transcribed

Create a class named Person that contains a string data field named ID for the person's ID and a LinkedList (from java.util.LinkedList) data field named phoneNums for all the numbers that the person possesses (the numbers saved in the LinkedList should be String). Provide an abstract data type PBList, which stands for phone book list, that can be used to represent sequences of objects of class Person Note: The IDs are unique for each person but a person can have multiple entries in the phonebook. In other words there can be multiple entries in PBList with the same ID which belong to the same person The abstract data type PBList must support the following operations int size() - Returns the current size of the list (number of entries in the phonebook) void addPerson(int i, Person person) - Adds a new element before the i-th element of the list (the index of the first entry is 0). If i is greater than the number of the elements in the list, adds it to the end boolean addNumber(String ID, String phoneNum) - Adds a new phone number to the first occurrence of ID in the list and returns true. Returns false if ID does not exist in the list. . boolean delete(int i) - Deletes the i-th element of the list and returns true. In the case when the list has less than i elements returns false . Person search(int i) - Returns the i-th element of the list. In the case when the sequence has less than i elements, it returns null e void merge0 Merges the phone numbers of all the entries with the same ID Provide two implementations of this abstract data structure: a class named PBArrayList and another class named PBLinkedList. The first one must use an array to store the sequence of persons and the second a singly linked list. Notes regarding the implementation of these ADT Using built-in Java classes, such as ArrayList and LinkedList, is not allowed (LinkedList is allowed only for the implementation and usage of class Person) . . Do not forget the issue of managing the "real estate" (i.e., the fixed size of the array) in the case of the PBArrayList implementation (e.g. you will need to internally re-allocate the array as it grows too much) Write a demo application utilizing this abstract data structure. Your application should include the following components . Two static methods: int prefixCountArrayList(PBArrayList list, String prefix) and int prefixCountLinkedList(PBLinkedList list, String prefix) which return the total number of entries in the phonebook with the phone number matching the prefix. Note: The running time of this method should be linear in the size of the phone book. Create a class named Person that contains a string data field named ID for the person's ID and a LinkedList (from java.util.LinkedList) data field named phoneNums for all the numbers that the person possesses (the numbers saved in the LinkedList should be String). Provide an abstract data type PBList, which stands for phone book list, that can be used to represent sequences of objects of class Person Note: The IDs are unique for each person but a person can have multiple entries in the phonebook. In other words there can be multiple entries in PBList with the same ID which belong to the same person The abstract data type PBList must support the following operations int size() - Returns the current size of the list (number of entries in the phonebook) void addPerson(int i, Person person) - Adds a new element before the i-th element of the list (the index of the first entry is 0). If i is greater than the number of the elements in the list, adds it to the end boolean addNumber(String ID, String phoneNum) - Adds a new phone number to the first occurrence of ID in the list and returns true. Returns false if ID does not exist in the list. . boolean delete(int i) - Deletes the i-th element of the list and returns true. In the case when the list has less than i elements returns false . Person search(int i) - Returns the i-th element of the list. In the case when the sequence has less than i elements, it returns null e void merge0 Merges the phone numbers of all the entries with the same ID Provide two implementations of this abstract data structure: a class named PBArrayList and another class named PBLinkedList. The first one must use an array to store the sequence of persons and the second a singly linked list. Notes regarding the implementation of these ADT Using built-in Java classes, such as ArrayList and LinkedList, is not allowed (LinkedList is allowed only for the implementation and usage of class Person) . . Do not forget the issue of managing the "real estate" (i.e., the fixed size of the array) in the case of the PBArrayList implementation (e.g. you will need to internally re-allocate the array as it grows too much) Write a demo application utilizing this abstract data structure. Your application should include the following components . Two static methods: int prefixCountArrayList(PBArrayList list, String prefix) and int prefixCountLinkedList(PBLinkedList list, String prefix) which return the total number of entries in the phonebook with the phone number matching the prefix. Note: The running time of this method should be linear in the size of the phone book

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago