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

Info iconThis 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
Background image of page 1

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

View Full DocumentRight 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
Background 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
Background image of page 3

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

View Full DocumentRight 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
Background 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
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Member functions Which member function specifications and implementations must change? InsertItem DeleteItem
Background 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.
Background image of page 7

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

View Full DocumentRight 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 :
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/26/2010 for the course CS cs24 taught by Professor Singh during the Winter '10 term at UCSB.

Page1 / 28

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

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

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