logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Steven HughesEducation
(5/5)

508 Answers

Hire Me
expert
Seth PowelllEngineering
(5/5)

688 Answers

Hire Me
expert
Garard BerwickkCriminology
(5/5)

951 Answers

Hire Me
expert
Pragun SangwanTechnical writing
(5/5)

825 Answers

Hire Me
Others
(5/5)

In this assignment you are to modify the SinglyLinkedList ADT class provided to you by

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

In this assignment you are to modify the SinglyLinkedList ADT class provided to you by (1) adding two methods to the class and then (2) by reading and processing a stream of list transactions that add, insert, and remove from a linked list created as an object of the SinglyLinkedList (with your added methods), hereafter referred to using the

abbreviation SLL.

 

The transactions to be processed are stored in a sequential text file that I provide with the assignment, one

transaction per line. The file is read one line (or transaction) at a time from the first to last, each line (transaction) is interpreted as to what’s to be done based on a “transaction code” (add, insert, or remove), and for each line code the appropriate transaction is executed to perform the transaction. This is referred to as batch processing.

 

The transaction processing is handled by SLL methods. However, you must add two methods to the SLL code I provide in order to successfully process the transaction stream:

 

1. insertAfter takes two parameters, an integer index (0 and higher) and a string value, creates a newly created node object (NN) with the string value as the new node’s element, and inserts that node object after the ith element (specified by the index parameter) of the SLL. For the purpose of this method the items of the SLL are numbered starting with 1, not 0. Inserting after element 0 means placing the new node at the front of the SLL. If the value of the index is greater than the number of items in the SLL the new node is to be inserted after the last item (after the rear or tail) and becomes the new rear or tail.

 

2. insertElt takes three parameters: (1) a string value used as the element for a newly created node (NN) object that is to be inserted into the SLL, (2) an indicator (“B” or “A”) specifying whether the NN is to be inserted before or after a specified SLL node, and (3) a string value of the element of a node (EN) already in the SLL (maybe) before or after which the NN will be inserted. This method searches the list by iterating through it using the “next” pointer and comparing the EN value with those in each SLL node it encounters. When the EN value matches the SLL node, the new node NN is inserted before (“B”) or after (“A”) the SLL node that was just found. If the string value in EN, parameter (3), is not found in the SLL, the NN is added to the end (tail) of the list.

 

Both methods will take in the string parameter and create (instantiate) a new node (NN). They will then execute their code to insert the NN into the SLL. Cases that need to be handled include (1) inserting into an empty SLL, (2) inserting as the first or head element (index 0 for insertAfter, and ‘B’efore the named head element in insertElt), (3) inserting into the interior of the list (between two existing nodes), and (4) inserting as the last/tail node (when the index exceeds the size for insertAfter, and when the NN element is not found in the SLL for insertElt).

 

Pseudo-code for insertAfter into the interior of the SLL (case (3) above):

 

1. instantiate a new node NN to be inserted into the SLL

2. navigate the SLL starting with the head and find the node x you want to insert after

3. set NN’s next pointer to the value of x’s next pointer

4. set x’s next pointer point to NN (the order is important)

 

Pseudo-code for insertElt into the interior of the SLL (case (3) above)t:

 

1. instantiate a new node NN to be inserted into the SLL

2. navigate the SLL starting with the head and find the node x you want to insert before or after

3. when navigating also save the pointer to the node just before x as bx

4. if inserting ‘A’fter:

a. set NN’s next pointer to the value of x’s next pointer

b. set x’s next pointer point to NN (the order is important)

 

5. if inserting ‘B’efore:

a. set NN’s next pointer to point to x

b. set bx’s next pointer point to NN

 

 

After the methods are created they are to be tested using a transaction stream to be provided as a list of strings for input, similar to the way the expressions were provided in a previous assignment. These could also easily be provided in a text file that could be read and processed in the same way. The transactions consist of comma-

separated elements: (1) a transaction code indicating which SLL ADT operation is to be executed, and (2) a value(s) to use when executing an add or insert, and no value when the operation is ‘remove’.

(5/5)
Attachments:

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme