{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Tutorial 10

Tutorial 10 - CS 134 Tutorial 10 ADT Table& Asymptotic...

This preview shows pages 1–3. Sign up to view the full content.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 134 Tutorial 10: ADT Table & Asymptotic Analysis CS 134 Tutors Winter 2008 1 ADT Table 1.1 Summary of Important Points • A Table is a collection of key-value pairs • The keys are stored in KeyedItem Objects. • Keys must be unique and of type Comparable • The major operations of the TableInterface are: public boolean isEmpty() public int length() public KeyedItem retrieve(Comparable searchKey) public KeyedItem delete(Comparable searchKey) public void insert(KeyedItem newItem) • The major operations of the KeyedItem class are: public KeyedItem(Comparable theKey) public KeyedItem(Comparable theKey, Object theValue) public Comparable getKey() public Object getValue() public void setValue(Object theValue) 1 1.2 Example -“Passing CS 125” Consider a Table ( cs125CourseList ) which holds key-value pairs. The keys are the students’ userIDs and the values are the students’ final marks in CS 125. Implement a method that, given an array of userIDs for students in CS 125, it will go through the Table, delete students who passed CS 125 and insert these students into the cs134CourseList . Students who did not pass CS 125 should stay in the CS 125 course list. Essentially, your method is updating the cs134 course list for the upcoming term. // pre: cs125CourseList != null, cs134CourseList != null, userIDs != null // userIDs is an array of userIDs for students currently in CS 125 // post: cs125CourseList contains only students who did not pass CS 125; // cs134CourseList contains students who passed CS 125...
View Full Document

{[ snackBarMessage ]}

Page1 / 12

Tutorial 10 - CS 134 Tutorial 10 ADT Table& Asymptotic...

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

View Full Document
Ask a homework question - tutors are online