{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2-2 - Problem Solving with Computers-II CS 24 February 2...

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Problem Solving with Computers-II CS 24 February 2, 2010 1
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
Announcements Final feedback Wednesday’s Lab section Binary search Running time comparison of linear and binary search Exceptions Programming project Start working on it! 2
Image of page 2
Recap Abstract Data Types Specification (What?) Implementation (How?) Unsorted lists Array-based implementation Pointer-based implementation Time complexity Sorted lists 3
Image of page 3

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

View Full Document Right Arrow Icon
Lecture Plan Sorted Lists Everything the same as unsorted lists except GetNextItem needs to return items in sorted order Change InsertItem and DeleteItem so that list is always maintained in a sorted order Modifications are less frequent than lookup Improve searching for an item 4
Image of page 4
ADT Sorted/Unsorted List Transformers MakeEmpty InsertItem DeleteItem Observers IsFull GetLength RetrieveItem Iterators ResetList GetNextItem change state observe state process all 5
Image of page 5

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

View Full Document Right Arrow Icon
6 Member functions Which member function specifications and implementations must change? InsertItem DeleteItem
Image of page 6
7 InsertItem for SortedList ADT (array) Find proper location for the new element in the sorted list. Create space for the new element by moving down all the list elements that will follow it. Put the new element in the list. Increment length.
Image of page 7

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

View Full Document Right Arrow Icon
Array Implementation InsertItem Initialize location to position of first item Set moreToSearch to (have not examined Info(last)) while moreToSearch switch (item.ComparedTo(Info(location))) case LESS :
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the 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