Elementary Data Structures and Hash Tables

Size: px
Start display at page:

Download "Elementary Data Structures and Hash Tables"

Transcription

1 Elementary Data Structures and Hash Tables Antonio Carzaniga Faculty of Informatics University of Lugano November 24, 2006

2 Outline Common concepts and notation Stacks Queues Linked lists Trees Direct-access tables Hash tables

3 Concepts A data structure is a way to organize and store information to facilitate access, or for other purposes

4 Concepts A data structure is a way to organize and store information to facilitate access, or for other purposes A data structure has an interface consisting of procedures for adding, deleting, accessing, reorganizing, etc.

5 Concepts A data structure is a way to organize and store information to facilitate access, or for other purposes A data structure has an interface consisting of procedures for adding, deleting, accessing, reorganizing, etc. A data structure stores data and meta-data e.g., a heap needs an array A to store the keys plus a variable heap-size(a) to remember how many elements are in the heap

6 Notation

7 Notation Data is generally represented with simple variables names e.g., A for the elements of a heap A function notation for meta-data e.g., heap-size(a) for the number of elements in a heap

8 Notation Data is generally represented with simple variables names e.g., A for the elements of a heap A function notation for meta-data e.g., heap-size(a) for the number of elements in a heap Java class Heap { int [] A; int size; } Heap h; //... h.a[0] = 2; h.size = h.size + 1; Our pseudo-code notation A heap-size(a) A[1] 2 heap-size(a) heap-size(a) + 1

9 Notation (2) Another example

10 Notation (2) Another example Java class ListElement { int key; ListElement prev; ListElement next; } class List { ListElement head; } List l; ListElement x; int k; //... k = l.head.next.key; x = l.head.next.next; Our pseudo-code notation x key(x) prev(x) next(x) L head(l) k key(next(head(l))) x next(next(head(l)))

11 Stacks A ubiquitous data structure

12 Stacks A ubiquitous data structure Interface STACK-EMPTY(S) returns TRUE if and only if S is empty PUSH(S, x) pushes the value x onto the stack S empty POP(S) extracts and returns the value on the top of the stack S

13 Stacks A ubiquitous data structure Interface STACK-EMPTY(S) returns TRUE if and only if S is empty PUSH(S, x) pushes the value x onto the stack S empty POP(S) extracts and returns the value on the top of the stack S Implementation using an array using a linked

14 A Stack Implementation

15 A Stack Implementation Array-based implementation S is an array that holds the elements of the stack top(s) is the current position of the top element of S

16 A Stack Implementation Array-based implementation S is an array that holds the elements of the stack top(s) is the current position of the top element of S STACK-EMPTY(S) 1 if top(s) = 0 2 then return TRUE 3 else return FALSE PUSH(S,X) 1 top(s) top(s) S[top(S)] x POP(S) 1 if STACK-EMPTY(S) 2 then error underflow 3 else top(s) top(s) 1 4 return S[top(S) 1]

17 Queues Interface ENQUEUE(Q, x) adds element x at the back of queue Q DEQUEUE(Q) extracts the element at the head of queue Q

18 Queues Interface ENQUEUE(Q, x) adds element x at the back of queue Q DEQUEUE(Q) extracts the element at the head of queue Q Implementation Q is an array of total length length(q) head(q) is the position of the head of the queue tail(q) is the first empty position at the tail of the queue

19 Enqueue ENQUEUE(Q,X) 1 if QUEUE-FULL(Q) 2 then error overflow 3 else Q[tail(Q)] x 4 if tail(q) < length(q) 5 then tail(q) tail(q) else tail(q) 1

20 Enqueue ENQUEUE(Q,X) 1 if QUEUE-FULL(Q) 2 then error overflow 3 else Q[tail(Q)] x 4 if tail(q) < length(q) 5 then tail(q) tail(q) else tail(q) 1 head(q) tail(q)

21 Enqueue ENQUEUE(Q,X) 1 if QUEUE-FULL(Q) 2 then error overflow 3 else Q[tail(Q)] x 4 if tail(q) < length(q) 5 then tail(q) tail(q) else tail(q) 1 head(q) tail(q)

22 Enqueue ENQUEUE(Q,X) 1 if QUEUE-FULL(Q) 2 then error overflow 3 else Q[tail(Q)] x 4 if tail(q) < length(q) 5 then tail(q) tail(q) else tail(q) 1 head(q) tail(q)

23 Enqueue ENQUEUE(Q,X) 1 if QUEUE-FULL(Q) 2 then error overflow 3 else Q[tail(Q)] x 4 if tail(q) < length(q) 5 then tail(q) tail(q) else tail(q) 1 head(q) tail(q)

24 Enqueue ENQUEUE(Q,X) 1 if QUEUE-FULL(Q) 2 then error overflow 3 else Q[tail(Q)] x 4 if tail(q) < length(q) 5 then tail(q) tail(q) else tail(q) 1 head(q) tail(q)

25 Enqueue ENQUEUE(Q,X) 1 if QUEUE-FULL(Q) 2 then error overflow 3 else Q[tail(Q)] x 4 if tail(q) < length(q) 5 then tail(q) tail(q) else tail(q) 1 head(q) tail(q)

26 Enqueue ENQUEUE(Q,X) 1 if QUEUE-FULL(Q) 2 then error overflow 3 else Q[tail(Q)] x 4 if tail(q) < length(q) 5 then tail(q) tail(q) else tail(q) 1 head(q) tail(q)

27 Dequeue DEQUEUE(Q) 1 if QUEUE-EMPTY(Q) 2 then error underflow 3 else x Q[head(Q)] 4 if head(q) < length(q) 5 then head(q) head(q) else head(q) 1 7 return x

28 Dequeue DEQUEUE(Q) 1 if QUEUE-EMPTY(Q) 2 then error underflow 3 else x Q[head(Q)] 4 if head(q) < length(q) 5 then head(q) head(q) else head(q) 1 7 return x head(q) tail(q)

29 Dequeue DEQUEUE(Q) 1 if QUEUE-EMPTY(Q) 2 then error underflow 3 else x Q[head(Q)] 4 if head(q) < length(q) 5 then head(q) head(q) else head(q) 1 7 return x head(q) tail(q)

30 Dequeue DEQUEUE(Q) 1 if QUEUE-EMPTY(Q) 2 then error underflow 3 else x Q[head(Q)] 4 if head(q) < length(q) 5 then head(q) head(q) else head(q) 1 7 return x head(q) tail(q)

31 Dequeue DEQUEUE(Q) 1 if QUEUE-EMPTY(Q) 2 then error underflow 3 else x Q[head(Q)] 4 if head(q) < length(q) 5 then head(q) head(q) else head(q) 1 7 return x head(q) tail(q)

32 Linked Lists Interface LIST-INSERT(L, x) adds element x at beginning of a list L LIST-DELETE(L, x) removes element x from a list L LIST-SEARCH(L, k) finds an element whose key is k in a list L

33 Linked Lists Interface LIST-INSERT(L, x) adds element x at beginning of a list L LIST-DELETE(L, x) removes element x from a list L LIST-SEARCH(L, k) finds an element whose key is k in a list L Implementation a doubly-linked list head(l) is the first element each element x has two links prev(x) and next(x) to the previous and next elements, respectively

34 Trees Structure fixed branching unbounded branching

35 Trees Structure fixed branching unbounded branching Implementation for each node x = root(t), parent(x) is x s parent node fixed branching: e.g., left-child(x) and right-child(x) in a binary tree unbounded branching: left-child(x) is x s first (leftmost) child right-sibling(x) is x closest sibling to the right

36 Complexity STACK-EMPTY PUSH POP ENQUEUE DEQUEUE LIST-INSERT LIST-DELETE LIST-SEARCH O(1) O(1) O(1) O(1) O(1) O(1) O(1) O(n)

37 Dictionary A dictionary is an abstract data structure that represents a set of elements (or keys) a dynamic set

38 Dictionary A dictionary is an abstract data structure that represents a set of elements (or keys) a dynamic set Interface (generic interface) INSERT(D, k) adds a key k to the dictionary D DELETE(D, k) removes key k from D SEARCH(D, x) tells whether D contains a key k

39 Dictionary A dictionary is an abstract data structure that represents a set of elements (or keys) a dynamic set Interface (generic interface) INSERT(D, k) adds a key k to the dictionary D DELETE(D, k) removes key k from D SEARCH(D, x) tells whether D contains a key k Implementation many (concrete) data structures

40 Dictionary A dictionary is an abstract data structure that represents a set of elements (or keys) a dynamic set Interface (generic interface) INSERT(D, k) adds a key k to the dictionary D DELETE(D, k) removes key k from D SEARCH(D, x) tells whether D contains a key k Implementation many (concrete) data structures hash tables

41 Direct-Address Table A direct-address table implements a dictionary

42 Direct-Address Table A direct-address table implements a dictionary The universe of keys is U = {1, 2,...,M}

43 Direct-Address Table A direct-address table implements a dictionary The universe of keys is U = {1, 2,...,M} Implementation an array T of size M each key has its own position in M

44 Direct-Address Table A direct-address table implements a dictionary The universe of keys is U = {1, 2,...,M} Implementation an array T of size M each key has its own position in M DIRECT-ADDRESS-INSERT(T, k) 1 T[k] TRUE DIRECT-ADDRESS-DELETE(T, k) 1 T[k] FALSE DIRECT-ADDRESS-SEARCH(T, k) 1 return T[k]

45 Direct-Address Table (2) All direct-address table operations are O(1)

46 All direct-address table operations are O(1) Direct-Address Table (2) So why isn t every set implemented with a direct-address table? The space complexity is Θ( U )... U is usually a very large number the size of the represented set is usually much smaller than U, which means that a direct-address table usually wastes a lot of space

47 All direct-address table operations are O(1) Direct-Address Table (2) So why isn t every set implemented with a direct-address table? The space complexity is Θ( U )... U is usually a very large number the size of the represented set is usually much smaller than U, which means that a direct-address table usually wastes a lot of space Can we have the benefits of direct-address tables but with much smaller tables?

48 Hash Table Idea we use a table T with length(t) U we map each key k U to a position in T through a hash function h : U {1,...,length(T)}

49 Hash Table Idea we use a table T with length(t) U we map each key k U to a position in T through a hash function h : U {1,...,length(T)} HASH-INSERT(T, k) 1 T[h(k)] TRUE HASH-DELETE(T, k) 1 T[h(k)] FALSE HASH-SEARCH(T, k) 1 return T[h(k)]

50 Hash Table Idea we use a table T with length(t) U we map each key k U to a position in T through a hash function h : U {1,...,length(T)} HASH-INSERT(T, k) 1 T[h(k)] TRUE HASH-DELETE(T, k) 1 T[h(k)] FALSE HASH-SEARCH(T, k) 1 return T[h(k)] Are these algorithms correct?

51 Hash Table Idea we use a table T with length(t) U we map each key k U to a position in T through a hash function h : U {1,...,length(T)} HASH-INSERT(T, k) 1 T[h(k)] TRUE HASH-DELETE(T, k) 1 T[h(k)] FALSE HASH-SEARCH(T, k) 1 return T[h(k)] Are these algorithms correct? No!

52 Hash Table Idea we use a table T with length(t) U we map each key k U to a position in T through a hash function h : U {1,...,length(T)} HASH-INSERT(T, k) 1 T[h(k)] TRUE HASH-DELETE(T, k) 1 T[h(k)] FALSE HASH-SEARCH(T, k) 1 return T[h(k)] Are these algorithms correct? No! What if two distinct keys k 1 = k 2 collide? (I.e., h(k 1 ) = h(k 2 ))

53 Hash Table U T

54 Hash Table U k 1 T

55 Hash Table U k 1 T k 2

56 Hash Table U k 1 T k 2 k 3

57 Hash Table U k 1 k 4 T k 2 k 3

58 Hash Table U k 1 k 4 T k1 k 3 k 2 k 4 k 2 k 3

59 Hash Table U k 1 k 4 T CHAINED-HASH-INSERT(T, k) 1 return LIST-INSERT(T[h(k)], k) k1 k 3 k 2 k 4 k 2 k 3

60 Hash Table U k 1 k 4 T CHAINED-HASH-INSERT(T, k) 1 return LIST-INSERT(T[h(k)], k) k1 k 3 k 2 k 4 k 2 k 3 CHAINED-HASH-SEARCH(T, k) 1 return LIST-SEARCH(T[h(k)], k)

61 Hash Table U k 1 k 4 T CHAINED-HASH-INSERT(T, k) 1 return LIST-INSERT(T[h(k)], k) k1 k 2 k 3 k 4 k 2 load factor n length(t) α = k 3 CHAINED-HASH-SEARCH(T, k) 1 return LIST-SEARCH(T[h(k)], k)

62 Analysis We assume uniform hashing for our hash function h : U {1... T } (where T = length(t))

63 Analysis We assume uniform hashing for our hash function h : U {1... T } (where T = length(t)) Pr[h(k) = i] = 1 T for all i {1... T }

64 Analysis We assume uniform hashing for our hash function h : U {1... T } (where T = length(t)) Pr[h(k) = i] = 1 T for all i {1... T } So, given n distinct keys, the expected length n i of the linked list at position i is E[n i ] = n T = α

65 Analysis We assume uniform hashing for our hash function h : U {1... T } (where T = length(t)) Pr[h(k) = i] = 1 T for all i {1... T } So, given n distinct keys, the expected length n i of the linked list at position i is E[n i ] = n T = α We further assume that h(k) can be computed in O(1) time

66 Analysis We assume uniform hashing for our hash function h : U {1... T } (where T = length(t)) Pr[h(k) = i] = 1 T for all i {1... T } So, given n distinct keys, the expected length n i of the linked list at position i is E[n i ] = n T = α We further assume that h(k) can be computed in O(1) time Therefore, the complexity of CHAINED-HASH-SEARCH is Θ(1 +α)

67 Open-Address Hash Table U T

68 Open-Address Hash Table U k 1 T

69 Open-Address Hash Table U k 1 T k 1

70 Open-Address Hash Table U k 1 T k 1 k 2

71 Open-Address Hash Table U k 1 T k 1 k 2 k 2

72 Open-Address Hash Table U k 1 T k 1 k 2 k 2 k 3

73 Open-Address Hash Table U k 1 T k 1 k 3 k 2 k 2 k 3

74 Open-Address Hash Table U k 1 k 4 T k 1 k 3 k 2 k 2 k 3

75 Open-Address Hash Table U k 1 k 4 T k 1 k 3 k 2 k 2 k 3 k 4

76 Open-Address Hash Table U k 1 k 4 T k 1 k 3 k 2 k 2 k 4 k 3 HASH-INSERT(T, k) 1 j h(k) 2 for i 1 to length(t) 3 do if T[j] = NIL 4 then T[j] k 5 return j 6 elseif j < length(t) 7 then j j else j 1 9 error overflow

77 Open-Addressing (2) Idea: instead of using linked lists, we can store the all elements in the table this implies α 1

78 Open-Addressing (2) Idea: instead of using linked lists, we can store the all elements in the table this implies α 1 When a collision occurs, we simply find another free cell in T

79 Open-Addressing (2) Idea: instead of using linked lists, we can store the all elements in the table this implies α 1 When a collision occurs, we simply find another free cell in T A sequential probe may not be optimal can you figure out why?

80 Open-Addressing (3) HASH-INSERT(T, k) 1 for i 1 to length(t) 2 j h(k, i) 3 do if T[j] = NIL 4 then T[j] k 5 return j 6 error overflow

81 Open-Addressing (3) HASH-INSERT(T, k) 1 for i 1 to length(t) 2 j h(k, i) 3 do if T[j] = NIL 4 then T[j] k 5 return j 6 error overflow Notice that h(k, ) must be a permutation i.e., h(k, 1), h(k, 2),...,h(k, T ) must cover the entire table T

Elementary Data Structures and Hash Tables

Elementary Data Structures and Hash Tables Elementary Data Structures and Hash Tables Antonio Carzaniga Faculty of Informatics Università della Svizzera italiana March 23, 2016 Outline Common concepts and notation Stacks Queues Linked lists Trees

More information

3. Fundamental Data Structures

3. Fundamental Data Structures 3. Fundamental Data Structures CH08-320201: Algorithms and Data Structures 233 Data Structures Definition (recall): A data structure is a way to store and organize data in order to facilitate access and

More information

Algorithms and Data Structures

Algorithms and Data Structures Algorithms and Data Structures CMPSC 465 LECTURE 10 Abstract Data Types Queues Adam Smith 1 Data Structures So far in this class: designing algorithms Inputs and outputs were specified, we wanted to design

More information

Algorithms and Data Structures

Algorithms and Data Structures Algorithms and Data Structures CSE 465 LECTURE 9 Abstract Data Types Queues Sofya Raskhodnikova and Adam Smith 1 Data Structures So far in this class: designing algorithms Inputs and outputs were specified,

More information

Representing and Searching Sets of Strings

Representing and Searching Sets of Strings Representing and Searching Sets of Strings Antonio Carzaniga Faculty of Informatics University of Lugano December 1, 2006 Outline Radix search Ternary search tries Why Sets of Strings? Why Sets of Strings?

More information

Algorithms. 演算法 Data Structures (focus on Trees)

Algorithms. 演算法 Data Structures (focus on Trees) 演算法 Data Structures (focus on Trees) Professor Chien-Mo James Li 李建模 Graduate Institute of Electronics Engineering National Taiwan University 1 Dynamic Set Dynamic set is a set of elements that can grow

More information

Lecture 3: Stacks & Queues

Lecture 3: Stacks & Queues Lecture 3: Stacks & Queues Prakash Gautam https://prakashgautam.com.np/dipit02/ info@prakashgautam.com.np 22 March, 2018 Objectives Definition: Stacks & Queues Operations of Stack & Queues Implementation

More information

DATA STRUCTURES AND ALGORITHMS

DATA STRUCTURES AND ALGORITHMS LECTURE 11 Babeş - Bolyai University Computer Science and Mathematics Faculty 2017-2018 In Lecture 10... Hash tables Separate chaining Coalesced chaining Open Addressing Today 1 Open addressing - review

More information

Announcements. Biostatistics 615/815 Lecture 8: Hash Tables, and Dynamic Programming. Recap: Example of a linked list

Announcements. Biostatistics 615/815 Lecture 8: Hash Tables, and Dynamic Programming. Recap: Example of a linked list Announcements Biostatistics 615/815 Lecture 8:, and Dynamic Programming Hyun Min Kang February 1st, 2011 Homework #2 For problem 3, assume that all the input values are unique Include the class definition

More information

Hash Tables. Reading: Cormen et al, Sections 11.1 and 11.2

Hash Tables. Reading: Cormen et al, Sections 11.1 and 11.2 COMP3600/6466 Algorithms 2018 Lecture 10 1 Hash Tables Reading: Cormen et al, Sections 11.1 and 11.2 Many applications require a dynamic set that supports only the dictionary operations Insert, Search

More information

Binary Search Trees. Antonio Carzaniga. Faculty of Informatics University of Lugano. October 22, Antonio Carzaniga 1

Binary Search Trees. Antonio Carzaniga. Faculty of Informatics University of Lugano. October 22, Antonio Carzaniga 1 Binary Search Trees Antonio Carzaniga Faculty of Informatics University of Lugano October 22, 2008 2006 Antonio Carzaniga 1 Binary search trees Outline Randomized binary search trees 2006 Antonio Carzaniga

More information

CSCE 2014 Final Exam Spring Version A

CSCE 2014 Final Exam Spring Version A CSCE 2014 Final Exam Spring 2017 Version A Student Name: Student UAID: Instructions: This is a two-hour exam. Students are allowed one 8.5 by 11 page of study notes. Calculators, cell phones and computers

More information

8. Fundamental Data Structures

8. Fundamental Data Structures 172 8. Fundamental Data Structures Abstract data types stack, queue, implementation variants for linked lists, [Ottman/Widmayer, Kap. 1.5.1-1.5.2, Cormen et al, Kap. 10.1.-10.2] Abstract Data Types 173

More information

CSCI Analysis of Algorithms I

CSCI Analysis of Algorithms I CSCI 305 - Analysis of Algorithms I 04 June 2018 Filip Jagodzinski Computer Science Western Washington University Announcements Remainder of the term 04 June : lecture 05 June : lecture 06 June : lecture,

More information

III Data Structures. Dynamic sets

III Data Structures. Dynamic sets III Data Structures Elementary Data Structures Hash Tables Binary Search Trees Red-Black Trees Dynamic sets Sets are fundamental to computer science Algorithms may require several different types of operations

More information

Elementary Data Structures. CS 114/116 and CS 505 material. Chapters , of GT

Elementary Data Structures. CS 114/116 and CS 505 material. Chapters , of GT Subject 2 Fall 2016 Elementary Data Structures CS 114/116 and CS 505 material Chapters 2.1-2.3, 4.2.2 of GT Disclaimer: These abbreviated notes DO NOT substitute the textbook for this class. They should

More information

CMSC Introduction to Algorithms Spring 2012 Lecture 7

CMSC Introduction to Algorithms Spring 2012 Lecture 7 CMSC 351 - Introduction to Algorithms Spring 2012 Lecture 7 Instructor: MohammadTaghi Hajiaghayi Scribe: Rajesh Chitnis 1 Introduction In this lecture we give an introduction to Data Structures like arrays,

More information

CS 1114: Implementing Search. Last time. ! Graph traversal. ! Two types of todo lists: ! Prof. Graeme Bailey.

CS 1114: Implementing Search. Last time. ! Graph traversal. ! Two types of todo lists: ! Prof. Graeme Bailey. CS 1114: Implementing Search! Prof. Graeme Bailey http://cs1114.cs.cornell.edu (notes modified from Noah Snavely, Spring 2009) Last time! Graph traversal 1 1 2 10 9 2 3 6 3 5 6 8 5 4 7 9 4 7 8 10! Two

More information

CS301 - Data Structures Glossary By

CS301 - Data Structures Glossary By CS301 - Data Structures Glossary By Abstract Data Type : A set of data values and associated operations that are precisely specified independent of any particular implementation. Also known as ADT Algorithm

More information

Introduction to Data Structures. Introduction to Data Structures. Introduction to Data Structures. Data Structures

Introduction to Data Structures. Introduction to Data Structures. Introduction to Data Structures. Data Structures Philip Bille Data Structures Data structure. Method for organizing data for efficient access, searching, manipulation, etc. Goal. Fast. Compact Terminology. Abstract vs. concrete data structure. Dynamic

More information

Data Structures and Algorithms for Engineers

Data Structures and Algorithms for Engineers 04-630 Data Structures and Algorithms for Engineers David Vernon Carnegie Mellon University Africa vernon@cmu.edu www.vernon.eu Data Structures and Algorithms for Engineers 1 Carnegie Mellon University

More information

if (Q.head = Q.tail + 1) or (Q.head = 1 and Q.tail = Q.length) then throw F ullqueueexception if (Q.head = Q.tail) then throw EmptyQueueException

if (Q.head = Q.tail + 1) or (Q.head = 1 and Q.tail = Q.length) then throw F ullqueueexception if (Q.head = Q.tail) then throw EmptyQueueException data structures en algorithms 2017-2018 exercise class 7: some answers Goal Understanding of the linear data structures stacks, queues, linked lists. Understanding of linked representations of (mainly

More information

Algorithms and Data Structures for Mathematicians

Algorithms and Data Structures for Mathematicians Algorithms and Data Structures for Mathematicians Lecture 3: Basic Data Structures Peter Kostolányi kostolanyi at fmph and so on Room M-258 12 October 2017 Dynamic Sets and Data Structures Many algorithms

More information

CPSC 331 Term Test #2 March 26, 2007

CPSC 331 Term Test #2 March 26, 2007 CPSC 331 Term Test #2 March 26, 2007 Name: Please DO NOT write your ID number on this page. Instructions: Answer all questions in the space provided. Point form answers are acceptable if complete enough

More information

Today s Outline. CS 561, Lecture 8. Direct Addressing Problem. Hash Tables. Hash Tables Trees. Jared Saia University of New Mexico

Today s Outline. CS 561, Lecture 8. Direct Addressing Problem. Hash Tables. Hash Tables Trees. Jared Saia University of New Mexico Today s Outline CS 561, Lecture 8 Jared Saia University of New Mexico Hash Tables Trees 1 Direct Addressing Problem Hash Tables If universe U is large, storing the array T may be impractical Also much

More information

Dictionaries (Maps) Hash tables. ADT Dictionary or Map. n INSERT: inserts a new element, associated to unique value of a field (key)

Dictionaries (Maps) Hash tables. ADT Dictionary or Map. n INSERT: inserts a new element, associated to unique value of a field (key) Dictionaries (Maps) Hash tables ADT Dictionary or Map Has following operations: n INSERT: inserts a new element, associated to unique value of a field (key) n SEARCH: searches an element with a certain

More information

Introduction to Data Structures

Introduction to Data Structures Introduction to Data Structures Data structures Stacks and Queues Linked Lists Dynamic Arrays Philip Bille Introduction to Data Structures Data structures Stacks and Queues Linked Lists Dynamic Arrays

More information

data structures and algorithms lecture 6

data structures and algorithms lecture 6 data structures and algorithms 2017 09 21 lecture 6 overview lower bound counting sort radix sort stacks queues material question we have seen for example insertion sort: worst-case in O(n 2 ) merge sort:

More information

COMP 182 Algorithmic Thinking. Breadth-first Search. Luay Nakhleh Computer Science Rice University

COMP 182 Algorithmic Thinking. Breadth-first Search. Luay Nakhleh Computer Science Rice University COMP 182 Algorithmic Thinking Breadth-first Search Luay Nakhleh Computer Science Rice University Graph Exploration Elucidating graph properties provides a powerful tool for understanding networks and their

More information

Binary Search Trees. Antonio Carzaniga. Faculty of Informatics University of Lugano. October 21, Antonio Carzaniga 1

Binary Search Trees. Antonio Carzaniga. Faculty of Informatics University of Lugano. October 21, Antonio Carzaniga 1 Binary Search Trees Antonio Carzaniga Faculty of Informatics University of Lugano October 21, 2010 2006 Antonio Carzaniga 1 Binary search trees Outline Randomized binary search trees 2006 Antonio Carzaniga

More information

811312A Data Structures and Algorithms, , Exercise 1 Solutions

811312A Data Structures and Algorithms, , Exercise 1 Solutions 811312A Data Structures and Algorithms, 2018-2019, Exercise 1 Solutions Topics of this exercise are stacks, queues, and s. Cormen 3 rd edition, chapter 10. Task 1.1 Assume that L is a containing 1000 items.

More information

CS532: Design and Analysis of Algorithms. Overview. Linked Lists. Data Structures Intro. Classes, Objects, and Pointers.

CS532: Design and Analysis of Algorithms. Overview. Linked Lists. Data Structures Intro. Classes, Objects, and Pointers. CS533 Class 01: 1 c P. Heeman, 2017 What is the Course About? Data Structures Intro Classes, Objects, and Pointers Linked Lists Rooted Trees Overview CS533 Class 01: 2 c P. Heeman, 2017 CS532: Design and

More information

4.1 COMPUTATIONAL THINKING AND PROBLEM-SOLVING

4.1 COMPUTATIONAL THINKING AND PROBLEM-SOLVING 4.1 COMPUTATIONAL THINKING AND PROBLEM-SOLVING 4.1.2 ALGORITHMS ALGORITHM An Algorithm is a procedure or formula for solving a problem. It is a step-by-step set of operations to be performed. It is almost

More information

1 P age DS & OOPS / UNIT II

1 P age DS & OOPS / UNIT II UNIT II Stacks: Definition operations - applications of stack. Queues: Definition - operations Priority queues - De que Applications of queue. Linked List: Singly Linked List, Doubly Linked List, Circular

More information

COMP 250 Midterm #2 March 11 th 2013

COMP 250 Midterm #2 March 11 th 2013 NAME: STUDENT ID: COMP 250 Midterm #2 March 11 th 2013 - This exam has 6 pages - This is an open book and open notes exam. No electronic equipment is allowed. 1) Questions with short answers (28 points;

More information

DATA STRUCTURES AND ALGORITHMS

DATA STRUCTURES AND ALGORITHMS LECTURE 11 Babeş - Bolyai University Computer Science and Mathematics Faculty 2017-2018 In Lecture 9-10... Hash tables ADT Stack ADT Queue ADT Deque ADT Priority Queue Hash tables Today Hash tables 1 Hash

More information

Design and Analysis of Algorithms Lecture- 9: Binary Search Trees

Design and Analysis of Algorithms Lecture- 9: Binary Search Trees Design and Analysis of Algorithms Lecture- 9: Binary Search Trees Dr. Chung- Wen Albert Tsao 1 Binary Search Trees Data structures that can support dynamic set operations. Search, Minimum, Maximum, Predecessor,

More information

Data Structures. Outline. Introduction Linked Lists Stacks Queues Trees Deitel & Associates, Inc. All rights reserved.

Data Structures. Outline. Introduction Linked Lists Stacks Queues Trees Deitel & Associates, Inc. All rights reserved. Data Structures Outline Introduction Linked Lists Stacks Queues Trees Introduction dynamic data structures - grow and shrink during execution Linked lists - insertions and removals made anywhere Stacks

More information

Queues. A queue is a special type of structure that can be used to maintain data in an organized way.

Queues. A queue is a special type of structure that can be used to maintain data in an organized way. A queue is a special type of structure that can be used to maintain data in an organized way. This data structure is commonly implemented in one of two ways: as an array or as a linked list. In either

More information

COMP171. Hashing.

COMP171. Hashing. COMP171 Hashing Hashing 2 Hashing Again, a (dynamic) set of elements in which we do search, insert, and delete Linear ones: lists, stacks, queues, Nonlinear ones: trees, graphs (relations between elements

More information

Abstract vs concrete data structures HEAPS AND PRIORITY QUEUES. Abstract vs concrete data structures. Concrete Data Types. Concrete data structures

Abstract vs concrete data structures HEAPS AND PRIORITY QUEUES. Abstract vs concrete data structures. Concrete Data Types. Concrete data structures 10/1/17 Abstract vs concrete data structures 2 Abstract data structures are interfaces they specify only interface (method names and specs) not implementation (method bodies, fields, ) HEAPS AND PRIORITY

More information

Elementary Data Structures 2

Elementary Data Structures 2 Elementary Data Structures Priority Queues, & Dictionaries Priority Queues Sell 00 IBM $ Sell 300 IBM $0 Buy 00 IBM $9 Buy 400 IBM $8 Priority Queue ADT A priority queue stores a collection of items An

More information

Algorithms and Data Structures

Algorithms and Data Structures Lesson 4: Sets, Dictionaries and Hash Tables Luciano Bononi http://www.cs.unibo.it/~bononi/ (slide credits: these slides are a revised version of slides created by Dr. Gabriele D Angelo)

More information

CS8391-DATA STRUCTURES

CS8391-DATA STRUCTURES ST.JOSEPH COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERI NG CS8391-DATA STRUCTURES QUESTION BANK UNIT I 2MARKS 1.Explain the term data structure. The data structure can be defined

More information

Fundamentals of Data Structure

Fundamentals of Data Structure Fundamentals of Data Structure Set-1 1. Which if the following is/are the levels of implementation of data structure A) Abstract level B) Application level C) Implementation level D) All of the above 2.

More information

CS 8391 DATA STRUCTURES

CS 8391 DATA STRUCTURES DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK CS 8391 DATA STRUCTURES UNIT- I PART A 1. Define: data structure. A data structure is a way of storing and organizing data in the memory for

More information

Hashing Techniques. Material based on slides by George Bebis

Hashing Techniques. Material based on slides by George Bebis Hashing Techniques Material based on slides by George Bebis https://www.cse.unr.edu/~bebis/cs477/lect/hashing.ppt The Search Problem Find items with keys matching a given search key Given an array A, containing

More information

Chapter 5 Data Structures Algorithm Theory WS 2016/17 Fabian Kuhn

Chapter 5 Data Structures Algorithm Theory WS 2016/17 Fabian Kuhn Chapter 5 Data Structures Algorithm Theory WS 06/ Fabian Kuhn Examples Dictionary: Operations: insert(key,value), delete(key), find(key) Implementations: Linked list: all operations take O(n) time (n:

More information

Binary search trees. Support many dynamic-set operations, e.g. Search. Minimum. Maximum. Insert. Delete ...

Binary search trees. Support many dynamic-set operations, e.g. Search. Minimum. Maximum. Insert. Delete ... Binary search trees Support many dynamic-set operations, e.g. Search Minimum Maximum Insert Delete... Can be used as dictionary, priority queue... you name it Running time depends on height of tree: 1

More information

Binary Trees. Recursive definition. Is this a binary tree?

Binary Trees. Recursive definition. Is this a binary tree? Binary Search Trees Binary Trees Recursive definition 1. An empty tree is a binary tree 2. A node with two child subtrees is a binary tree 3. Only what you get from 1 by a finite number of applications

More information

Outlines: Graphs Part-2

Outlines: Graphs Part-2 Elementary Graph Algorithms PART-2 1 Outlines: Graphs Part-2 Graph Search Methods Breadth-First Search (BFS): BFS Algorithm BFS Example BFS Time Complexity Output of BFS: Shortest Path Breath-First Tree

More information

Data Structures Question Bank Multiple Choice

Data Structures Question Bank Multiple Choice Section 1. Fundamentals: Complexity, Algorthm Analysis 1. An algorithm solves A single problem or function Multiple problems or functions Has a single programming language implementation 2. A solution

More information

Basic Data Structures (Version 7) Name:

Basic Data Structures (Version 7) Name: Prerequisite Concepts for Analysis of Algorithms Basic Data Structures (Version 7) Name: Email: Concept: mathematics notation 1. log 2 n is: Code: 21481 (A) o(log 10 n) (B) ω(log 10 n) (C) Θ(log 10 n)

More information

CS8391-DATA STRUCTURES QUESTION BANK UNIT I

CS8391-DATA STRUCTURES QUESTION BANK UNIT I CS8391-DATA STRUCTURES QUESTION BANK UNIT I 2MARKS 1.Define data structure. The data structure can be defined as the collection of elements and all the possible operations which are required for those

More information

Solution for Data Structure

Solution for Data Structure Solution for Data Structure May 2016 INDEX Q1 a 2-3 b 4 c. 4-6 d 7 Q2- a 8-12 b 12-14 Q3 a 15-18 b 18-22 Q4- a 22-35 B..N.A Q5 a 36-38 b N.A Q6- a 39-42 b 43 1 www.brainheaters.in Q1) Ans: (a) Define ADT

More information

Summer Final Exam Review Session August 5, 2009

Summer Final Exam Review Session August 5, 2009 15-111 Summer 2 2009 Final Exam Review Session August 5, 2009 Exam Notes The exam is from 10:30 to 1:30 PM in Wean Hall 5419A. The exam will be primarily conceptual. The major emphasis is on understanding

More information

(b) If a heap has n elements, what s the height of the tree?

(b) If a heap has n elements, what s the height of the tree? CISC 5835 Algorithms for Big Data Fall, 2018 Homework Assignment #4 1 Answer the following questions about binary tree and heap: (a) For a complete binary tree of height 4 (we consider a tree with just

More information

You must include this cover sheet. Either type up the assignment using theory4.tex, or print out this PDF.

You must include this cover sheet. Either type up the assignment using theory4.tex, or print out this PDF. 15-122 Assignment 4 Page 1 of 12 15-122 : Principles of Imperative Computation Fall 2012 Assignment 4 (Theory Part) Due: Thursday, October 18, 2012 at the beginning of lecture Name: Andrew ID: Recitation:

More information

Data Structures and Algorithms. Chapter 7. Hashing

Data Structures and Algorithms. Chapter 7. Hashing 1 Data Structures and Algorithms Chapter 7 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples

More information

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT)

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT) D B3D042 Pages: 2 Reg. No. Name: APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 Max. Marks: 100 CS205: DATA STRUCTURES (CS, IT) PART A Answer all questions.

More information

CS 241 Analysis of Algorithms

CS 241 Analysis of Algorithms CS 241 Analysis of Algorithms Professor Eric Aaron Lecture T Th 9:00am Lecture Meeting Location: OLB 205 Business HW5 extended, due November 19 HW6 to be out Nov. 14, due November 26 Make-up lecture: Wed,

More information

INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad - 500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name Course Code Class Branch DATA STRUCTURES ACS002 B. Tech

More information

CS 270 Algorithms. Oliver Kullmann. Binary search. Lists. Background: Pointers. Trees. Implementing rooted trees. Tutorial

CS 270 Algorithms. Oliver Kullmann. Binary search. Lists. Background: Pointers. Trees. Implementing rooted trees. Tutorial Week 7 General remarks Arrays, lists, pointers and 1 2 3 We conclude elementary data structures by discussing and implementing arrays, lists, and trees. Background information on pointers is provided (for

More information

Basic Data Structures and Heaps

Basic Data Structures and Heaps Basic Data Structures and Heaps David Kauchak Sorting demo (http://math.hws.edu/tmcm/java/xsortlab/) Data structures What is a data structure? Way of storing data that facilitates particular operations.

More information

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE TED (10)-3071 Reg. No.. (REVISION-2010) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours (Maximum marks: 100)

More information

Data Structure Lecture#22: Searching 3 (Chapter 9) U Kang Seoul National University

Data Structure Lecture#22: Searching 3 (Chapter 9) U Kang Seoul National University Data Structure Lecture#22: Searching 3 (Chapter 9) U Kang Seoul National University U Kang 1 In This Lecture Motivation of collision resolution policy Open hashing for collision resolution Closed hashing

More information

Week 6. Data structures

Week 6. Data structures 1 2 3 4 5 n Week 6 Data structures 6 7 n 8 General remarks We start considering Part III Data Structures from CLRS. As a first example we consider two special of buffers, namely stacks and queues. Reading

More information

Dictionaries and Hash Tables

Dictionaries and Hash Tables Dictionaries and Hash Tables Nicholas Mainardi Dipartimento di Elettronica e Informazione Politecnico di Milano nicholas.mainardi@polimi.it 14th June 2017 Dictionaries What is a dictionary? A dictionary

More information

We don t have much time, so we don t teach them [students]; we acquaint them with things that they can learn. Charles E. Leiserson

We don t have much time, so we don t teach them [students]; we acquaint them with things that they can learn. Charles E. Leiserson Homework 3 CS 321 - Data Structures Fall 2018 Dec 6, 2018 Name: Collaborators: We don t have much time, so we don t teach them [students]; we acquaint them with things that they can learn. Charles E. Leiserson

More information

Week 5, continued. This is CS50. Harvard University. Fall Anna Whitney

Week 5, continued. This is CS50. Harvard University. Fall Anna Whitney This is CS50. Harvard University. Fall 2015. Anna Whitney Table of Contents 1. Linked Lists, continued... 1 1.1. Searching... 2 2. Stacks & Queues... 4 3. Memory... 9 4. More Data Structures... 13 5. Compression...

More information

Module 1: Asymptotic Time Complexity and Intro to Abstract Data Types

Module 1: Asymptotic Time Complexity and Intro to Abstract Data Types Module 1: Asymptotic Time Complexity and Intro to Abstract Data Types Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu

More information

MLR Institute of Technology

MLR Institute of Technology MLR Institute of Technology Laxma Reddy Avenue, Dundigal, Quthbullapur (M), Hyderabad 500 043 Phone Nos: 08418 204066 / 204088, Fax : 08418 204088 TUTORIAL QUESTION BANK Course Name : DATA STRUCTURES Course

More information

This lecture. Iterators ( 5.4) Maps. Maps. The Map ADT ( 8.1) Comparison to java.util.map

This lecture. Iterators ( 5.4) Maps. Maps. The Map ADT ( 8.1) Comparison to java.util.map This lecture Iterators Hash tables Formal coursework Iterators ( 5.4) An iterator abstracts the process of scanning through a collection of elements Methods of the ObjectIterator ADT: object object() boolean

More information

COP 3502 (Computer Science I) Test #3: Data Structures Date: 11/1/2013 VERSION A

COP 3502 (Computer Science I) Test #3: Data Structures Date: 11/1/2013 VERSION A COP 3502 (Computer Science I) Test #3: Data Structures Date: 11/1/2013 VERSION A Directions: This is a multiple choice test. Each question is worth 5 points. Please choose the most accurate answer listed.

More information

How to Win Coding Competitions: Secrets of Champions. Week 2: Computational complexity. Linear data structures Lecture 5: Stack. Queue.

How to Win Coding Competitions: Secrets of Champions. Week 2: Computational complexity. Linear data structures Lecture 5: Stack. Queue. How to Win Coding Competitions: Secrets of Champions Week 2: Computational complexity. Linear data structures Lecture 5: Stack. Queue. Deque Pavel Krotkov Saint Petersburg 2016 General overview Stack,

More information

You must print this PDF and write your answers neatly by hand. You should hand in the assignment before recitation begins.

You must print this PDF and write your answers neatly by hand. You should hand in the assignment before recitation begins. 15-122 Homework 4 Page 1 of 13 15-122 : Principles of Imperative Computation, Summer 1 2014 Written Homework 4 Due: Thursday, June 12 before recitation Name: Andrew ID: Recitation: In this assignment,

More information

Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 1

Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 1 UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series UG Examination 2015-16 DATA STRUCTURES AND ALGORITHMS CMP-5014Y Time allowed: 3 hours Section A (Attempt any 4 questions: 60 marks) Section

More information

Data Abstractions. National Chiao Tung University Chun-Jen Tsai 05/23/2012

Data Abstractions. National Chiao Tung University Chun-Jen Tsai 05/23/2012 Data Abstractions National Chiao Tung University Chun-Jen Tsai 05/23/2012 Concept of Data Structures How do we store some conceptual structure in a linear memory? For example, an organization chart: 2/32

More information

Xoo. Address. October 19,

Xoo.  Address. October 19, Xoo October 19, 2004 Email Address texnician@163.com 3 Preface :P http://ftp.cdaan.com/sy/light/clrs_study.pdf 1 Copyright 2004 lightzju@hotmail.com. All rights reserved. lightzju@hotmail.com 2004 Permission

More information

1. Attempt any three of the following: 15

1. Attempt any three of the following: 15 (Time: 2½ hours) Total Marks: 75 N. B.: (1) All questions are compulsory. (2) Make suitable assumptions wherever necessary and state the assumptions made. (3) Answers to the same question must be written

More information

Quiz 1 Practice Problems

Quiz 1 Practice Problems Introduction to Algorithms: 6.006 Massachusetts Institute of Technology March 7, 2008 Professors Srini Devadas and Erik Demaine Handout 6 1 Asymptotic Notation Quiz 1 Practice Problems Decide whether these

More information

Computer Programming II C++ (830)

Computer Programming II C++ (830) DESCRIPTION This is an advanced course in computer programming/software engineering and applications. It reviews and builds on the concepts introduced in CP I. It introduces students to dynamic data structures,

More information

Dictionary. Dictionary. stores key-value pairs. Find(k) Insert(k, v) Delete(k) List O(n) O(1) O(n) Sorted Array O(log n) O(n) O(n)

Dictionary. Dictionary. stores key-value pairs. Find(k) Insert(k, v) Delete(k) List O(n) O(1) O(n) Sorted Array O(log n) O(n) O(n) Hash-Tables Introduction Dictionary Dictionary stores key-value pairs Find(k) Insert(k, v) Delete(k) List O(n) O(1) O(n) Sorted Array O(log n) O(n) O(n) Balanced BST O(log n) O(log n) O(log n) Dictionary

More information

ECE250: Algorithms and Data Structures Midterm Review

ECE250: Algorithms and Data Structures Midterm Review ECE250: Algorithms and Data Structures Midterm Review Ladan Tahvildari, PEng, SMIEEE Associate Professor Software Technologies Applied Research (STAR) Group Dept. of Elect. & Comp. Eng. University of Waterloo

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 3 Data Structures Graphs Traversals Strongly connected components Sofya Raskhodnikova L3.1 Measuring Running Time Focus on scalability: parameterize the running time

More information

Course Review. Cpt S 223 Fall 2009

Course Review. Cpt S 223 Fall 2009 Course Review Cpt S 223 Fall 2009 1 Final Exam When: Tuesday (12/15) 8-10am Where: in class Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes Homeworks & program

More information

Quiz 1 Practice Problems

Quiz 1 Practice Problems Introduction to Algorithms: 6.006 Massachusetts Institute of Technology March 7, 2008 Professors Srini Devadas and Erik Demaine Handout 6 1 Asymptotic Notation Quiz 1 Practice Problems Decide whether these

More information

SEQUENCES, ARRAYS, AND LINKED LISTS

SEQUENCES, ARRAYS, AND LINKED LISTS SEQUENCES, ARRAYS, AND LINKED LISTS (with remarks on recursion and values vs. references) University of Waterloo LIST OF SLIDES 1-1 List of Slides 1 2 List and Stack ADTs 3 Linked List Data Structure 4

More information

Lecture 4: Elementary Data Structures Steven Skiena

Lecture 4: Elementary Data Structures Steven Skiena Lecture 4: Elementary Data Structures Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.stonybrook.edu/ skiena Problem of the Day Find two

More information

CSI33 Data Structures

CSI33 Data Structures Outline Department of Mathematics and Computer Science Bronx Community College November 30, 2016 Outline Outline 1 Chapter 13: Heaps, Balances Trees and Hash Tables Hash Tables Outline 1 Chapter 13: Heaps,

More information

Symbol Table. Symbol table is used widely in many applications. dictionary is a kind of symbol table data dictionary is database management

Symbol Table. Symbol table is used widely in many applications. dictionary is a kind of symbol table data dictionary is database management Hashing Symbol Table Symbol table is used widely in many applications. dictionary is a kind of symbol table data dictionary is database management In general, the following operations are performed on

More information

STACKS AND QUEUES. Problem Solving with Computers-II

STACKS AND QUEUES. Problem Solving with Computers-II STACKS AND QUEUES Problem Solving with Computers-II 2 Stacks container class available in the C++ STL Container class that uses the Last In First Out (LIFO) principle Methods i. push() ii. iii. iv. pop()

More information

PA3 Design Specification

PA3 Design Specification PA3 Teaching Data Structure 1. System Description The Data Structure Web application is written in JavaScript and HTML5. It has been divided into 9 pages: Singly linked page, Stack page, Postfix expression

More information

UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING ECE 250 ALGORITHMS AND DATA STRUCTURES

UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING ECE 250 ALGORITHMS AND DATA STRUCTURES UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING ECE 250 ALGORITHMS AND DATA STRUCTURES Final Examination (8 pages) Instructor: R.E.Seviora 9-12 AM, Apr 16, 2003 Name (last, first)

More information

5. Hashing. 5.1 General Idea. 5.2 Hash Function. 5.3 Separate Chaining. 5.4 Open Addressing. 5.5 Rehashing. 5.6 Extendible Hashing. 5.

5. Hashing. 5.1 General Idea. 5.2 Hash Function. 5.3 Separate Chaining. 5.4 Open Addressing. 5.5 Rehashing. 5.6 Extendible Hashing. 5. 5. Hashing 5.1 General Idea 5.2 Hash Function 5.3 Separate Chaining 5.4 Open Addressing 5.5 Rehashing 5.6 Extendible Hashing Malek Mouhoub, CS340 Fall 2004 1 5. Hashing Sequential access : O(n). Binary

More information

CS 561, Lecture 2 : Randomization in Data Structures. Jared Saia University of New Mexico

CS 561, Lecture 2 : Randomization in Data Structures. Jared Saia University of New Mexico CS 561, Lecture 2 : Randomization in Data Structures Jared Saia University of New Mexico Outline Hash Tables Bloom Filters Skip Lists 1 Dictionary ADT A dictionary ADT implements the following operations

More information

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators) Name: Email address: Quiz Section: CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will

More information

CARNEGIE MELLON UNIVERSITY DEPT. OF COMPUTER SCIENCE DATABASE APPLICATIONS

CARNEGIE MELLON UNIVERSITY DEPT. OF COMPUTER SCIENCE DATABASE APPLICATIONS CARNEGIE MELLON UNIVERSITY DEPT. OF COMPUTER SCIENCE 15-415 DATABASE APPLICATIONS C. Faloutsos Indexing and Hashing 15-415 Database Applications http://www.cs.cmu.edu/~christos/courses/dbms.s00/ general

More information

Computer Programming II Python

Computer Programming II Python EXAM INFORMATION Items 32 Points 33 Prerequisites SECONDARY MATH I COMPUTER PROGRAMMING I Grade Level 10-12 Course Length ONE YEAR DESCRIPTION This is an advanced course in computer programming/software

More information

Practical Session 8- Hash Tables

Practical Session 8- Hash Tables Practical Session 8- Hash Tables Hash Function Uniform Hash Hash Table Direct Addressing A hash function h maps keys of a given type into integers in a fixed interval [0,m-1] 1 Pr h( key) i, where m is

More information