Question
Asymptotic Analysis Part I: Reversing a List In this lab, you will adding a single method to DoublyLinkedList : reverse() . When called, reverse() should
Asymptotic Analysis
Part I: Reversing a List
In this lab, you will adding a single method to DoublyLinkedList: reverse(). When called, reverse() should reverse the order of nodes in the list. You may use any methods we've implemented in class to accomplish this.
Note: You must reverse this list in-place. That means you may not change node.value; you may only change node.prev and node.next.
When you are finished, add a Driver class with a main method which tests this method.
Part II: Algorithm Analysis
Analyze your algorithm using Big-Oh notation. Assuming the list contains n elements, what is its worst-case running time? Answer in a comment in the main method of your Driver class.
Part III: Problem Analysis
Is your algorithm asymptotically optimal? That is, is it possible to write a function that does better in the worst case? Answer in a comment in the main method of your Driver class.
Code for Doubly Linked List:
public class DoublyLinkedList
} private static class Node
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started