?? 英漢對照典型數據結構—棧和隊列.htm
字號:
<DIV id=cont_right style="WIDTH: 495px">The data types arrays and records
are native to many programming languages.By using the pointer data type
and dynamic memory allocation,many programming languages also provide the
facilities for constructing linked structures.Arrays,records,and linked
structures provide the building blocks for implementing what we might call
higher-level abstractions.The first two higher-level abstract data types
that we take up-stacks and queues-are extremely important to
computing.<BR><BR>A stack is a data type whose major attributes are
determined by the rules governing the insertion and deletion of its
elements.The only element that can be deleted or removed is the one that
was inserted most recently.Such a structure is said to have a“last
in,first out”(LIFO)behavior,or protocol.The simplicity of the data type
stack belies [1] its importance.Many computer systems have stacks built
[2] into their circuitry and have machine-level instructions to operate
the hardware stack.The sequencing of calls to and returns from subroutines
follows a stack protocol.Arithmetic expressions are often evaluated by a
sequence of operations on a stack.Many handheld calculators use a stack
mode of operation.In studying computer science,you can expect to see many
examples of stacks.<BR><BR>Queues occur frequently in everyday life and
are therefore familiar to us.<BR><BR>The line of people waiting for [3]
service at a bank or for tickets at a movie theater and the line of autos
at a traffic light are examples of queues.The main feature of queues is
that they follow a“first come,first served”rule.Contrary to a stack,in
which the latest element inserted is the first removed or served,in queues
the earliest element inserted is the first served.In social settings,the
rule appeals to our sense of equality and fairness.<BR><BR>There are many
applications of the FIFO protocol of queues in computing.For example,the
line of input/output(I/O)requests waiting for access to a disk drive in a
multiuser time-sharing system might be a queue.The line of computing jobs
waiting to be run on a computer system might also be a queue.The jobs and
I/O requests are serviced in order of their arrival,that is,the first in
is the first out.<BR><BR>There is a second kind of queue that is
important.An everyday example can be seen in an emergency room of a
hospital.In large emergencies it is common to first treat the worst
injured patients who are likely to survive.In certain societies in which
1ess emphasis is placed on equality,people with higher social standing may
be treated first.<BR><BR>In computer systems,events that demand the
attention of the computer are often handled according to
a“most-important-event served-first”,or“highest-priority
in/first-out”(HPIFO),rule.Such queues are called priority queues,in this
type of queue service is not in order of time of arrival but rather in
order of some measure of
priority.<BR><BR>數組和記錄在很多程序設計語言中都作為固有數據類型。通過使用指針數據類型和動態存儲分配,很多程序設計語言也提供構造鏈接結構的設施。數組、記錄和鏈接結構提供了實現所謂更高一級抽象的基本構件。本文將要討論的兩種更高一級抽象數據類型,棧和隊列,對計算至關重要。<BR><BR>棧是這樣一種數據類型,其主要屬性是由支配其元素的插入與刪除的規則來決定的,被刪除或移去的元素只能是最后插入的,即所謂具有后進先出(LIFO)性質或規范。<BR><BR>數據類型棧的簡單性使人對其重要性產生誤解。許多計算機系統把棧做成其電路,并有操作這種硬件棧的機器指令。子例程的調用和返回序列都服從棧協議。算術表達式的求值都是通過對棧的操作序列來實現的。很多手持計算器都是用棧方式來操作的。在學習計算機科學時,將能看到許多棧的例子。<BR><BR>隊列在日常生活中經常出現并且為我們所熟悉。在銀行等待服務或在電影院門口等待買票的一隊人,在紅燈前等待通行的一長串汽車,都是隊列的例子。隊列的主要特征是遵循先來先服務(First
Come,first
served)的原則。與棧后進先出的特征不同,在隊列中,最先插入的元素將最先除去或接受服務,這樣的原則與社會生活中人們公正與平等的意識是一致的。<BR><BR>隊列的先進先出(FIFO)原則在計算機中有很多應用。例如,在多用戶分時操作系統中,等待訪問磁盤驅動器的多個輸入輸出(I/O)請求就可能是一個隊列。等待在計算機中運行的作業也形成一個隊列,計算機將按照作業和I/O請求到達的先后次序進行服務,也就是按先進先出的次序服務。<BR><BR>另外,還存在著一種重要的隊列:在醫院的急救室內每天都可以看到的例子。在危重病人多的情況下,醫生必須首先搶救生命垂危的病人。在某些不太強調平等性的社會中社會地位高的人可以最先得到治療。<BR><BR>在計算機系統中,要求計算機系統服務的事件通常是最重要的事件最先服務,換句話說,按最高優先級先進先出隊列(HPIFO)的原則。這種隊列稱之為優先級隊列。優先級隊列并不按進入隊列的時間的先后決定服務的次序,而是按照優先級確定的次序。<BR><BR></DIV></TD></TR></TBODY></TABLE>
<FORM style="MARGIN: 0px" name=TheForm
onsubmit=javascript:document.all.Submit1.disabled=true; action=view.asp
method=post>
<TABLE cellSpacing=1 cellPadding=5 width="100%" align=center bgColor=#6595d6
border=0>
<TBODY>
<TR bgColor=#fff5ec>
<TD vAlign=top align=middle bgColor=#fff5ec colSpan=2 height=3>
<DIV align=left><FONT
color=#ff0000>本帖內容僅代表網友觀點,與希賽網立場無關。如發現帖子內容有與法律抵觸之處,請向<A class=chinablue
href="mailto:master@csai.cn">網站管理員</A>舉報。</FONT></FONT></DIV></TD></TR>
<TR>
<TD class=chinabai vAlign=top align=middle bgColor=#6595d6 colSpan=2
height=3><IMG height=16 src="英漢對照典型數據結構—棧和隊列_files/shownew.gif" width=16
align=absMiddle><FONT
color=#ffffff>注意:本社區里的任何言論僅代表發言者個人的觀點,與希賽網立場無關。請對您的言論負責,遵守中華人民共和國有關法律、法規。如果您的帖子違反<A
class=chinahong href="http://bbs.csai.cn/bbs/help/index.asp"
target=_blank><STRONG>希賽網社區規則</STRONG></A>,將立即刪除;如果再次發布,則封IP。</FONT></TD></TR>
<TR>
<TD vAlign=top bgColor=#fefefe height=22><A name=Answer></A><IFRAME
src="英漢對照典型數據結構—棧和隊列_files/inc_search.htm" frameBorder=0 width="100%"
height=22></IFRAME><FONT color=red>Firefox瀏覽器用戶請使用編輯器的[粘貼]按鈕進行粘貼</FONT>
<INPUT type=hidden value={9A7C3902-9717-41DF-86A9-C8839A5B63F7}
name=backtitle>
<DIV><INPUT id=PContent style="DISPLAY: none" type=hidden
name=PContent><INPUT id=PContent___Config style="DISPLAY: none"
type=hidden value=SkinPath=/fckeditor23/editor/skins/silver/><IFRAME
id=PContent___Frame src="英漢對照典型數據結構—棧和隊列_files/upload.htm" frameBorder=0
width="100%" scrolling=no height=260></IFRAME></DIV><INPUT type=hidden
value=1 name=backpage></TD></TR>
<TR>
<TD class=hai vAlign=top align=middle bgColor=#efefef height=22><INPUT
type=hidden value=post name=action> <INPUT type=submit value=提交回復 name=Submit1>(按撤消鍵或CTRL+Z進行撤消)</TD></TR></TBODY></TABLE></FORM><FONT
color=#666666>125.00000ms</FONT> </DIV>
<DIV id=body_right
style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FLOAT: right; OVERFLOW-X: hidden; PADDING-BOTTOM: 0px; MARGIN: 0px; WIDTH: 176px; PADDING-TOP: 0px">
<DIV style="BACKGROUND-COLOR: #f7f7f7"><A class=chinablue
href="javascript:closead();"><IMG height=30
src="英漢對照典型數據結構—棧和隊列_files/closead_bt.gif" width=176 border=0></A></DIV>
<TABLE borderColor=#6595d6 height="100%" cellSpacing=0 borderColorDark=#ffffff
cellPadding=0 width=177 bgColor=#ffffff border=1>
<TBODY>
<TR>
<TD vAlign=top>
<SCRIPT type=text/javascript>
var arrBaiduCproConfig=new Array();
arrBaiduCproConfig['uid'] =341368;
arrBaiduCproConfig['n'] ='csai_cpr';
arrBaiduCproConfig['tm'] =18;
arrBaiduCproConfig['cm'] =196;
arrBaiduCproConfig['um'] =22;
arrBaiduCproConfig['w'] =173;
arrBaiduCproConfig['h'] =600;
arrBaiduCproConfig['wn'] =1;
arrBaiduCproConfig['hn'] =4;
arrBaiduCproConfig['ta'] ='left';
arrBaiduCproConfig['tl'] ='top';
arrBaiduCproConfig['bu'] =1;
arrBaiduCproConfig['bd'] ='#DD6400';
arrBaiduCproConfig['bg'] ='#FEF0E2';
arrBaiduCproConfig['tt'] ='#0000ff';
arrBaiduCproConfig['ct'] ='#333333';
arrBaiduCproConfig['url'] ='#666666';
arrBaiduCproConfig['bdl'] ='#ffffff';
arrBaiduCproConfig['rad'] =1;
</SCRIPT>
<SCRIPT src="英漢對照典型數據結構—棧和隊列_files/ui.js" type=text/javascript></SCRIPT>
<SCRIPT type=text/javascript>
<!--
document.write(baiduCproIFrame());
-->
</SCRIPT>
<DIV style="MARGIN: 0px; OVERFLOW: hidden; WIDTH: 173px">
<SCRIPT src="英漢對照典型數據結構—棧和隊列_files/rightlist.htm"
type=text/javascript></SCRIPT>
</DIV></TD></TR></TBODY></TABLE></DIV></DIV>
<SCRIPT>
function closead(){
var d_left=document.getElementById("body_left");
//var t_left=document.getElementById("body_leftTab");
var d_right=document.getElementById("body_right");
var arrDiv=document.getElementsByTagName("div");
for (var i=0;i<arrDiv.length;i++){
if(arrDiv[i].id=="cont_right") arrDiv[i].style.width='668px';
}
d_left.style.width='777px';
//t_left.style.width='777px';
d_right.style.display='none';
}
</SCRIPT>
<SCRIPT src="英漢對照典型數據結構—棧和隊列_files/api.js"></SCRIPT>
<DIV style="FLOAT: left" align=center><BR>
<SCRIPT language=javascript src="英漢對照典型數據結構—棧和隊列_files/showAds.htm"></SCRIPT>
<SCRIPT language=javascript src="英漢對照典型數據結構—棧和隊列_files/right.htm"></SCRIPT>
</DIV></DIV></BODY></HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -