Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE WRITE TE CODE IN JAVA 1. A regular linked list contains a head, nodes with data, and a pointer to the next node as

PLEASE WRITE TE CODE IN JAVA

1. A regular linked list contains a head, nodes with data, and a pointer to the next node as well as a tail. For this assignment, we will be changing the code that creates a linked list in order to get a new and interesting data structure. Before beginning the below questions, implement a linked list on your own. Your linked list only needs an insert function and a traverse function at this point. 2. There is a type of linked list called a circular linked list, where the tail of the linked list is also the head (in graph theory this is called a cycle or circuit btw). Do we need to modify a linked lists implementation code to get this behavior? If we do, how do we change the code, and if we dont, what should we do to get a circular linked list? 3. Change the node structure in the linked list so that it accepts two pointers instead of one: the first pointer will point to the next node on the list, the second pointer will point to the node after the next node. a. Create a traversal function that traverses through the list by skipping every odd node (the first part of this question is a major help here) and printing out the data values in the even nodes. b. Create a traversal function that prints the value in the current node and then prints the value in the node that is 3 spaces from the current node (array positions: 0, 3, 6, 9, etc.). 4. Modify 3 so that one pointer points to the node before the current node and the other points to the node after the current node. This is called a doubly linked list. a. Write a traversal function which traverses the list and once it reaches the tail, it traverses the list in reverse. i. What would happen if your list was circular? 5. Modify your linked list so that it now has these features: a. There is a way to delete nodes based on what data value is in the node. If the value exists delete it. If the value doesnt exist return this data value doesnt exist. b. A way to insert data in sorted order: if you insert a node into the list, itll traverse the list and find the place where the node should go based on its data value. [ex: node_to_insert = 5 -- current_list = 3,4,6,7,11 -- this will insert the node between 4 and 6]. Note that the pointer values will need to change.

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 Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Explain the procedure for valuation of shares.

Answered: 1 week ago

Question

Which months of this year 5 Mondays ?

Answered: 1 week ago

Question

Define Leap year?

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago