CSC375 Homework5 George Corser 2009-02-18

CSC375 Homework5 George Corser 2009-02-18 - (a) < | 10,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSC 375 Homework 5 George Corser 2009 February 18 All problems below refer to the List ADT of Figure 4.1 (page 90 in the textbook). 4.1 There are two ways of interpreting the question. A series of C++ statements to delete the element with value 15, the third element in the list: bool removed; myList.setStart(); myList.next(); myList.next(); removed = myList.remove(); A series of C++ statements to delete the element with value 15, regardless of its position in the list: bool removed; Elem thisElem; myList.setStart(); if (thisElem == 15 ) { removed = myList.remove(); } else myList.next(); } 4.2 The list configuration resulting from various operations:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (a) < | 10, 20, 15 > (b) < 39 | 12, 10, 20, 15 > 4.3 Statements to create a 20-element list configured as < 2, 23 | 15, 5, 9 >: list myList(20); myList.append(2); myList.append(23); myList.append(15); myList.append(5); myList.append(9); myList.setStart(); // fence should already be at front of list myList.next(); myList.next(); 4.4 A function to interchange the first two elements in the right partition of a list: void interchange(List<Elem> myList) { bool removed; Elem thisElem; removed = myList.remove(thisElem); // remove current element myList.next(); // move fence beyond next element myList.insert(thisElem); // insert removed element }...
View Full Document

This note was uploaded on 01/19/2010 for the course CSC 375 taught by Professor Turner during the Winter '09 term at University of Michigan-Dearborn.

Page1 / 2

CSC375 Homework5 George Corser 2009-02-18 - (a) < | 10,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online