CISC 2200 Lecture Notes - Lecture 7: Move, Linked List, Search Algorithm

16 views2 pages

Document Summary

Sorted list: logical level: only change from unsorted list is guaranteeing list elements are sorted, order is determined by itemtype"s compareto method, putitem and deleteitem pre and post . Sorted list: application level: nothing has changed for the user. Sorted list: implementation level: few changes are needed to implement the sorted list, putitem, delete item : ensure list remains sorted, getitem can be improved, 1st attempt: will implement as array-based list. While (location < length && item. compareto(info[location]) == greater) for (int i = length - 1; i >= location; i--) // assume that the item is in the list. //we dont really have to delete anything just move up. For (int i = location +1]; i > length; i++) // this function can be improved with binary search. //simple optimization: stop searching the list when we encounter an item greater than what we"re searching for.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents