For this assignment, you are to write a program which implements a Sorted List data structure using a circular array-based implementation and a driver program that will test this implementation. The Sorted List ADT is a linear collection of data in which all elements are stored in sorted order. Your implementation has to store a single int value as each element of the list and support the following operations: 1. add(x) – adds the integer x to the list. The resulting list should remain sorted in increasing order. The time complexity of this operation should be 0(N), where N is the size of the list. 2. removeFirst() – deletes the first integer from the list and returns its value. The remaining list should remain sorted. Time complexity of this operation should be 0(1). 3. removelast() – deletes the last integer from the list and returns its value. The remaining list should remain sorted. Time complexity of this operation should be 0(1). 4. exists(x) – returns true if the integer x exists in the list and false otherwise. Time complexity of this operation should be O(log N). 5. tostring() – returns a string representing the sorted set as a space separated list. 0 (N). Requirements Your program should do the following: 1. Implement the Sorted List as the CircularArraySortedList dlass with all the operations implemented using separate methods. 2. In the main method of the same class, implement a driver program that first creates an empty CircularArraySortedList. Then, it repeatedly prompts the user for an input command, performs the corresponding operation, and prints the list to the screen. The prompts should stop when the user types "q". Your program should allow for the following operations to be entered: "ax", where x is some int value - this will perform the add(x) operation on the list "rf"- this will perform the removeFirst() operation and print the returned value to the screen "rl" - this will perform the removeLlast() operation and print the returned value to the screen "ex" - this will perform the exists(x) operation and print the return value ("true" or "false")

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Introduction
For this assignment, you are to write a program which implements a Sorted List data structure using a circular
array-based implementation and a driver program that will test this implementation.
The Sorted List ADT is a linear collection of data in which all elements are stored in sorted order. Your
implementation has to store a single int value as each element of the list and support the following operations:
1. add(x) – adds the integer x to the list. The resulting list should remain sorted in increasing order. The time
complexity of this operation should be 0(N), where N is the size of the list.
2. removefirst() - deletes the first integer from the list and returns its value. The remaining list should
remain sorted. Time complexity of this operation should be 0(1).
3. removelast() – deletes the last integer from the list and returns its value. The remaining list should
remain sorted. Time complexity of this operation should be 0(1).
4. exists(x) – returns true if the integer x exists in the list and false otherwise. Time complexity of this
operation should be 0(log N).
5. tostring() – returns a string representing the sorted set as a space separated list. O(N).
Requirements
Your program should do the following:
1. Implement the Sorted List as the CircularArraySortedList class with all the operations
implemented using separate methods.
2. In the main method of the same class, implement a driver program that first creates an empty
CircularArraySortedList. Then, it repeatedly prompts the user for an input command, performs
the corresponding operation, and prints the list to the screen. The prompts should stop when the user
types "q". Your program should allow for the following operations to be entered:
"a x", where x is some int value – this will perform the add(x) operation on the list
"rf" - this will perform the removeFirst() operation and print the returned value to the screen
"rl" - this will perform the removelast() operation and print the returned value to the screen
"e x" – this will perform the exists(x) operation and print the return value ("true" or "false")
Transcribed Image Text:Introduction For this assignment, you are to write a program which implements a Sorted List data structure using a circular array-based implementation and a driver program that will test this implementation. The Sorted List ADT is a linear collection of data in which all elements are stored in sorted order. Your implementation has to store a single int value as each element of the list and support the following operations: 1. add(x) – adds the integer x to the list. The resulting list should remain sorted in increasing order. The time complexity of this operation should be 0(N), where N is the size of the list. 2. removefirst() - deletes the first integer from the list and returns its value. The remaining list should remain sorted. Time complexity of this operation should be 0(1). 3. removelast() – deletes the last integer from the list and returns its value. The remaining list should remain sorted. Time complexity of this operation should be 0(1). 4. exists(x) – returns true if the integer x exists in the list and false otherwise. Time complexity of this operation should be 0(log N). 5. tostring() – returns a string representing the sorted set as a space separated list. O(N). Requirements Your program should do the following: 1. Implement the Sorted List as the CircularArraySortedList class with all the operations implemented using separate methods. 2. In the main method of the same class, implement a driver program that first creates an empty CircularArraySortedList. Then, it repeatedly prompts the user for an input command, performs the corresponding operation, and prints the list to the screen. The prompts should stop when the user types "q". Your program should allow for the following operations to be entered: "a x", where x is some int value – this will perform the add(x) operation on the list "rf" - this will perform the removeFirst() operation and print the returned value to the screen "rl" - this will perform the removelast() operation and print the returned value to the screen "e x" – this will perform the exists(x) operation and print the return value ("true" or "false")
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linked List Representation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education