Question: In JAVA Q2.1 Ideate 6 Points Data Structure This question can be solved using a linked list. Each PlaylistNode has a reference to the next

In JAVA

In JAVA Q2.1 Ideate 6 Points Data Structure This question can besolved using a linked list. Each PlaylistNode has a reference to thenext node in the chain. They also hold a piece of informationon each song. In our case, the song's title is all weneed. Write down the class definition for this data structure: public class

Q2.1 Ideate 6 Points Data Structure This question can be solved using a linked list. Each PlaylistNode has a reference to the next node in the chain. They also hold a piece of information on each song. In our case, the song's title is all we need. Write down the class definition for this data structure: public class PlaylistNode { // Declare instance variables Enter your answer here public PlaylistNode(T title) { Enter your answer here } public String getTitle() { Enter your answer here public void setTitle(t input) { Enter your answer here } public PlaylistNode getNext() { Enter your answer here } public void setNext (PlaylistNode nex ut) { Enter your answer here } } Q2.3 8 Points How can you reverse a simple 2-song playlist, given the first (head) node? Return the new head node. Input: Loving Is Easy" -> "Back Pocket" -> NU Return: PlaylistNode Back Pocket" public static PlaylistNode reverseTinyPlaylist(PlaylistNode head) { Enter your answer here } Q2.4 8 Points Now, can you use this approach to reverse the entire playlist? Again, make sure you return the new head of the list. Try to do this without the use of a stack or any extra memory besides the nodes given. No extra nodes need to be created; reverse the list in place. Think of an algorithm and try it out on our examples from before. Example 1 Input: Tokyo Drifting" -> "Highest In The Room" -> "Que Calor" -> NULL Output: Que Calor -> Highest In The Room -> Tokyo Drifting" -> NULL Example 2 Input: Loving Is Easy" -> "Back Pocket" -> NULL Output: Back Pocket" -> "Loving Is Easy -> NULL Code up the algorithm. Vocalize your decisions with your partner, and explain what you are writing. public static PlaylistNode reversePlaylist(PlaylistNode head) { Enter your answer here } Q2.4 8 Points Now, can you use this approach to reverse the entire playlist? Again, make sure you return the new head of the list. Try to do this without the use of a stack or any extra memory besides the nodes given. No extra nodes need to be created; reverse the list in place. Think of an algorithm and try it out on our examples from before. Example 1 Input: Tokyo Drifting" -> "Highest In The Room" -> "Que Calor" -> NULL Output: Que Calor -> Highest In The Room -> Tokyo Drifting" -> NULL Example 2 Input: Loving Is Easy" -> "Back Pocket" -> NULL Output: Back Pocket" -> "Loving Is Easy -> NULL Code up the algorithm. Vocalize your decisions with your partner, and explain what you are writing. public static PlaylistNode reversePlaylist(PlaylistNode head) { Enter your answer here }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!