Question: a ) Write a main ( ) routine in which you allocate nodes and create the following linked list. b ) Write a function called

a) Write a main() routine in which you allocate nodes and create the following linked list.
b) Write a function called listSize that takes a pointer to the start of a linked list and returns
the number of elements in the list.
c) Write another function called listSum that also takes a pointer to the start of a linked list
and returns the sum of the values of all elements in the list.
In your main routine, call and print out the results of these two functions.
d) Question: If we want to change it to a circular linked list, what should we do?
Question 2:
Assume nodes in a linked list are of class ListNode above, except that the type of data is char.
Write a main() routine in which you create the following linked list:
Write a function called printList that takes a pointer to the start of a linked list and prints out all
the nodes in the list in sequence. The interface of this function is
Question 3: Doubly-linked List
Revise Question 2 to create a doubly-linked list and design two functions:
traverseHead2Tail (Node2*head)(...)
traverseTai12Head (Node2*tail)(..)
In main(), test the two functions with the data from question 2.
Question 4:
Design a template swap function with the following interface:
a ) Write a main ( ) routine in which you

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 Programming Questions!