{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CSC375 Homework5 George Corser 2009-02-18

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

Info icon This 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(); while (myList.getValue(thisElem) && !removed) { if (thisElem == 15 ) { removed = myList.remove(); } else myList.next(); } 4.2 The list configuration resulting from various operations:
Image of page 1

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

View Full Document Right Arrow Icon
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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern