Open Data Structures (In Pseudocode)

Total Page:16

File Type:pdf, Size:1020Kb

Open Data Structures (In Pseudocode) Open Data Structures (in pseudocode) Edition 0.1Gβ Pat Morin Contents Acknowledgments ix Why This Book? xi 1 Introduction 1 1.1 The Need for Efficiency ..................... 2 1.2 Interfaces ............................. 4 1.2.1 The Queue, Stack, and Deque Interfaces . 5 1.2.2 The List Interface: Linear Sequences . 6 1.2.3 The USet Interface: Unordered Sets .......... 8 1.2.4 The SSet Interface: Sorted Sets ............. 8 1.3 Mathematical Background ................... 9 1.3.1 Exponentials and Logarithms . 10 1.3.2 Factorials ......................... 11 1.3.3 Asymptotic Notation . 12 1.3.4 Randomization and Probability . 15 1.4 The Model of Computation ................... 18 1.5 Correctness, Time Complexity, and Space Complexity . 19 1.6 Code Samples .......................... 21 1.7 List of Data Structures ..................... 23 1.8 Discussion and Exercises .................... 23 2 Array-Based Lists 31 2.1 ArrayStack: Fast Stack Operations Using an Array . 32 2.1.1 The Basics ........................ 32 2.1.2 Growing and Shrinking . 35 2.1.3 Summary ......................... 37 Contents 2.2 FastArrayStack: An Optimized ArrayStack . 37 2.3 ArrayQueue: An Array-Based Queue . 38 2.3.1 Summary ......................... 41 2.4 ArrayDeque: Fast Deque Operations Using an Array . 42 2.4.1 Summary ......................... 44 2.5 DualArrayDeque: Building a Deque from Two Stacks . 44 2.5.1 Balancing ......................... 48 2.5.2 Summary ......................... 50 2.6 RootishArrayStack: A Space-Efficient Array Stack . 50 2.6.1 Analysis of Growing and Shrinking . 55 2.6.2 Space Usage ....................... 55 2.6.3 Summary ......................... 56 2.7 Discussion and Exercises .................... 57 3 Linked Lists 61 3.1 SLList: A Singly-Linked List . 61 3.1.1 Queue Operations .................... 63 3.1.2 Summary ......................... 64 3.2 DLList: A Doubly-Linked List . 64 3.2.1 Adding and Removing . 66 3.2.2 Summary ......................... 68 3.3 SEList: A Space-Efficient Linked List . 68 3.3.1 Space Requirements . 69 3.3.2 Finding Elements .................... 69 3.3.3 Adding an Element ................... 71 3.3.4 Removing an Element . 73 3.3.5 Amortized Analysis of Spreading and Gathering . 75 3.3.6 Summary ......................... 77 3.4 Discussion and Exercises .................... 78 4 Skiplists 83 4.1 The Basic Structure ....................... 83 4.2 SkiplistSSet: An Efficient SSet . 85 4.2.1 Summary ......................... 88 4.3 SkiplistList: An Efficient Random-Access List . 89 4.3.1 Summary ......................... 93 iv 4.4 Analysis of Skiplists ....................... 93 4.5 Discussion and Exercises .................... 97 5 Hash Tables 101 5.1 ChainedHashTable: Hashing with Chaining . 101 5.1.1 Multiplicative Hashing . 104 5.1.2 Summary . 108 5.2 LinearHashTable: Linear Probing . 108 5.2.1 Analysis of Linear Probing . 112 5.2.2 Summary . 115 5.2.3 Tabulation Hashing . 115 5.3 Hash Codes ............................117 5.3.1 Hash Codes for Primitive Data Types . 117 5.3.2 Hash Codes for Compound Objects . 117 5.3.3 Hash Codes for Arrays and Strings . 119 5.4 Discussion and Exercises . 122 6 Binary Trees 127 6.1 BinaryTree: A Basic Binary Tree . 129 6.1.1 Recursive Algorithms . 129 6.1.2 Traversing Binary Trees . 130 6.2 BinarySearchTree: An Unbalanced Binary Search Tree . 133 6.2.1 Searching . 133 6.2.2 Addition . 135 6.2.3 Removal . 137 6.2.4 Summary . 139 6.3 Discussion and Exercises . 140 7 Random Binary Search Trees 145 7.1 Random Binary Search Trees . 145 7.1.1 Proof of Lemma 7.1 . 148 7.1.2 Summary . 150 7.2 Treap: A Randomized Binary Search Tree . 151 7.2.1 Summary . 158 7.3 Discussion and Exercises . 160 v Contents 8 Scapegoat Trees 165 8.1 ScapegoatTree: A Binary Search Tree with Partial Rebuilding166 8.1.1 Analysis of Correctness and Running-Time . 170 8.1.2 Summary . 172 8.2 Discussion and Exercises . 173 9 Red-Black Trees 177 9.1 2-4 Trees .............................178 9.1.1 Adding a Leaf . 179 9.1.2 Removing a Leaf . 179 9.2 RedBlackTree: A Simulated 2-4 Tree . 182 9.2.1 Red-Black Trees and 2-4 Trees . 183 9.2.2 Left-Leaning Red-Black Trees . 186 9.2.3 Addition . 188 9.2.4 Removal . 191 9.3 Summary .............................196 9.4 Discussion and Exercises . 198 10 Heaps 203 10.1 BinaryHeap: An Implicit Binary Tree . 203 10.1.1 Summary . 209 10.2 MeldableHeap: A Randomized Meldable Heap . 209 10.2.1 Analysis of merge(h1,h2) . 212 10.2.2 Summary . 214 10.3 Discussion and Exercises . 214 11 Sorting Algorithms 217 11.1 Comparison-Based Sorting . 218 11.1.1 Merge-Sort . 218 11.1.2 Quicksort . 222 11.1.3 Heap-sort . 225 11.1.4 A Lower-Bound for Comparison-Based Sorting . 227 11.2 Counting Sort and Radix Sort . 231 11.2.1 Counting Sort . 231 11.2.2 Radix-Sort . 233 11.3 Discussion and Exercises . 235 vi 12 Graphs 239 12.1 AdjacencyMatrix: Representing a Graph by a Matrix . 241 12.2 AdjacencyLists: A Graph as a Collection of Lists . 244 12.3 Graph Traversal . 247 12.3.1 Breadth-First Search . 248 12.3.2 Depth-First Search . 250 12.4 Discussion and Exercises . 252 13 Data Structures for Integers 257 13.1 BinaryTrie: A digital search tree . 258 13.2 XFastTrie: Searching in Doubly-Logarithmic Time . 264 13.3 YFastTrie: A Doubly-Logarithmic Time SSet . 267 13.4 Discussion and Exercises . 272 14 External Memory Searching 275 14.1 The Block Store . 277 14.2 B-Trees ..............................277 14.2.1 Searching . 280 14.2.2 Addition . 282 14.2.3 Removal . 287 14.2.4 Amortized Analysis of B-Trees . 293 14.3 Discussion and Exercises . 296 Bibliography 301 Index 309 vii Acknowledgments I am grateful to Nima Hoda, who spent a summer tirelessly proofread- ing many of the chapters in this book; to the students in the Fall 2011 offering of COMP2402/2002, who put up with the first draft of this book and spotted many typographic, grammatical, and factual errors; and to Morgan Tunzelmann at Athabasca University Press, for patiently editing several near-final drafts. ix Why This Book? There are plenty of books that teach introductory data structures. Some of them are very good. Most of them cost money, and the vast majority of computer science undergraduate students will shell out at least some cash on a data structures book. Several free data structures books are available online. Some are very good, but most of them are getting old. The majority of these books be- came free when their authors and/or publishers decided to stop updat- ing them. Updating these books is usually not possible, for two reasons: (1) The copyright belongs to the author and/or publisher, either of whom may not allow it. (2) The source code for these books is often not avail- able. That is, the Word, WordPerfect, FrameMaker, or LATEX source for the book is not available, and even the version of the software that han- dles this source may not be available. The goal of this project is to free undergraduate computer science stu- dents from having to pay for an introductory data structures book. I have decided to implement this goal by treating this book like an Open Source software project. The LATEX source, pseudocode source, and build scripts for the book are available to download from the author’s website1 and also, more importantly, on a reliable source code management site.2 The source code available there is released under a Creative Commons Attribution license, meaning that anyone is free to share: to copy, dis- tribute and transmit the work; and to remix: to adapt the work, including the right to make commercial use of the work. The only condition on these rights is attribution: you must acknowledge that the derived work contains code and/or text from opendatastructures.org. 1http://opendatastructures.org 2https://github.com/patmorin/ods xi Why This Book? Anyone can contribute corrections/fixes using the git source-code management system. Anyone can also fork the book’s sources to develop a separate version (for example, in another programming language). My hope is that, by doing things this way, this book will continue to be a use- ful textbook long after my interest in the project, or my pulse, (whichever comes first) has waned. xii Chapter 1 Introduction Every computer science curriculum in the world includes a course on data structures and algorithms. Data structures are that important; they im- prove our quality of life and even save lives on a regular basis. Many multi-million and several multi-billion dollar companies have been built around data structures. How can this be? If we stop to think about it, we realize that we inter- act with data structures constantly. • Open a file: File system data structures are used to locate the parts of that file on disk so they can be retrieved. This isn’t easy; disks contain hundreds of millions of blocks. The contents of your file could be stored on any one of them. • Look up a contact on your phone: A data structure is used to look up a phone number in your contact list based on partial information even before you finish dialing/typing. This isn’t easy; your phone may contain information about a lot of people—everyone you have ever contacted via phone or email—and your phone doesn’t have a very fast processor or a lot of memory. • Log in to your favourite social network: The network servers use your login information to look up your account information.
Recommended publications
  • C Programming: Data Structures and Algorithms
    C Programming: Data Structures and Algorithms An introduction to elementary programming concepts in C Jack Straub, Instructor Version 2.07 DRAFT C Programming: Data Structures and Algorithms, Version 2.07 DRAFT C Programming: Data Structures and Algorithms Version 2.07 DRAFT Copyright © 1996 through 2006 by Jack Straub ii 08/12/08 C Programming: Data Structures and Algorithms, Version 2.07 DRAFT Table of Contents COURSE OVERVIEW ........................................................................................ IX 1. BASICS.................................................................................................... 13 1.1 Objectives ...................................................................................................................................... 13 1.2 Typedef .......................................................................................................................................... 13 1.2.1 Typedef and Portability ............................................................................................................. 13 1.2.2 Typedef and Structures .............................................................................................................. 14 1.2.3 Typedef and Functions .............................................................................................................. 14 1.3 Pointers and Arrays ..................................................................................................................... 16 1.4 Dynamic Memory Allocation .....................................................................................................
    [Show full text]
  • Lecture 04 Linear Structures Sort
    Algorithmics (6EAP) MTAT.03.238 Linear structures, sorting, searching, etc Jaak Vilo 2018 Fall Jaak Vilo 1 Big-Oh notation classes Class Informal Intuition Analogy f(n) ∈ ο ( g(n) ) f is dominated by g Strictly below < f(n) ∈ O( g(n) ) Bounded from above Upper bound ≤ f(n) ∈ Θ( g(n) ) Bounded from “equal to” = above and below f(n) ∈ Ω( g(n) ) Bounded from below Lower bound ≥ f(n) ∈ ω( g(n) ) f dominates g Strictly above > Conclusions • Algorithm complexity deals with the behavior in the long-term – worst case -- typical – average case -- quite hard – best case -- bogus, cheating • In practice, long-term sometimes not necessary – E.g. for sorting 20 elements, you dont need fancy algorithms… Linear, sequential, ordered, list … Memory, disk, tape etc – is an ordered sequentially addressed media. Physical ordered list ~ array • Memory /address/ – Garbage collection • Files (character/byte list/lines in text file,…) • Disk – Disk fragmentation Linear data structures: Arrays • Array • Hashed array tree • Bidirectional map • Heightmap • Bit array • Lookup table • Bit field • Matrix • Bitboard • Parallel array • Bitmap • Sorted array • Circular buffer • Sparse array • Control table • Sparse matrix • Image • Iliffe vector • Dynamic array • Variable-length array • Gap buffer Linear data structures: Lists • Doubly linked list • Array list • Xor linked list • Linked list • Zipper • Self-organizing list • Doubly connected edge • Skip list list • Unrolled linked list • Difference list • VList Lists: Array 0 1 size MAX_SIZE-1 3 6 7 5 2 L = int[MAX_SIZE]
    [Show full text]
  • Open Data Structures (In Java)
    Open Data Structures (in Java) Edition 0.1G Pat Morin Contents Acknowledgments ix Why This Book? xi 1 Introduction 1 1.1 The Need for Efficiency ..................... 2 1.2 Interfaces ............................. 4 1.2.1 The Queue, Stack, and Deque Interfaces . 5 1.2.2 The List Interface: Linear Sequences . 6 1.2.3 The USet Interface: Unordered Sets .......... 8 1.2.4 The SSet Interface: Sorted Sets ............ 9 1.3 Mathematical Background ................... 9 1.3.1 Exponentials and Logarithms . 10 1.3.2 Factorials ......................... 11 1.3.3 Asymptotic Notation . 12 1.3.4 Randomization and Probability . 15 1.4 The Model of Computation ................... 18 1.5 Correctness, Time Complexity, and Space Complexity . 19 1.6 Code Samples .......................... 22 1.7 List of Data Structures ..................... 22 1.8 Discussion and Exercises .................... 26 2 Array-Based Lists 29 2.1 ArrayStack: Fast Stack Operations Using an Array . 30 2.1.1 The Basics ........................ 30 2.1.2 Growing and Shrinking . 33 2.1.3 Summary ......................... 35 Contents 2.2 FastArrayStack: An Optimized ArrayStack . 35 2.3 ArrayQueue: An Array-Based Queue . 36 2.3.1 Summary ......................... 40 2.4 ArrayDeque: Fast Deque Operations Using an Array . 40 2.4.1 Summary ......................... 43 2.5 DualArrayDeque: Building a Deque from Two Stacks . 43 2.5.1 Balancing ......................... 47 2.5.2 Summary ......................... 49 2.6 RootishArrayStack: A Space-Efficient Array Stack . 49 2.6.1 Analysis of Growing and Shrinking . 54 2.6.2 Space Usage ....................... 54 2.6.3 Summary ......................... 55 2.6.4 Computing Square Roots . 56 2.7 Discussion and Exercises ...................
    [Show full text]
  • Unrolled Linked Lists
    CSCI-1200 Data Structures | Fall 2014 Homework 5 | Unrolled Linked Lists In this assignment you will modify the dslist class from Lecture 11 to implement an unrolled linked list data structure. This data structure is very similar to a standard doubly linked list, except that more than one element may be stored at each node. This data structure can have performance advantages (both in memory and running time) over a standard linked list when storing small items and can be used to better align data in the cache. You're welcome to read more about unrolled linked lists on Wikipedia (but you're not allowed to search for or use any code or pseudocode that might be available online!). Please read the entire handout before beginning your implementation. To complete the assignment you will modify the helper classes (Node and list_iterator) as well as the main class, dslist, which will be renamed \UnrolledLL". Below is a picture of the relationships between the classes (compare this to the picture of the dslist class from Lecture 11): UnrolledLL<int> head: tail: size: 14 list_iterator<int> ptr: offset: 3 Node<int> Node<int> Node<int> prev: NULL prev: prev: num_elements: 6 num_elements: 6 num_elements: 2 elements: 10 11 12 13 14 15elements: 16 17 1819 20 21 elements: 22 23 next: next: next: NULL Each Node object contains a fixed size array (size = 6 in the above example) that will store 1 or more elements from the list. The elements are ordered from left to right. From the outside, this unrolled linked list should perform exactly like an STL list containing the numbers 10 through 23 in sorted order.
    [Show full text]
  • Kernel Extensions and Device Support Programming Concepts
    Bull Kernel Extensions and Device Support Programming Concepts AIX ORDER REFERENCE 86 A2 36JX 02 Bull Kernel Extensions and Device Support Programming Concepts AIX Software November 1999 BULL ELECTRONICS ANGERS CEDOC 34 Rue du Nid de Pie – BP 428 49004 ANGERS CEDEX 01 FRANCE ORDER REFERENCE 86 A2 36JX 02 The following copyright notice protects this book under the Copyright laws of the United States of America and other countries which prohibit such actions as, but not limited to, copying, distributing, modifying, and making derivative works. Copyright Bull S.A. 1992, 1999 Printed in France Suggestions and criticisms concerning the form, content, and presentation of this book are invited. A form is provided at the end of this book for this purpose. To order additional copies of this book or other Bull Technical Publications, you are invited to use the Ordering Form also provided at the end of this book. Trademarks and Acknowledgements We acknowledge the right of proprietors of trademarks mentioned in this book. AIXR is a registered trademark of International Business Machines Corporation, and is being used under licence. UNIX is a registered trademark in the United States of America and other countries licensed exclusively through the Open Group. Year 2000 The product documented in this manual is Year 2000 Ready. The information in this document is subject to change without notice. Groupe Bull will not be liable for errors contained herein, or for incidental or consequential damages in connection with the use of this material. Contents Trademarks and Acknowledgements . iii 64-bit Kernel Extension Development. 23 About This Book .
    [Show full text]
  • Xilinx UG925 Zynq-7000 All Programmable Soc ZC702 Base
    Zynq-7000 All Programmable SoC ZC702 Base Targeted Reference Design (Vivado Design Suite 2013.3) User Guide UG925 (v6.0) February 21, 2014 Notice of Disclaimer The information disclosed to you hereunder (the “Materials”) is provided solely for the selection and use of Xilinx products. To the maximum extent permitted by applicable law: (1) Materials are made available "AS IS" and with all faults, Xilinx hereby DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and (2) Xilinx shall not be liable (whether in contract or tort, including negligence, or under any other theory of liability) for any loss or damage of any kind or nature related to, arising under, or in connection with, the Materials (including your use of the Materials), including for any direct, indirect, special, incidental, or consequential loss or damage (including loss of data, profits, goodwill, or any type of loss or damage suffered as a result of any action brought by a third party) even if such damage or loss was reasonably foreseeable or Xilinx had been advised of the possibility of the same. Xilinx assumes no obligation to correct any errors contained in the Materials or to notify you of updates to the Materials or to product specifications. You may not reproduce, modify, distribute, or publicly display the Materials without prior written consent. Certain products are subject to the terms and conditions of the Limited Warranties which can be viewed at http://www.xilinx.com/warranty.htm; IP cores may be subject to warranty and support terms contained in a license issued to you by Xilinx.
    [Show full text]
  • Meant to Provoke Thought Regarding the Current "Software Crisis" at the Time
    1 www.onlineeducation.bharatsevaksamaj.net www.bssskillmission.in DATA STRUCTURES Topic Objective: At the end of this topic student will be able to: At the end of this topic student will be able to: Learn about software engineering principles Discover what an algorithm is and explore problem-solving techniques Become aware of structured design and object-oriented design programming methodologies Learn about classes Learn about private, protected, and public members of a class Explore how classes are implemented Become aware of Unified Modeling Language (UML) notation Examine constructors and destructors Learn about the abstract data type (ADT) Explore how classes are used to implement ADT Definition/Overview: Software engineering is the application of a systematic, disciplined, quantifiable approach to the development, operation, and maintenance of software, and the study of these approaches. That is the application of engineering to software. The term software engineering first appeared in the 1968 NATO Software Engineering Conference and WWW.BSSVE.INwas meant to provoke thought regarding the current "software crisis" at the time. Since then, it has continued as a profession and field of study dedicated to creating software that is of higher quality, cheaper, maintainable, and quicker to build. Since the field is still relatively young compared to its sister fields of engineering, there is still much work and debate around what software engineering actually is, and if it deserves the title engineering. It has grown organically out of the limitations of viewing software as just programming. Software development is a term sometimes preferred by practitioners in the industry who view software engineering as too heavy-handed and constrictive to the malleable process of creating software.
    [Show full text]
  • Fundamental Data Structures Contents
    Fundamental Data Structures Contents 1 Introduction 1 1.1 Abstract data type ........................................... 1 1.1.1 Examples ........................................... 1 1.1.2 Introduction .......................................... 2 1.1.3 Defining an abstract data type ................................. 2 1.1.4 Advantages of abstract data typing .............................. 4 1.1.5 Typical operations ...................................... 4 1.1.6 Examples ........................................... 5 1.1.7 Implementation ........................................ 5 1.1.8 See also ............................................ 6 1.1.9 Notes ............................................. 6 1.1.10 References .......................................... 6 1.1.11 Further ............................................ 7 1.1.12 External links ......................................... 7 1.2 Data structure ............................................. 7 1.2.1 Overview ........................................... 7 1.2.2 Examples ........................................... 7 1.2.3 Language support ....................................... 8 1.2.4 See also ............................................ 8 1.2.5 References .......................................... 8 1.2.6 Further reading ........................................ 8 1.2.7 External links ......................................... 9 1.3 Analysis of algorithms ......................................... 9 1.3.1 Cost models ......................................... 9 1.3.2 Run-time analysis
    [Show full text]
  • Saturation in Lock-Based Concurrent Data Structures Ph.D
    SATURATION IN LOCK-BASED CONCURRENT DATA STRUCTURES by Kenneth Joseph Platz APPROVED BY SUPERVISORY COMMITTEE: S. Venkatesan, Co-Chair Neeraj Mittal, Co-Chair Ivor Page Cong Liu Copyright c 2017 Kenneth Joseph Platz All rights reserved This dissertation is dedicated to my wife and my parents. They have always believed in me even when I did not. SATURATION IN LOCK-BASED CONCURRENT DATA STRUCTURES by KENNETH JOSEPH PLATZ, BS, MS DISSERTATION Presented to the Faculty of The University of Texas at Dallas in Partial Fulfillment of the Requirements for the Degree of DOCTOR OF PHILOSOPHY IN COMPUTER SCIENCE THE UNIVERSITY OF TEXAS AT DALLAS December 2017 ACKNOWLEDGMENTS I would like to first of all thank my wife Tracy for having the patience and fortitude to stand with me through this journey. Without her support, I could have never started this path much less completed it. Second, I would like to thank my supervising professors, Drs. \Venky" Venkatesan and Neeraj Mittal. They both provided me with frequent guidance and support throughout this entire journey. Finally, I would like to thank the rest of my dissertation committee, Drs. Ivor Page and Cong Liu. Dr. Page especially asked many pointed (and difficult) questions during my proposal defense, and that helped improve the quality of this work. November 2017 v SATURATION IN LOCK-BASED CONCURRENT DATA STRUCTURES Kenneth Joseph Platz, PhD The University of Texas at Dallas, 2017 Supervising Professors: S. Venkatesan, Co-Chair Neeraj Mittal, Co-Chair For over three decades, computer scientists enjoyed a \free lunch" inasmuch as they could depend on processor speeds doubling every three years.
    [Show full text]
  • S.Y. B.Tech. 2017-Pattern
    Bansilal Ramnath Agarwal Charitable Trust’s Vishwakarma Institute of Information Technology, Pune-48 (An Autonomous Institute affiliated to Savitribai Phule Pune University) BansilalDepartment Ramnath of ComputerAgarwal Charitable Engineering Trust’s Vishwakarma Institute of Information Technology, Pune-48 (An Autonomous Institute affiliated to Savitribai Phule Pune University) CurriculumSyllabus for for SM.Y.. BTech..Tech. (Mechanical (Computer – Design Engineering) Engineering) Department of Computer Engineering S.Y.B.Tech.(Pattern 2017) Computer Engineering 1 Bansilal Ramnath Agarwal Charitable Trust’s Vishwakarma Institute of Information Technology, Pune-48 (An Autonomous Institute affiliated to Savitribai Phule Pune University) Department of Computer Engineering Vision and Mission of the Department • Vision “Excellence in the field of Computer Engineering for rendering services to the industry and society”. • Mission To empower our students for substantial contribution to economical, technological, entrepreneurial and social progress of the society. To strive for excellence at different levels and diverse dimensions in the field of computer engineering. To encourage students to pursue research and advanced studies for better adaptability towards globalization. Program Specific Outcomes (PSOs) At the end of program, students should be able to • PSO a: Use knowledge to write programs and integrate them with the hardware/software products in the domains of embedded systems, data Science, networking and web technology. • PSO b: Participate in planning and implement solutions to cater to business – specific requirements, displaying team dynamics and professional ethics. Program Outcomes (POs) At the end of program, students should be able to: 1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals and an engineering specialization to the solution of complex engineering problems.
    [Show full text]
  • CSCI-1200 Data Structures — Fall 2018 Lecture 24 – Miscellaneous Data Structures
    CSCI-1200 Data Structures | Fall 2018 Lecture 24 { Miscellaneous Data Structures Review from Lecture 23 • STL's for_each, STL's find_if, Function Objects, a.k.a. Functors • Hash table collision resolution: separate chaining vs open addressing • STL's unordered_set (and unordered_map) • Using a hash table to implement a set/map 24.1 The Basic Data Structures This term we've covered a number of core data structures. These structures have fundamentally different memory layouts. These data structures are classic, and are not unique to C++. • array / vector • linked list • binary search tree • binary heap / priority queue • hash table 24.2 A Few Variants of the Basic Data Structures Many variants and advanced extensions and hybrid versions of these data structures are possible. Different applications with different requirements and patterns of data and data sizes and computer hardware will benefit from or leverage different aspects of these variants. This term we've already discussed / implemented a number of data structure variants: • single vs. doubly linked lists using more memory can improve convenience and running time for key operations • dummy nodes or circular linked lists { can reduce need for special case / corner case code • linked grid/matrix (Homework 5) { 2-dimensional linked list with efficient merge/split • bi-directional map (Homework 8) { 2 BSTs allow efficient find/insert/erase on both keys and values • red-black tree { an algorithm to automatically balance a binary search tree • stack and queue { restricted/reduced(!) set of operations on array/vector and list • hash table: separate chaining vs open addressing { reduce memory and avoid pointer dereferencing • priority queue with backpointers (Homework 10) { when you need to update data already in the structure We'll discuss just a few additional variants today.
    [Show full text]
  • Handout 09: Suggested Project Topics
    CS166 Handout 09 Spring 2021 April 13, 2021 Suggested Project Topics Here is a list of data structures and families of data structures we think you might find interesting topics for your research project. You're by no means limited to what's contained here; if you have another data structure you'd like to explore, feel free to do so! My Wish List Below is a list of topics where, each quarter, I secretly think “I hope someone wants to pick this topic this quarter!” These are data structures I’ve always wanted to learn a bit more about or that I think would be particularly fun to do a deep dive into. You are not in any way, shape, or form required to pick something from this list, and we aren’t offer- ing extra credit or anything like that if you do choose to select one of these topics. However, if any of them seem interesting to you, we’d be excited to see what you come up with over the quarter. • Bentley-Saxe dynamization (turning static data structures into dynamic data structures) • Bε-trees (a B-tree variant designed to minimize writes) • Chazelle and Guibas’s O(log n + k) 3D range search (fast range searches in 3D) • Crazy good chocolate pop tarts (deamortizing binary search trees) • Durocher’s RMQ structure (fast RMQ without the Method of Four Russians) • Dynamic prefix sum lower bounds (proving lower bounds on dynamic prefix parity) • Farach’s suffix tree algorithm (a brilliant, beautiful divide-and-conquer algorithm) • Geometric greedy trees (lower bounds on BSTs giving rise to a specific BST) • Ham sandwich trees (fast searches
    [Show full text]