ADTs so far.

Slides:



Advertisements
Similar presentations
The Dictionary ADT Definition A dictionary is an ordered or unordered list of key-element pairs, where keys are used to locate elements in the list. Example:
Advertisements

AVL Trees1 Part-F2 AVL Trees v z. AVL Trees2 AVL Tree Definition (§ 9.2) AVL trees are balanced. An AVL Tree is a binary search tree such that.
Transform and Conquer Chapter 6. Transform and Conquer Solve problem by transforming into: a more convenient instance of the same problem (instance simplification)
Data Abstraction and Problem Solving with JAVA Walls and Mirrors Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Data Abstraction and Problem.
Computer Science Dictionaries: Red-Black CS 330: Algorithms Dictionaries: and Red-Black Trees Gene Itkis.
© 2006 Pearson Addison-Wesley. All rights reserved13 A-1 Chapter 13 Hash Tables.
Course Review COMP171 Spring Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert,
Computer Science Red-Black CS 330: Algorithms and Red-Black Trees Gene Itkis.
Computer Science Elementary Data Structures, Dictionaries CS 330: Algorithms Elementary Data Structures, Dictionaries Gene Itkis.
CSE 326: Data Structures Lecture #13 Extendible Hashing and Splay Trees Alon Halevy Spring Quarter 2001.
© 2006 Pearson Addison-Wesley. All rights reserved13 B-1 Chapter 13 (excerpts) Advanced Implementation of Tables CS102 Sections 51 and 52 Marc Smith and.
CS 221 Analysis of Algorithms Data Structures Dictionaries, Hash Tables, Ordered Dictionary and Binary Search Trees.
Compiled by: Dr. Mohammad Alhawarat BST, Priority Queue, Heaps - Heapsort CHAPTER 07.
1 Hash Tables  a hash table is an array of size Tsize  has index positions 0.. Tsize-1  two types of hash tables  open hash table  array element type.
1 B Trees - Motivation Recall our discussion on AVL-trees –The maximum height of an AVL-tree with n-nodes is log 2 (n) since the branching factor (degree,
Brought to you by Max (ICQ: TEL: ) February 5, 2005 Advanced Data Structures Introduction.
1 Road Map Associative Container Impl. Unordered ACs Hashing Collision Resolution Collision Resolution Open Addressing Open Addressing Separate Chaining.
Final Review Dr. Yingwu Zhu. Goals Use appropriate data structures to solve real- world problems –E.g., use stack to implement non-recursive BST traversal,
© 2006 Pearson Addison-Wesley. All rights reserved13 B-1 Chapter 13 (continued) Advanced Implementation of Tables.
CS Data Structures II Review & Final Exam. 2 Topics Review Final Exam.
Final Exam Review CS Total Points – 60 Points Writing Programs – 50 Points Tracing Algorithms, determining results, and drawing pictures – 50.
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
Appendix C File Organization & Storage Structure.
CHAPTER 9 HASH TABLES, MAPS, AND SKIP LISTS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++,
Advanced Data Structure By Kayman 21 Jan Outline Review of some data structures Array Linked List Sorted Array New stuff 3 of the most important.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
Hash Tables ADT Data Dictionary, with two operations – Insert an item, – Search for (and retrieve) an item How should we implement a data dictionary? –
 Saturday, April 20, 8:30-11:00am in B9201  Similar in style to written midterm exam  May include (a little) coding on paper  About 1.5 times as long.
Appendix C File Organization & Storage Structure.
Nov 2, 2001CSE 373, Autumn Hash Table example marking deleted items + choice of table size.
Final Exam Review COP4530.
Final Exam Review CS 3358.
CSE373: Data Structures & Algorithms Priority Queues
ADT description Implementations
COMP 53 – Week Eleven Hashtables.
CS 315 Data Structures B. Ravikumar Office: 116 I Darwin Hall Phone:
Priority Queues and Heaps
Lecture 15 AVL Trees Slides modified from © 2010 Goodrich, Tamassia & by Prof. Naveen Garg’s Lectures.
Hashing Exercises.
Part-D1 Priority Queues
Cse 373 April 26th – Exam Review.
O(lg n) Search Tree Tree T is a search tree made up of n elements: x0 x1 x2 x3 … xn-1 No function (except transverse) takes more than O(lg n) in the.
Chapter 2: Basic Data Structures
Review for Midterm Neil Tang 03/04/2010
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Advanced Associative Structures
Hash Table.
CSE 326: Data Structures: Midterm Review
structures and their relationships." - Linus Torvalds
Final Exam Review COP4530.
Lesson 6. Types Equality and Identity. Collections.
Hash Tables Chapter 12.7 Wherein we throw all the data into random array slots and somehow obtain O(1) retrieval time Nyhoff, ADTs, Data Structures and.
Implementing Hash and AVL
Priority Queues (Chapter 6.6):
CSE 332: Data Abstractions AVL Trees
CS202 - Fundamental Structures of Computer Science II
Advanced Implementation of Tables
Advanced Implementation of Tables
Binary and Binomial Heaps
Final Review Dr. Yingwu Zhu.
Ch Hash Tables Array or linked list Binary search trees
Priority Queues (Chapter 6):
Ch. 13 Hash Tables  .
Hashing.
Important Problem Types and Fundamental Data Structures
Instructor: Dr. Michael Geiger Spring 2019 Lecture 34: Exam 3 Preview
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Priority Queues Binary Heaps
17CS1102 DATA STRUCTURES © 2018 KLEF – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS RESERVED.
Presentation transcript:

ADTs so far

Lower level ADTs Linked lists (singly- and doubly- linked) Arrays “Stretchable”, efficient, but… Sequential access Arrays Even more efficient, but not “stretchable” Random Access Vectors, Sequences, Lists All the features, but pay in efficiency Really, implemented with the above 1/13/2019 Gene Itkis; cs112

Higher Level ADTs For all: isEmpty() size() insert(elem) remove() Stacks last inserted Queues first inserted Priority Queues highest priority 1/13/2019 Gene Itkis; cs112

Dictionaries Retrieve by key

Dictionary Examples Phone directory Student records Credit cards DB Name is key; phone # is the info Reverse lookup: phone # is key Student records Credit cards DB E.g. check that the given credit card is valid Extra: “Authenticate” the result ETC. 1/13/2019 Gene Itkis; cs112

Dictionary Interface isEmpty() size() insert(elem) find(key) Using elem.key find(key) remove(key) 1/13/2019 Gene Itkis; cs112

Simple Implementations Unordered List insert O(1) – fast (delete: the same) find O(n) – slow Ordered list Linked list implementation – same as unordered Array Binary search: O(lg n) – pretty fast O(n) – slow (delete: the same) 1/13/2019 Gene Itkis; cs112

Better Implementations Ordered trees Hash tables Other Skip-lists 1/13/2019 Gene Itkis; cs112

Ordered Trees Order Depth x< y,z : min at root – heap () x y<x<z : search  Depth Shallow  Balanced There might be exceptions: e.g., Leftist heaps “Strong” balance Approximate  E.g., depth of leaves within factor of 2 (R-B trees) heap 1/13/2019 Gene Itkis; cs112

Ordered Trees Searching Insert/Delete Easy Destroys balance Fix balance How? AVL trees Nodes keep children heights Rotate when needed: when children heights are >1 apart Red-Black/2-3-4 trees 1/13/2019 Gene Itkis; cs112

Hash tables Example Idea Find professors by office number Find tools in a tool-box Might not work for everyone Idea “Figure” info location from the key 1/13/2019 Gene Itkis; cs112

Hash Tables: Idea Hash function If it works… Problem? H(key)=i Find – O(1) Insert/Delete – O(1) Problem? Collisions: H(key’)=H(key) key … H i key info … 1/13/2019 Gene Itkis; cs112

Hash Table: Issues Good Hash functions Collision Resolution … key H Hash table key’ key” Good Hash functions Minimize collision chances “Random looking” Collision Resolution Chaining Open Addressing Linear Probing: d=1 Quadratic Probing: d=i2 Double Hashing: d=H2(key’) key info key info d key’ info key’ info d key” info 1/13/2019 Gene Itkis; cs112

Collision Resolution Methods Comparison Chaining Requires extra space As with linked list Stretchable Can degenerate to linked-list search Open Addressing No extra space needed Has size limit Also can degenerate to unordered list search 1/13/2019 Gene Itkis; cs112