Data Str & Algorithm HW Solutions 23

Data Str & Algorithm HW Solutions 23 - L1.next();...

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

View Full Document Right Arrow Icon
4 Lists, Stacks, and Queues 4.1 Call the list in question L1 . L1.setStart(); L1.next(); L1.next(); val = L1.remove(); 4.2 (a) h| 10 , 20 , 15 ± . (b) h 39 | 12 , 10 , 20 , 15 ± . 4.3 list L1(20); L1.append(2); L1.append(23); L1.append(15); L1.append(5); L1.append(9); L1.next(); L1.next(); 4.4 // Interchange the order of current and next elements void switch(List<Elem> L1) { Elem temp; if (!L1.remove(temp)) ERROR;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: L1.next(); L1.insert(temp); } 4.5 template <class Elem> void LList<Elem>::reverse() { // Reverse list contents if(head->next == NULL) return; // First, fix fence by pushing it forward one step if (fence->next == NULL) fence = head; else fence = fence->next; // Now, reverse the list 23...
View Full Document

This note was uploaded on 12/27/2011 for the course MAP 2302 taught by Professor Bell,d during the Fall '08 term at UNF.

Ask a homework question - tutors are online