# - Easy to insert & delete in O(1) time - Don t need to estimate total memory needed. - Hard to search in less than O(n) time

Save this PDF as:

Size: px
Start display at page:

Download "- Easy to insert & delete in O(1) time - Don t need to estimate total memory needed. - Hard to search in less than O(n) time"

## Transcription

1 Skip Lists CMSC 420

2 Linked Lists Benefits & Drawbacks Benefits: - Easy to insert & delete in O(1) time - Don t need to estimate total memory needed Drawbacks: - Hard to search in less than O(n) time (binary search doesn t work, eg.) - Hard to jump to the middle Skip Lists: - fix these drawbacks - good data structure for a dictionary ADT

3 Skip Lists Invented around 1990 by Bill Pugh Generalization of sorted linked lists so simple to implement Expected search time is O(log n) Randomized data structure: - use random coin flips to build the data structure

4 Perfect Skip Lists header sentinel

5 Perfect Skip Lists Keys in sorted order. O(log n) levels Each higher level contains 1/2 the elements of the level below it. Header & sentinel nodes are in every level

6 Perfect Skip Lists, continued Nodes are of variable size: - contain between 1 and O(log n) pointers Pointers point to the start of each node (picture draws pointers horizontally for visual clarity) Called skip lists because higher level lists let you skip over many items

7 Perfect Skip Lists, continued Find 71 Comparison Change current location 71 <? 71 < 91? < 96? < Inf? When search for k: If k = key, done! If k < next key, go down a level If k next key, go right

8 In other words, To find an item, we scan along the shortest list until we would pass the desired item. At that point, we drop down to a slightly more complete list at one level lower. Remember: sorted sequential searching... for(i = 0; i < n; i++) if(x[i] >= K) break; if(x[i]!= K) return FAIL;

9 Perfect Skip Lists, continued Find 96 Comparison Change current location 96 <? < Inf? 96 < 91? 96 < Inf? < Inf? 96 96? When search for k: If k = key, done! If k < next key, go down a level If k next key, go right

10 Search Time: O(log n) levels --- because you cut the # of items in half at each level Will visit at most 2 nodes per level: If you visit more, then you could have done it on one level higher up. Therefore, search time is O(log n).

11 Insert & Delete Insert & delete might need to rearrange the entire list Like Perfect Binary Search Trees, Perfect Skip Lists are too structured to support efficient updates. Idea: - Relax the requirement that each level have exactly half the items of the previous level - Instead: design structure so that we expect 1/2 the items to be carried up to the next level - Skip Lists are a randomized data structure: the same sequence of inserts / deletes may produce different structures depending on the outcome of random coin flips.

12 Randomization Allows for some imbalance (like the +1-1 in AVL trees) Expected behavior (over the random choices) remains the same as with perfect skip lists. Idea: Each node is promoted to the next higher level with probability 1/2 - Expect 1/2 the nodes at level 1 - Expect 1/4 the nodes at level Therefore, expect # of nodes at each level is the same as with perfect skip lists. Also: expect the promoted nodes will be well distributed across the list

13 Randomized Skip List:

14 Insertion: Insert

15 Insertion: Insert Find k Insert node in level 0 let i = 1 while FLIP() == heads : insert node into level i i++ Just insertion into a linked list after last visited node in level i

16 Deletion: Delete

17 Deletion: Delete

18 There are no bad sequences: We expect a randomized skip list to perform about as well as a perfect skip list. With some very small probability, - the skip list will just be a linked list, or - the skip list will have every node at every level - These degenerate skip lists are very unlikely! Level structure of a skip list is independent of the keys you insert. Therefore, there are no bad key sequences that will lead to degenerate skip lists

19 Skip List Analysis Expected number of levels = O(log n) - E[# nodes at level 1] = n/2 - E[# nodes at level 2] = n/ E[# nodes at level log n] = 1 Still need to prove that # of steps at each level is small.

20 Backwards Analysis Consider the reverse of the path you took to find k: Note that you always move up if you can. (because you always enter a node from its topmost level when doing a find)

21 Analysis, continued... What s the probability that you can move up at a give step of the reverse walk? 0.5 Steps to go up j levels = Make one step, then make either C(j-1) steps if this step went up [Prob = 0.5] C(j) steps if this step went left [Prob = 0.5] Expected # of steps to walk up j levels is: C(j) = C(j-1) + 0.5C(j)

22 Analysis Continue, 2 Expected # of steps to walk up j levels is: C(j) = C(j-1) + 0.5C(j) So: 2C(j) = 2 + C(j-1) + C(j) C(j) = 2 + C(j-1) Expected # of steps at each level = 2 Expanding C(j) above gives us: C(j) = 2j Since O(log n) levels, we have O(log n) steps, expected

23 Implementation Notes Node structures are of variable size But once a node is created, its size won t change It s often convenient to assume that you know the maximum number of levels in advance (but this is not a requirement).

### Balanced search trees

Lecture 8 Balanced search trees 8.1 Overview In this lecture we discuss search trees as a method for storing data in a way that supports fast insert, lookup, and delete operations. (Data structures handling

### From Last Time: Remove (Delete) Operation

CSE 32 Lecture : More on Search Trees Today s Topics: Lazy Operations Run Time Analysis of Binary Search Tree Operations Balanced Search Trees AVL Trees and Rotations Covered in Chapter of the text From

### Announcements. CSE332: Data Abstractions. Lecture 9: B Trees. Today. Our goal. M-ary Search Tree. M-ary Search Tree. Ruth Anderson Winter 2011

Announcements CSE2: Data Abstractions Project 2 posted! Partner selection due by 11pm Tues 1/25 at the latest. Homework due Friday Jan 28 st at the BEGINNING of lecture Lecture 9: B Trees Ruth Anderson

### Simplified Analyses of Randomized Algorithms for Searching, Sorting, and Selection

Simplified Analyses of Randomized Algorithms for Searching, Sorting, and Selection i Michael T. Goodrich Roberto Tamassia Dept. of Info. & Computer Science Dept. of Computer Science University of California

### Binary Search Trees. Data in each node. Larger than the data in its left child Smaller than the data in its right child

Binary Search Trees Data in each node Larger than the data in its left child Smaller than the data in its right child FIGURE 11-6 Arbitrary binary tree FIGURE 11-7 Binary search tree Data Structures Using

### Multi-Way Search Trees (B Trees)

Multi-Way Search Trees (B Trees) Multiway Search Trees An m-way search tree is a tree in which, for some integer m called the order of the tree, each node has at most m children. If n

### Binary Heap Algorithms

CS Data Structures and Algorithms Lecture Slides Wednesday, April 5, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005 2009 Glenn G. Chappell

### Lecture 6. Randomized data structures Random number generation Skip lists: ideas and implementation Skip list time costs. Reading:

Lecture 6 Randomized data structures Random number generation Skip lists: ideas and implementation Skip list time costs Reading: Skip Lists: A Probabilistic Alternative to Balanced Trees (author William

### BINARY SEARCH TREE PERFORMANCE

BINARY SEARCH TREE PERFORMANCE Operation Best Time Average Time Worst Time (on a tree of n nodes) Find Insert Delete O(lg n)?? O(lg n)?? O(n) Fastest Running Time The find, insert and delete algorithms

### TREE BASIC TERMINOLOGIES

TREE Trees are very flexible, versatile and powerful non-liner data structure that can be used to represent data items possessing hierarchical relationship between the grand father and his children and

### Outline BST Operations Worst case Average case Balancing AVL Red-black B-trees. Binary Search Trees. Lecturer: Georgy Gimel farb

Binary Search Trees Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 27 1 Properties of Binary Search Trees 2 Basic BST operations The worst-case time complexity of BST operations

### Balanced Binary Search Tree

AVL Trees / Slide 1 Balanced Binary Search Tree Worst case height of binary search tree: N-1 Insertion, deletion can be O(N) in the worst case We want a tree with small height Height of a binary tree with

### Binary Heaps. CSE 373 Data Structures

Binary Heaps CSE Data Structures Readings Chapter Section. Binary Heaps BST implementation of a Priority Queue Worst case (degenerate tree) FindMin, DeleteMin and Insert (k) are all O(n) Best case (completely

### A Comparison of Dictionary Implementations

A Comparison of Dictionary Implementations Mark P Neyer April 10, 2009 1 Introduction A common problem in computer science is the representation of a mapping between two sets. A mapping f : A B is a function

### Lecture 6: Binary Search Trees CSCI 700 - Algorithms I. Andrew Rosenberg

Lecture 6: Binary Search Trees CSCI 700 - Algorithms I Andrew Rosenberg Last Time Linear Time Sorting Counting Sort Radix Sort Bucket Sort Today Binary Search Trees Data Structures Data structure is a

LINKED DATA STRUCTURES 1 Linked Lists A linked list is a structure in which objects refer to the same kind of object, and where: the objects, called nodes, are linked in a linear sequence. we keep a reference

### Merge Sort. 2004 Goodrich, Tamassia. Merge Sort 1

Merge Sort 7 2 9 4 2 4 7 9 7 2 2 7 9 4 4 9 7 7 2 2 9 9 4 4 Merge Sort 1 Divide-and-Conquer Divide-and conquer is a general algorithm design paradigm: Divide: divide the input data S in two disjoint subsets

### Chapter 7. Multiway Trees. Data Structures and Algorithms in Java

Chapter 7 Multiway Trees Data Structures and Algorithms in Java Objectives Discuss the following topics: The Family of B-Trees Tries Case Study: Spell Checker Data Structures and Algorithms in Java 2 Multiway

### Data Structures Fibonacci Heaps, Amortized Analysis

Chapter 4 Data Structures Fibonacci Heaps, Amortized Analysis Algorithm Theory WS 2012/13 Fabian Kuhn Fibonacci Heaps Lacy merge variant of binomial heaps: Do not merge trees as long as possible Structure:

### 1 2-3 Trees: The Basics

CS10: Data Structures and Object-Oriented Design (Fall 2013) November 1, 2013: 2-3 Trees: Inserting and Deleting Scribes: CS 10 Teaching Team Lecture Summary In this class, we investigated 2-3 Trees in

### 2 Exercises and Solutions

2 Exercises and Solutions Most of the exercises below have solutions but you should try first to solve them. Each subsection with solutions is after the corresponding subsection with exercises. 2.1 Sorting

### Learning Outcomes. COMP202 Complexity of Algorithms. Binary Search Trees and Other Search Trees

Learning Outcomes COMP202 Complexity of Algorithms Binary Search Trees and Other Search Trees [See relevant sections in chapters 2 and 3 in Goodrich and Tamassia.] At the conclusion of this set of lecture

### Chapter Objectives. Chapter 9. Sequential Search. Search Algorithms. Search Algorithms. Binary Search

Chapter Objectives Chapter 9 Search Algorithms Data Structures Using C++ 1 Learn the various search algorithms Explore how to implement the sequential and binary search algorithms Discover how the sequential

### Lecture Notes on Binary Search Trees

Lecture Notes on Binary Search Trees 15-122: Principles of Imperative Computation Frank Pfenning André Platzer Lecture 17 October 23, 2014 1 Introduction In this lecture, we will continue considering associative

### Balanced Binary Trees

Reminders about Trees Balanced Binary Trees With pictures by John Morris (ciips.ee.uwa.edu.au/~morris) A binary tree is a tree with exactly two sub-trees for each node, called the left and right sub-trees.

### Introduction Advantages and Disadvantages Algorithm TIME COMPLEXITY. Splay Tree. Cheruku Ravi Teja. November 14, 2011

November 14, 2011 1 Real Time Applications 2 3 Results of 4 Real Time Applications Splay trees are self branching binary search tree which has the property of reaccessing the elements quickly that which

### 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The

### Merkle Hash Trees for Distributed Audit Logs

Merkle Hash Trees for Distributed Audit Logs Subject proposed by Karthikeyan Bhargavan Karthikeyan.Bhargavan@inria.fr April 7, 2015 Modern distributed systems spread their databases across a large number

### Datenbanksysteme II: Hashing. Ulf Leser

Datenbanksysteme II: Hashing Ulf Leser Content of this Lecture Hashing Extensible Hashing Linear Hashing Ulf Leser: Implementation of Database Systems, Winter Semester 2012/2013 2 Sorting or Hashing Sorted

Unordered Linked Lists Derive class unorderedlinkedlist from the abstract class linkedlisttype Implement the operations search, insertfirst, insertlast, deletenode See code on page 292 Defines an unordered

### Algorithms and Data Structures

Algorithms and Data Structures CMPSC 465 LECTURES 20-21 Priority Queues and Binary Heaps Adam Smith S. Raskhodnikova and A. Smith. Based on slides by C. Leiserson and E. Demaine. 1 Trees Rooted Tree: collection

### Symbol Tables. IE 496 Lecture 13

Symbol Tables IE 496 Lecture 13 Reading for This Lecture Horowitz and Sahni, Chapter 2 Symbol Tables and Dictionaries A symbol table is a data structure for storing a list of items, each with a key and

### CMSC 451: Graph Properties, DFS, BFS, etc.

CMSC 451: Graph Properties, DFS, BFS, etc. Slides By: Carl Kingsford Department of Computer Science University of Maryland, College Park Based on Chapter 3 of Algorithm Design by Kleinberg & Tardos. Graphs

### UNIVERSITI MALAYSIA SARAWAK KOTA SAMARAHAN SARAWAK PSD2023 ALGORITHM & DATA STRUCTURE

STUDENT IDENTIFICATION NO UNIVERSITI MALAYSIA SARAWAK 94300 KOTA SAMARAHAN SARAWAK FAKULTI SAINS KOMPUTER & TEKNOLOGI MAKLUMAT (Faculty of Computer Science & Information Technology) Diploma in Multimedia

### AVL Trees. CSE 373 Data Structures

AVL Trees CSE 373 Data Structures Readings Reading Chapter 1 Section 1.2 AVL Trees 2 Binary Search Tree - Best Time All BST operations are O(d), where d is tree depth minimum d is = log N for a binary

### Abstract Data Type. EECS 281: Data Structures and Algorithms. The Foundation: Data Structures and Abstract Data Types

EECS 281: Data Structures and Algorithms The Foundation: Data Structures and Abstract Data Types Computer science is the science of abstraction. Abstract Data Type Abstraction of a data structure on that

### CS 3410 Ch 19 Binary Search Trees

CS 3410 Ch 19 Binary Search Trees Sections 19.1, 19.3-19.6 Pages 687-697, 702-737 Exercises 19 The find operation for a linked list is ( ), which can be prohibitive with a large amount of data. In this

### Analysis of Algorithms I: Binary Search Trees

Analysis of Algorithms I: Binary Search Trees Xi Chen Columbia University Hash table: A data structure that maintains a subset of keys from a universe set U = {0, 1,..., p 1} and supports all three dictionary

### 6 March 2007 1. Array Implementation of Binary Trees

Heaps CSE 0 Winter 00 March 00 1 Array Implementation of Binary Trees Each node v is stored at index i defined as follows: If v is the root, i = 1 The left child of v is in position i The right child of

### Analysis of a Search Algorithm

CSE 326 Lecture 4: Lists and Stacks 1. Agfgd 2. Dgsdsfd 3. Hdffdsf 4. Sdfgsfdg 5. Tefsdgass We will review: Analysis: Searching a sorted array (from last time) List ADT: Insert, Delete, Find, First, Kth,

### Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

Binary Search Trees A Generic Tree Nodes in a binary search tree ( B-S-T) are of the form P parent Key A Satellite data L R B C D E F G H I J The B-S-T has a root node which is the only node whose parent

### Data Structures Using C++ 2E. Chapter 5 Linked Lists

Data Structures Using C++ 2E Chapter 5 Linked Lists Doubly Linked Lists Traversed in either direction Typical operations Initialize the list Destroy the list Determine if list empty Search list for a given

### Persistent Binary Search Trees

Persistent Binary Search Trees Datastructures, UvA. May 30, 2008 0440949, Andreas van Cranenburgh Abstract A persistent binary tree allows access to all previous versions of the tree. This paper presents

### Lecture 12 Doubly Linked Lists (with Recursion)

Lecture 12 Doubly Linked Lists (with Recursion) In this lecture Introduction to Doubly linked lists What is recursion? Designing a node of a DLL Recursion and Linked Lists o Finding a node in a LL (recursively)

### School of Informatics, University of Edinburgh Computer Science 1 Ah [03 04]

School of Informatics, University of Edinburgh Computer Science 1 Ah [03 04] CS1Ah Lecture Note 25 Binary Search Trees This lecture studies binary trees in more detail, in particular their application

### Node-Based Structures Linked Lists: Implementation

Linked Lists: Implementation CS 311 Data Structures and Algorithms Lecture Slides Monday, March 30, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org

### DATA STRUCTURES USING C

DATA STRUCTURES USING C QUESTION BANK UNIT I 1. Define data. 2. Define Entity. 3. Define information. 4. Define Array. 5. Define data structure. 6. Give any two applications of data structures. 7. Give

### A Study on Skip Lists, Jump Lists and Random Binary. Search Trees. (Kuan-Chien Wang) (Prof. Wei-Mei Chen)

A Study on Skip Lists, Jump Lists and Random Binary Search Trees (Kuan-Chien Wang) (Prof. Wei-Mei Chen) Thesis for Master of Science Department of Applied Mathematics Tatung University July 2004 kevin_9999@hotmail.com

### Algorithms and Data Structures

Algorithms and Data Structures Part 2: Data Structures PD Dr. rer. nat. habil. Ralf-Peter Mundani Computation in Engineering (CiE) Summer Term 2016 Overview general linked lists stacks queues trees 2 2

### Coin Flip Questions. Suppose you flip a coin five times and write down the sequence of results, like HHHHH or HTTHT.

Coin Flip Questions Suppose you flip a coin five times and write down the sequence of results, like HHHHH or HTTHT. 1 How many ways can you get exactly 1 head? 2 How many ways can you get exactly 2 heads?

### Labworks 1: Binary Search Trees and Red-Black trees

Labworks 1: Binary Search Trees and Red-Black trees October 12, 2016 Deadline for these labworks: October 26 2016 How? Make an archive with the source files of your implementation, and send it by email

### Exam study sheet for CS2711. List of topics

Exam study sheet for CS2711 Here is the list of topics you need to know for the final exam. For each data structure listed below, make sure you can do the following: 1. Give an example of this data structure

### CS112 Lecture: Searching and Sorting

CS112 Lecture: Searching and Sorting Objectives: 1. To introduce the linear search algorithm. 2. To introduce the binary search algorithm. 3. To show superiority of O(log n) vs O(n) 4. To take note of

### Problem. Indexing with B-trees. Indexing. Primary Key Indexing. B-trees. B-trees: Example. primary key indexing

Problem Given a large collection of records, Indexing with B-trees find similar/interesting things, i.e., allow fast, approximate queries Anastassia Ailamaki http://www.cs.cmu.edu/~natassa 2 Indexing Primary

### Symbol Tables. Introduction

Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The

### Lecture 2: The Complexity of Some Problems

IAS/PCMI Summer Session 2000 Clay Mathematics Undergraduate Program Basic Course on Computational Complexity Lecture 2: The Complexity of Some Problems David Mix Barrington and Alexis Maciel July 18, 2000

### Shortest Inspection-Path. Queries in Simple Polygons

Shortest Inspection-Path Queries in Simple Polygons Christian Knauer, Günter Rote B 05-05 April 2005 Shortest Inspection-Path Queries in Simple Polygons Christian Knauer, Günter Rote Institut für Informatik,

### Cpt S 223. School of EECS, WSU

Priority Queues (Heaps) 1 Motivation Queues are a standard mechanism for ordering tasks on a first-come, first-served basis However, some tasks may be more important or timely than others (higher priority)

### Fast Sequential Summation Algorithms Using Augmented Data Structures

Fast Sequential Summation Algorithms Using Augmented Data Structures Vadim Stadnik vadim.stadnik@gmail.com Abstract This paper provides an introduction to the design of augmented data structures that offer

### 12 Abstract Data Types

12 Abstract Data Types 12.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT).

### Persistent Data Structures

6.854 Advanced Algorithms Lecture 2: September 9, 2005 Scribes: Sommer Gentry, Eddie Kohler Lecturer: David Karger Persistent Data Structures 2.1 Introduction and motivation So far, we ve seen only ephemeral

Chapter 7 Linked Lists In order to use linked lists, you need to learn how to allocate memory dynamically on the heap and you need to learn about objects. Recall that local variables are temporary which

### Shortest Path Algorithms

Shortest Path Algorithms Jaehyun Park CS 97SI Stanford University June 29, 2015 Outline Cross Product Convex Hull Problem Sweep Line Algorithm Intersecting Half-planes Notes on Binary/Ternary Search Cross

### Identity Finder Setup

Identity Finder Information Sheet for MAC This document will walk you through how to install, scan, and secure any SI found on your computer, or storage devices using the Identity Finder Software. This

### 5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

1. The advantage of.. is that they solve the problem if sequential storage representation. But disadvantage in that is they are sequential lists. [A] Lists [B] Linked Lists [A] Trees [A] Queues 2. The

### Data Warehousing und Data Mining

Data Warehousing und Data Mining Multidimensionale Indexstrukturen Ulf Leser Wissensmanagement in der Bioinformatik Content of this Lecture Multidimensional Indexing Grid-Files Kd-trees Ulf Leser: Data

### Data storage Tree indexes

Data storage Tree indexes Rasmus Pagh February 7 lecture 1 Access paths For many database queries and updates, only a small fraction of the data needs to be accessed. Extreme examples are looking or updating

### CSC 421: Algorithm Design Analysis. Spring 2014

CSC 421: Algorithm esign Analysis Spring 2014 Transform & conquer transform-and-conquer approach presorting balanced search trees, heaps Horner's Rule problem reduction 1 Transform & conquer the idea behind

### Binary Search Trees > = Binary Search Trees 1. 2004 Goodrich, Tamassia

Binary Search Trees < 6 2 > = 1 4 8 9 Binary Search Trees 1 Binary Search Trees A binary search tree is a binary tree storing keyvalue entries at its internal nodes and satisfying the following property:

### Balanced Trees Part One

Balanced Trees Part One Balanced Trees Balanced trees are surprisingly versatile data structures. Many programming languages ship with a balanced tree library. C++: std::map / std::set Java: TreeMap /

### In our lecture about Binary Search Trees (BST) we have seen that the operations of searching for and inserting an element in a BST can be of the

In our lecture about Binary Search Trees (BST) we have seen that the operations of searching for and inserting an element in a BST can be of the order O(log n) (in the best case) and of the order O(n)

### Algorithms. Margaret M. Fleck. 18 October 2010

Algorithms Margaret M. Fleck 18 October 2010 These notes cover how to analyze the running time of algorithms (sections 3.1, 3.3, 4.4, and 7.1 of Rosen). 1 Introduction The main reason for studying big-o

### AS-2261 M.Sc.(First Semester) Examination-2013 Paper -fourth Subject-Data structure with algorithm

AS-2261 M.Sc.(First Semester) Examination-2013 Paper -fourth Subject-Data structure with algorithm Time: Three Hours] [Maximum Marks: 60 Note Attempts all the questions. All carry equal marks Section A

### Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s

Quiz 4 Solutions Q1: What value does function mystery return when called with a value of 4? int mystery ( int number ) { if ( number

### SMALL INDEX LARGE INDEX (SILT)

Wayne State University ECE 7650: Scalable and Secure Internet Services and Architecture SMALL INDEX LARGE INDEX (SILT) A Memory Efficient High Performance Key Value Store QA REPORT Instructor: Dr. Song

### Graph Theory Problems and Solutions

raph Theory Problems and Solutions Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles November, 005 Problems. Prove that the sum of the degrees of the vertices of any finite graph is

### Converting a Number from Decimal to Binary

Converting a Number from Decimal to Binary Convert nonnegative integer in decimal format (base 10) into equivalent binary number (base 2) Rightmost bit of x Remainder of x after division by two Recursive

### root node level: internal node edge leaf node CS@VT Data Structures & Algorithms 2000-2009 McQuain

inary Trees 1 A binary tree is either empty, or it consists of a node called the root together with two binary trees called the left subtree and the right subtree of the root, which are disjoint from each

### TIE-20106 1 TIE-20106 2

TIE-20106 1 1 List structures In this chapter, a few simple data structures (stack and queue) that can be implemented with arrays and/or lists are covered. Two more complex structures based on lists are

### TEACHER S GUIDE TO RUSH HOUR

Using Puzzles to Teach Problem Solving TEACHER S GUIDE TO RUSH HOUR Includes Rush Hour 2, 3, 4, Rush Hour Jr., Railroad Rush Hour and Safari Rush Hour BENEFITS Rush Hour is a sliding piece puzzle that

### Class 28: Binary Search Trees. Binary Search Trees

Introduction to Computation and Problem Solving Class 2: Binary Search Trees Prof. Steven R. Lerman and Dr. V. Judson Harward Binary Search Trees In the previous lecture, we defined the concept of binary

### Dynamic Programming. Lecture 11. 11.1 Overview. 11.2 Introduction

Lecture 11 Dynamic Programming 11.1 Overview Dynamic Programming is a powerful technique that allows one to solve many different types of problems in time O(n 2 ) or O(n 3 ) for which a naive approach

### CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92.

Name: Email ID: CSE 326, Data Structures Section: Sample Final Exam Instructions: The exam is closed book, closed notes. Unless otherwise stated, N denotes the number of elements in the data structure

### Physical Data Organization

Physical Data Organization Database design using logical model of the database - appropriate level for users to focus on - user independence from implementation details Performance - other major factor

### Data Streams A Tutorial

Data Streams A Tutorial Nicole Schweikardt Goethe-Universität Frankfurt am Main DEIS 10: GI-Dagstuhl Seminar on Data Exchange, Integration, and Streams Schloss Dagstuhl, November 8, 2010 Data Streams Situation:

### B-Trees. Algorithms and data structures for external memory as opposed to the main memory B-Trees. B -trees

B-Trees Algorithms and data structures for external memory as opposed to the main memory B-Trees Previous Lectures Height balanced binary search trees: AVL trees, red-black trees. Multiway search trees:

### Rotation Operation for Binary Search Trees Idea:

Rotation Operation for Binary Search Trees Idea: Change a few pointers at a particular place in the tree so that one subtree becomes less deep in exchange for another one becoming deeper. A sequence of

### Hashing. CS 127 Fall Data structures, so far. New data structure: Hash table. Definitions

CS 127 Fall 2003 Hashing November 12 and 17, 2003 Data structures, so far Linked lists: refer to element starting from the head of the list Arrays: refer to element by its numerical position in the memory

### Chapter 8: Bags and Sets

Chapter 8: Bags and Sets In the stack and the queue abstractions, the order that elements are placed into the container is important, because the order elements are removed is related to the order in which

### CSE 326: Data Structures B-Trees and B+ Trees

Announcements (4//08) CSE 26: Data Structures B-Trees and B+ Trees Brian Curless Spring 2008 Midterm on Friday Special office hour: 4:-5: Thursday in Jaech Gallery (6 th floor of CSE building) This is

### A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

Binary Search Trees 1 The general binary tree shown in the previous chapter is not terribly useful in practice. The chief use of binary trees is for providing rapid access to data (indexing, if you will)

### A Fast Method For Accessing Nodes In The Binary Search Trees

A Fast Method For Accessing Nodes In The Binary Search Trees İbrahim Ates, Mustafa Akpınar, Beyza Eken, Nejat YUMUSAK Sakarya University, Department of Computer Engineering, Serdivan-Sakarya, Turkey ibrahimates@yahoo.com

### Algorithms. Theresa Migler-VonDollen CMPS 5P

Algorithms Theresa Migler-VonDollen CMPS 5P 1 / 32 Algorithms Write a Python function that accepts a list of numbers and a number, x. If x is in the list, the function returns the position in the list

### Quiz 1 Solutions. (a) T F The height of any binary search tree with n nodes is O(log n). Explain:

Introduction to Algorithms March 9, 2011 Massachusetts Institute of Technology 6.006 Spring 2011 Professors Erik Demaine, Piotr Indyk, and Manolis Kellis Quiz 1 Solutions Problem 1. Quiz 1 Solutions True

### Big Data and Scripting. Part 4: Memory Hierarchies

1, Big Data and Scripting Part 4: Memory Hierarchies 2, Model and Definitions memory size: M machine words total storage (on disk) of N elements (N is very large) disk size unlimited (for our considerations)

### Algorithms Chapter 12 Binary Search Trees

Algorithms Chapter 1 Binary Search Trees Outline Assistant Professor: Ching Chi Lin 林 清 池 助 理 教 授 chingchi.lin@gmail.com Department of Computer Science and Engineering National Taiwan Ocean University

### Unit 6: Binary Trees Part 2. Deletion. Deletion by merging. Deletion by merging Deletion by copying. Engineering 4892: Data Structures.

Unit : Binary Trees Part 2 Engineering 92: Data Structures Faculty of Engineering & Applied Science Memorial University of Newfoundland 1 Deletion Deletion by copying 1 Balanced trees AVL trees July 11,

### Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation:

CSE341T 08/31/2015 Lecture 3 Cost Model: Work, Span and Parallelism In this lecture, we will look at how one analyze a parallel program written using Cilk Plus. When we analyze the cost of an algorithm