Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago