Question: Write a program to implement a Dictionary of integers which consists of following methods using JAVA language: SortedArray(int a) : is a constructor which creates

Write a program to implement a Dictionary of integers which consists of following methods using JAVA language:

SortedArray(int a) : is a constructor which creates a dictionary of size a.

void insert(int x) : Inserts element x at its proper position.

o Raise exception Dictionary_Full when dictionary is already full (in case of SortedArray)

o If x already exists, then raise exception Duplicate_Element_Found

boolean delete(int x) : Deletes element x and returns true if x existed otherwise false.

o If x does not exists, the operation raises the exception Element_not_Found, which handles the exception by returning the predecessor and successor of x if x would have existed in the dictionary.

o If the dictionary is empty, it raises the Dictionary_Empty exception which handles it by returning a message "Dictionary Empty"

boolean find(int x) : Returns true if x exists otherwise false and raises the exception Element_not_Found.

void display() : Displays the dictionary's elements in order.

PART A: Implement the dictionary using a sorted array. Here you will be required to implement find operation using binary search. The class name should be SortedArrayTable

PART B: Implement the dictionary using a sorted linked list. Here you will be required to implement find operation using only linear search. The class name should be SortedListTable

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!