⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 9exerc.html

📁 Visual C++ has been one of most effective tool for the large industrial applications. This book is t
💻 HTML
字号:
<html>
<head>
	<title>Exercises</title>
	<link rel="stylesheet" href="rs.css" tppabs="http://www.relisoft.com/book/rs.css">
</head>

<body background="margin.gif" tppabs="http://www.relisoft.com/book/images/margin.gif" bgcolor="#FFFFDC">

<!-- Main Table -->
<table cellpadding="6">
    <tr>
    <td width="78">
	&nbsp;
    <td>
<h3>Exercises</h3>

<ol>

<li>Add a private <var>Shrink</var> method to the dynamic stack. Let <var>Pop</var> call it when <var>_top</var> reaches some low water mark. Make sure the stack doesn抰 have a size at which alternating <var>Pushes</var> and <var>Pops</var> lead to alternating allocations and deallocations.



<li>Create a 2-deep stack of strings (<var>char *</var>). It抯 a stack that &quot;remembers&quot; only the last and the one before last strings. When a new string is pushed, the &quot;before last&quot; string is deleted, the &quot;last&quot; string takes its place and the new one becomes &quot;last.&quot; <var>Pop</var> returns the last string; it also moves up the &quot;before last&quot; to the &quot;last&quot; position one and stores zero in its place. In other words, the third <var>Pop</var> in a row will always return a zero pointer.



<li>Create a queue of integers with the FIFO (First In First Out) protocol. Use a linked list to implement it.


<li>Create a sequencer for a linked list. Create another sequencer that keeps track of both, the current and the previous item. Implement method <var>Unlink</var> on such a sequencer. It should remove the current item from the list that is being iterated. Test for special cases (remove first, remove last, one element list, etc.).



<li>Create a doubly linked list item, <var>DLink</var>, with the <var>_pNext</var> as well as <var>_pPrev</var> pointers. Implement the <var>Unlink </var>method of the <var>DLink</var> object. Create a FIFO queue that uses a circular doubly linked list; that is, the last element points at the first element and the first element points back at the last element. Always create a new <var>DLink</var> with both links closed on itself. The pointer to itself can be accessed through the keyword <var>this</var>. For instance <var>_pNext = this;</var> will point <var>_pNext</var> at the current <var>DLink</var>.


<p> <img src="Image14.gif" tppabs="http://www.relisoft.com/book/lang/pointer/images/Image14.gif" width=258 height=198>
<p class=caption>Figure 14. A circular doubly linked list.</p>



<li>Design and implement a sequencer for the hash table. It should go through all the entries in the array and follow all the non-empty linked lists.



<li>Using the hash table sequencer from the previous problem, design and implement new <var>StringTable</var> that uses a dynamic hash table that grows by allocating a larger array, iterates through the old hash table and re-hashes each element into the new array. Notice that the new array抯 hash function will differ from the old one (the division modulo size will use a different size).

</ol>


</table>
<!-- End Main Table -->
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -