page379.html
来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 34 行
HTML
34 行
<HTML><HEAD><TITLE>Putting Items into a Binomial Queue</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="tex2html5555" HREF="page380.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html5553" HREF="page368.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html5547" HREF="page378.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html5557" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION0011450000000000000000">Putting Items into a Binomial Queue</A></H2><P>With the <tt>merge</tt> method at our disposal,the <tt>enqueue</tt> operation is easy to implement.To enqueue an item in a given binomial queue,we create another binomial queue that contains just the one item to be enqueuedand merge that queue with the original one.<P>Program <A HREF="page379.html#progbinomialQueuef"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> shows how easily this can be done.Creating the binomial tree <IMG WIDTH=18 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline65973" SRC="img1448.gif" > with the one object at its root (lines 4-5)takes a constant amount of time.Finally, the time required to merge the two queues is<P> <IMG WIDTH=362 HEIGHT=16 ALIGN=BOTTOM ALT="displaymath66423" SRC="img1516.gif" ><P>where <I>n</I> is the number of items originally in the queue.<P><P><A NAME="27141"> </A><A NAME="progbinomialQueuef"> </A> <IMG WIDTH=575 HEIGHT=142 ALIGN=BOTTOM ALT="program27044" SRC="img1517.gif" ><BR><STRONG>Program:</STRONG> <tt>BinomialQueue</tt> class <tt>enqueue</tt> method.<BR><P><HR><A NAME="tex2html5555" HREF="page380.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html5553" HREF="page368.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html5547" HREF="page378.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html5557" 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 + -
显示快捷键?