Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement a city database using unordered lists.Each database record contains th

ID: 3621234 • Letter: I

Question


Implement a city database using unordered lists.Each database record contains the name of the city(a string of arbitrary length) and the coordinates of the city expressed as integer x and y coordinates.Your database should allow records to be inserted,deleted name or coordinate,and searched name or coordinate.
Another operation that should be supported is to print all records within a given distance of a specified point.Implement the database using an array based list implementation,and then a linked list implementation.Collect running time statistics for each operation in both implementations.What are your conclusions about the relative advantages and disadvantages of the 2 implementations?Would storing records on the list in alphabetical order city name speed any of the operations?Would keeping the list in alphabetical order slow any of the operations

Explanation / Answer

Both Linked Lists and Arrays can be used to store linear data of similar types. Both of them have some advantages and disadvantages over each other.

Features/advantages/disadvantages of array:

1.       Array internally uses dynamic array to store the elements.

2.       The size of the arrays is fixed, The upper limit of the number of elements is known.

3.       Inserting a new element in an array of elements is expensive.

Features/advantages/disadvantages of linked list:

1.       Size is not fixed, it is dynamic.

2.       Insertion and deletion is much easier.

3. The elements should be accessed sequentially.

4.       Extra memory space is required.

Sorted or unsorted list:

·         For the unsorted list, always have to check each item to find possible doubles, which lead to a pointer stepping forward for each visited node.

·         For the sorted list, only have to search forward this way until the first element appears in the list which has a greater value.

·         It is much more cost effective to insert a new element into priority queue than to resort everything on each such intervals.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote