Advanced Datastruces and Implementation-Datastructues and Algorithms-Solutions, Exercises of Data Structures and Algorithms

This is solution manual provided by Muhammad Uzair at University of Engineering and Technology Lahore. It related to Data Structures and Algorithms course. Its main points are: Advanced, Data, Strcutures, Implementation, Additional, Field, Subtree, Nonroot, Nodes, Pointers, Arrays

Typology: Exercises

2011/2012

Uploaded on 07/16/2012

sangodkar
sangodkar 🇵🇰

5

(2)

12 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Data Structures & Algorithm Analysis in C
(second edition)
MarkAllenWeiss
FloridaInternationalUniversity
SolutionsManual
By:
Muhammad Uzair
05-E-147
U.E.T. Lahore
Pakistan
pf3
pf4

Partial preview of the text

Download Advanced Datastruces and Implementation-Datastructues and Algorithms-Solutions and more Exercises Data Structures and Algorithms in PDF only on Docsity!

Data Structures & Algorithm Analysis in C

(second edition)

MarkAllenWeiss

FloridaInternationalUniversity

SolutionsManual

By:

Muhammad Uzair

05-E-

U.E.T. Lahore

Pakistan

[email protected]

Preface

Included in this manual are answers to most of the exercises in the textbook Data Structures and Algorithm Analysis in C, second edition, published by Addison-Wesley. These answers reflect the state of the book in the first printing.

Specifically omitted are likely programming assignments and any question whose solu- tion is pointed to by a reference at the end of the chapter. Solutions vary in degree of complete- ness; generally, minor details are left to the reader. For clarity, programs are meant to be pseudo-C rather than completely perfect code.

Errors can be reported to [email protected]. Thanks to Grigori Schwarz and Brian Harvey for pointing out errors in previous incarnations of this manual.

Chapter 12: Advanced Data Structures

and Implementation

12.3 Incorporate an additional field for each node that indicates the size of its subtree. These fields are easy to update during a splay. This is difficult to do in a skip list.

12.6 If there are B O black nodes on the path from the root to all leaves, it is easy to show by induction that there are at most 2 B O^ leaves. Consequently, the number of black nodes on a path is at most log N O. Since there can’t be two consecutive red nodes, the height is bounded by 2log N O.

12.7 Color nonroot nodes red if their height is even and their parents height is odd, and black otherwise. Not all red black trees are AVL trees (since the deepest red black tree is deeper than the deepest AVL tree).

12.19 See H. N. Gabow, J. L. Bentley, and R. E. Tarjan, "Scaling and Related Techniques for Computational Geometry," Proceedings of the Sixteenth Annual ACM Symposium on Theory of Computing (1984), 135-143, or C. Levcopoulos and O. Petersson, "Heapsort Adapted for Presorted Files," Journal of Algorithms 14 (1993), 395-413.

12.29 Pointers are unnecessary; we can store everything in an array. This is discussed in refer- ence [12]. The bounds become O O( k Olog N O) for insertion, O O( k O^2 log N O) for deletion of a minimum, O O( k O^2 N O) for creation (an improvement over the bound in [12]).

12.35 Consider the pairing heap with 1 as the root and children 2, 3, ... N O. A DeleteMin O removes 1, and the resulting pairing heap is 2 as the root with children 3, 4, ... N O; the cost of this operation is N O units. A subsequent DeleteMin O sequence of 2, 3, 4, ... will take total time Ω( N O^2 ).