page168.html
来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 68 行
HTML
68 行
<HTML><HEAD><TITLE>Ordered Lists and Sorted Lists</TITLE></HEAD><BODY bgcolor="#FFFFFF"> <a href="../index.html" target="_top"><img src="../icons/usins.gif" alt="Logo" align=right></a><b>Data Structures and Algorithms with Object-Oriented Design Patterns in Python</b><br><A NAME="tex2html3131" HREF="page169.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html3129" HREF="book.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html3123" HREF="page167.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html3133" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H1><A NAME="SECTION007000000000000000000">Ordered Lists and Sorted Lists</A></H1><P><A NAME="chaplists"> </A><P>The most simple,yet one of the most versatile containers is the <em>list</em><A NAME=8540> </A>.In this chapter we consider lists as <em>abstract data types</em>.A list is a series of items.In general,we can insert and remove items from a listand we can visit all the items in a listin the order in which they appear.<P>In this chapter we consider two kinds of lists--ordered lists and sorted lists.In an <em>ordered list</em><A NAME=8543> </A>the order of the items is significant.Consider a list of the titles of the chapters in this book.The order of the items in the listcorresponds to the order in which they appear in the book.However, since the chapter titles are not sorted alphabetically,we cannot consider the list to be sorted.Since it is possible to change the order of the chapters in book,we must be able to do the same with the items of the list.As a result,we may insert an item into an ordered list at any position.<P>On the other hand,a <em>sorted list</em><A NAME=8545> </A>is one in which the order of the items is defined by some collating sequence.For example,the index of this book is a sorted list.The items in the index are sorted alphabetically.When an item is inserted into a sorted list,it must be inserted at the correct position.<P>As shown in Figure <A HREF="page168.html#figclasses3"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>,two abstract classes are used to represent the different list abstractions--<tt>OrderedList</tt> and <tt>SortedList</tt>.The various list abstractions can be implemented in many ways.In this chapter we examine implementationsbased on the <em>array</em> and the <em>linked list</em>foundational data structures presented in Chapter <A HREF="page81.html#chapfds"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.<P><P><A NAME="8556"> </A><A NAME="figclasses3"> </A> <IMG WIDTH=575 HEIGHT=292 ALIGN=BOTTOM ALT="figure8552" SRC="img731.gif" ><BR><STRONG>Figure:</STRONG> Object class hierarchy.<BR><P><BR> <HR><UL> <LI> <A NAME="tex2html3134" HREF="page169.html#SECTION007100000000000000000">Ordered Lists</A><LI> <A NAME="tex2html3135" HREF="page190.html#SECTION007200000000000000000">Sorted Lists</A><LI> <A NAME="tex2html3136" HREF="page203.html#SECTION007300000000000000000">Exercises</A><LI> <A NAME="tex2html3137" HREF="page204.html#SECTION007400000000000000000">Projects</A></UL><HR><A NAME="tex2html3131" HREF="page169.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html3129" HREF="book.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html3123" HREF="page167.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html3133" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <P><ADDRESS><img src="../icons/bruno.gif" alt="Bruno" align=right><a href="../copyright.html">Copyright © 2003</a> by <a href="../signature.html">Bruno R. Preiss, P.Eng.</a> All rights reserved.</ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?