Question
10. (12 points) Consider a singly-linked list containing the following animals (in this order): cow, dog, duck, cat, and canary. (a) Draw a picture of
10. (12 points) Consider a singly-linked list containing the following animals (in this order): cow, dog, duck, cat, and canary.
-
(a) Draw a picture of the linked list. Be sure to include a reference to beginning of the list called head.
-
(b) Suppose that a reference called prev points to the node containing dog. Show how to remove the node containing duck. Draw a picture and give the pseudocode.
-
(c) Suppose that a reference called prev points to the node containing cat. Show how to insert a node containing moose between cat and canary. Draw a picture and give the pseudocode.
-
(d) What is a header node? Defend the existence or absence of such a node in the linked list you have drawn above.
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