Data Structures Succinctly Volume Two By Robert Hovick

128 357 0
Data Structures Succinctly Volume Two By Robert Hovick

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

A skip list is an ordered (sorted) list of items stored in a linkedlist structure in a way that allows O(log n) insertion, removal, and search. So it looks like an ordered list, but has the operational complexity of a balanced tree. Why is this compelling? Doesn’t a sorted array give you O(log n) search as well? Sure, but a sorted array doesn’t give you O(log n) insertion or removal. Okay, why not just use a tree? Well, you could. But as we will see, the implementation of the skip list is much less complex than an unbalanced tree, and far less complex than a balanced one. Also, at the end of the chapter I’ll examine at another benefit of a skip list that wouldn’t be too hard to add—arraystyle indexing. So if a skip list is as good as a balanced tree while being easier to implement, why don’t more people use them? I suspect it is a lack of awareness. Skip lists are a relatively new data structure—they were first documented by William Pugh in 1990—and as such are not a core part of most algorithm and data structure courses.

1 2 By Robert Horvick Foreword by Daniel Jebaraj 3 Copyright © 2013 by Syncfusion Inc. 2501 Aerial Center Parkway Suite 200 Morrisville, NC 27560 USA All rights reserved. mportant licensing information. Please read. This book is available for free download from www.syncfusion.com on completion of a registration form. If you obtained this book from any other source, please register and download a free copy from www.syncfusion.com. This book is licensed for reading only if obtained from www.syncfusion.com. This book is licensed strictly for personal, educational use. Redistribution in any form is prohibited. The authors and copyright holders provide absolutely no warranty for any information provided. The authors and copyright holders shall not be liable for any claim, damages, or any other liability arising from, out of, or in connection with the information in this book. Please do not use this book if the listed terms are unacceptable. Use shall constitute acceptance of the terms listed. SYNCFUSION, SUCCINCTLY, DELIVER INNOVATION WITH EASE, ESSENTIAL, and .NET ESSENTIALS are the registered trademarks of Syncfusion, Inc. Technical Reviewer: Clay Burch, Ph.D., director of technical support, Syncfusion, Inc. Copy Editor: Courtney Wright Acquisitions Coordinator: Jessica Rightmer, senior marketing strategist, Syncfusion, Inc. Proofreader: Graham High, content producer, Syncfusion, Inc. I 4 Table of Contents The Story behind the Succinctly Series of Books 9 About the Author 11 Chapter 1 Skip Lists 12 Overview 12 How it Works 12 But There is a Problem 14 Code Samples 16 SkipListNode Class 16 SkipList Class 17 Add 18 Picking a Level 18 Picking the Insertion Point 20 Remove 21 Contains 22 Clear 23 CopyTo 24 IsReadOnly 24 Count 25 GetEnumerator 25 Common Variations 26 Array-Style Indexing 26 Set behaviors 26 Chapter 2 Hash Table 27 Hash Table Overview 27 5 Hashing Basics 27 Overview 27 Hashing Algorithms 29 Handling Collisions 32 HashTableNodePair Class 34 HashTableArrayNode Class 36 Add 36 Update 37 TryGetValue 38 Remove 39 Clear 40 Enumeration 40 HashTableArray Class 42 Add 43 Update 43 TryGetValue 44 Remove 44 GetIndex 45 Clear 45 Capacity 46 Enumeration 46 HashTable Class 48 Add 49 Indexing 50 TryGetValue 50 Remove 51 ContainsKey 51 6 ContainsValue 52 Clear 52 Count 53 Enumeration 53 Chapter 3 Heap and Priority Queue 55 Overview 55 Binary Tree as Array 56 Structural Overview 56 Navigating the Array like a Tree 58 The Key Point 59 Heap Class 59 Add 60 RemoveMax 64 Peek 68 Count 68 Clear 68 Priority Queue 69 Priority Queue Class 69 Usage Example 70 Chapter 4 AVL Tree 72 Balanced Tree Overview 72 What is Node Height? 72 Balancing Algorithms 74 Right Rotation 74 Left Rotation 76 Right-Left Rotation 77 Left-Right Rotation 79 7 Heaviness and Balance Factor 80 AVLTreeNode Class 81 Balance 82 Rotation Methods 84 AVLTree Class 86 Add 87 Contains 88 Remove 89 GetEnumerator 92 Clear 93 Count 94 Chapter 5 B-tree 95 Overview 95 B-tree Structure 95 Minimal Degree 96 Tree Height 96 Searching the Tree 97 Putting it Together 99 Balancing Operations 99 Pushing Down 99 Rotating Values 101 Splitting Nodes 103 Adding Values 104 Removing Values 106 B-tree Node 107 BTreeNode Class 107 Adding, Removing, and Updating Values 109 8 Splitting Node 110 Pushing Down 112 Validation 114 B-tree 115 BTree Class 115 Add 116 Remove 117 Contains 125 Clear 126 Count 126 CopyTo 127 IsReadOnly 127 GetEnumerator 128 9 The Story behind the Succinctly Series of Books Daniel Jebaraj, Vice President Syncfusion, Inc. taying on the cutting edge As many of you may know, Syncfusion is a provider of software components for the Microsoft platform. This puts us in the exciting but challenging position of always being on the cutting edge. Whenever platforms or tools are shipping out of Microsoft, which seems to be about every other week these days, we have to educate ourselves, quickly. Information is plentiful but harder to digest In reality, this translates into a lot of book orders, blog searches, and Twitter scans. While more information is becoming available on the Internet and more and more books are being published, even on topics that are relatively new, one aspect that continues to inhibit us is the inability to find concise technology overview books. We are usually faced with two options: read several 500+ page books or scour the web for relevant blog posts and other articles. Just as everyone else who has a job to do and customers to serve, we find this quite frustrating. The Succinctly series This frustration translated into a deep desire to produce a series of concise technical books that would be targeted at developers working on the Microsoft platform. We firmly believe, given the background knowledge such developers have, that most topics can be translated into books that are between 50 and 100 pages. This is exactly what we resolved to accomplish with the Succinctly series. Isn’t everything wonderful born out of a deep desire to change things for the better? The best authors, the best content Each author was carefully chosen from a pool of talented experts who shared our vision. The book you now hold in your hands, and the others available in this series, are a result of the authors’ tireless work. You will find original content that is guaranteed to get you up and running in about the time it takes to drink a few cups of coffee. S 10 Free forever Syncfusion will be working to produce books on several topics. The books will always be free. Any updates we publish will also be free. Free? What is the catch? There is no catch here. Syncfusion has a vested interest in this effort. As a component vendor, our unique claim has always been that we offer deeper and broader frameworks than anyone else on the market. Developer education greatly helps us market and sell against competing vendors who promise to “enable AJAX support with one click,” or “turn the moon to cheese!” Let us know what you think If you have any topics of interest, thoughts, or feedback, please feel free to send them to us at succinctly-series@syncfusion.com. We sincerely hope you enjoy reading this book and that it helps you better understand the topic of study. Thank you for reading. Please follow us on Twitter and “Like” us on Facebook to help us spread the word about the Succinctly series! [...]... = 0; currentFourBytes currentFourBytes currentFourBytes currentFourBytes += += += += GetByte(str, GetByte(str, GetByte(str, GetByte(str, startIndex); startIndex + 1) . Point 20 Remove 21 Contains 22 Clear 23 CopyTo 24 IsReadOnly 24 Count 25 GetEnumerator 25 Common Variations 26 Array-Style Indexing 26 Set behaviors 26 Chapter 2 Hash Table 27 Hash. 1 12 Validation 114 B-tree 115 BTree Class 115 Add 116 Remove 117 Contains 125 Clear 126 Count 126 CopyTo 127 IsReadOnly 127 GetEnumerator 128 9 The Story behind the Succinctly. behaviors 26 Chapter 2 Hash Table 27 Hash Table Overview 27 5 Hashing Basics 27 Overview 27 Hashing Algorithms 29 Handling Collisions 32 HashTableNodePair Class 34 HashTableArrayNode

Ngày đăng: 12/07/2014, 17:12

Từ khóa liên quan

Mục lục

  • The Story behind the Succinctly Series of Books

  • About the Author

  • Chapter 1 Skip Lists

    • Overview

      • How it Works

      • But There is a Problem

      • Code Samples

      • SkipListNode Class

      • SkipList Class

      • Add

        • Picking a Level

        • Picking the Insertion Point

        • Remove

        • Contains

        • Clear

        • CopyTo

        • IsReadOnly

        • Count

        • GetEnumerator

        • Common Variations

          • Array-Style Indexing

          • Set behaviors

          • Chapter 2 Hash Table

            • Hash Table Overview

            • Hashing Basics

              • Overview

                • The Key and Value

Tài liệu cùng người dùng

Tài liệu liên quan