HW #5 - splitAt . 8. Write the definition of the function...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
David Carothers CS 230 10/16/07 Homework # 5 Excercises 2. What is the output of the following code? a. cout<<list-> info; b. cout<<A->info; c. cout<<B->link->info; d. cout<<list->link->link->info; 5. Add the function splitAt to split a linked list at a node whose info is given. Suppose oldList points to a list with elements: 10, 18, 34, 6, 28, 92, 56, 48 And the list is to be split at the node whose info is 6. The two sublists are then 10, 18, 34, and 6, 28, 92, 56, 48 a. add the following function to the class linkedListType: void splitAt(linkedListType<Type> &secondList, const Type& item); Consider the following statements linkedListType<int> myList; Suppose myList points to a list with the elements 34 65 18 39 27 89 12 (In this order). The statement myList.splitAt(otherList, 18); Splits myList in to two sublists: myList points to the list with the elements 34 65 and otherlist points to the sublist with the elements 18, 39, 27, 89, 12. b. Write the definition of the function template to implement the operation
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: splitAt . 8. Write the definition of the function template back to return the last element of an ordered linked list. Moreover, add this operation to the class orderedLinkedListType. 11. This chapter defined and identified various operations on a linked ist with header and trailer nodes. a. write the definition of the class that defines a linked list with header and trailer nodes as an ADT. b. Write the definitions of the member functions of the class defined in part a. c. Write a program to test various operations of the class defined in part a. 13. Write the definition of the function template seqSearch to implement a sequential search on a list object. Its prototype is : Template&lt;class elemType&gt; List&lt;elemType&gt;::iterator seqsearch (list&lt;elemType&gt; &amp;searchList, const elemType&amp; item) Also write a program to test the function seqSearch ....
View Full Document

Ask a homework question - tutors are online