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 Università della Svizzera italiana March 23, 2016

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

3 Concepts Adatastructureisawaytoorganizeandstoreinformation to facilitate access, or for other purposes

4 Concepts Adatastructureisawaytoorganizeandstoreinformation to facilitate access, or for other purposes A data structure has an interface consisting of procedures for adding, deleting, accessing, reorganizing, etc.

5 Concepts Adatastructureisawaytoorganizeandstoreinformation 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 possibly meta-data

6 Concepts Adatastructureisawaytoorganizeandstoreinformation 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 possibly meta-data e.g.,aheapneedsanarrayatostorethekeys,plusavariable A.heap-sizetorememberhowmanyelementsareintheheap

7 The ubiquitous last-in first-out container(lifo) Stack

8 Stack The ubiquitous last-in first-out container(lifo) Interface STACK-EMPTY(S)returnsTRUEifandonlyifSisempty PUSH(S,x)pushesthevaluexontothestackS POP(S)extractsandreturnsthevalueonthetopofthestackS

9 Stack The ubiquitous last-in first-out container(lifo) Interface STACK-EMPTY(S)returnsTRUEifandonlyifSisempty PUSH(S,x)pushesthevaluexontothestackS POP(S)extractsandreturnsthevalueonthetopofthestackS Implementation usinganarray usingalinkedlist...

10 A Stack Implementation

11 Array-based implementation A Stack Implementation

12 A Stack Implementation Array-based implementation Sisanarraythatholdstheelementsofthestack S.topisthecurrentpositionofthetopelementofS

13 A Stack Implementation Array-based implementation Sisanarraythatholdstheelementsofthestack S.topisthecurrentpositionofthetopelementofS STACK-EMPTY(S) 1 ifs.top==0 2 return TRUE 3 else return FALSE

14 A Stack Implementation Array-based implementation Sisanarraythatholdstheelementsofthestack S.topisthecurrentpositionofthetopelementofS STACK-EMPTY(S) 1 ifs.top==0 2 return TRUE 3 else return FALSE PUSH(S,X) 1 S.top =S.top+1 2 S[S.top] =x POP(S) 1 if STACK-EMPTY(S) 2 error underflow 3 elses.top =S.top 1 4 return S[S.top + 1]

15 The ubiquitous first-in first-out container(fifo) Queue

16 Queue The ubiquitous first-in first-out container(fifo) Interface ENQUEUE(Q,x)addselementxatthebackofqueueQ DEQUEUE(Q)extractstheelementattheheadofqueueQ

17 Queue The ubiquitous first-in first-out container(fifo) Interface ENQUEUE(Q,x)addselementxatthebackofqueueQ DEQUEUE(Q)extractstheelementattheheadofqueueQ Implementation QisanarrayoffixedlengthQ.length i.e.,qholdsatmostq.lengthelements enqueueing more than Q elements causes an overflow error Q.headisthepositionofthe head ofthequeue Q.tailisthefirstemptypositionatthetailofthequeue

18 Enqueue ENQUEUE(Q,X) 1 if Q.queue-full 2 error overflow 3 elseq[q.tail] =x 4 if Q.tail < Q.length 5 Q.tail =Q.tail+1 6 elseq.tail =1 7 if Q.tail == Q.head 8 Q.queue-full = TRUE 9 Q.queue-empty = FALSE

19 Enqueue ENQUEUE(Q,X) 1 if Q.queue-full 2 error overflow 3 elseq[q.tail] =x 4 if Q.tail < Q.length 5 Q.tail =Q.tail+1 6 elseq.tail =1 7 if Q.tail == Q.head 8 Q.queue-full = TRUE 9 Q.queue-empty = FALSE Q.head Q.tail

20 Enqueue ENQUEUE(Q,X) 1 if Q.queue-full 2 error overflow 3 elseq[q.tail] =x 4 if Q.tail < Q.length 5 Q.tail =Q.tail+1 6 elseq.tail =1 7 if Q.tail == Q.head 8 Q.queue-full = TRUE 9 Q.queue-empty = FALSE Q.head Q.tail

21 Enqueue ENQUEUE(Q,X) 1 if Q.queue-full 2 error overflow 3 elseq[q.tail] =x 4 if Q.tail < Q.length 5 Q.tail =Q.tail+1 6 elseq.tail =1 7 if Q.tail == Q.head 8 Q.queue-full = TRUE 9 Q.queue-empty = FALSE Q.head Q.tail

22 Enqueue ENQUEUE(Q,X) 1 if Q.queue-full 2 error overflow 3 elseq[q.tail] =x 4 if Q.tail < Q.length 5 Q.tail =Q.tail+1 6 elseq.tail =1 7 if Q.tail == Q.head 8 Q.queue-full = TRUE 9 Q.queue-empty = FALSE Q.head Q.tail

23 Enqueue ENQUEUE(Q,X) 1 if Q.queue-full 2 error overflow 3 elseq[q.tail] =x 4 if Q.tail < Q.length 5 Q.tail =Q.tail+1 6 elseq.tail =1 7 if Q.tail == Q.head 8 Q.queue-full = TRUE 9 Q.queue-empty = FALSE Q.head Q.tail

24 Enqueue ENQUEUE(Q,X) 1 if Q.queue-full 2 error overflow 3 elseq[q.tail] =x 4 if Q.tail < Q.length 5 Q.tail =Q.tail+1 6 elseq.tail =1 7 if Q.tail == Q.head 8 Q.queue-full = TRUE 9 Q.queue-empty = FALSE Q.head Q.tail

25 Enqueue ENQUEUE(Q,X) 1 if Q.queue-full 2 error overflow 3 elseq[q.tail] =x 4 if Q.tail < Q.length 5 Q.tail =Q.tail+1 6 elseq.tail =1 7 if Q.tail == Q.head 8 Q.queue-full = TRUE 9 Q.queue-empty = FALSE Q.head Q.tail

26 Dequeue DEQUEUE(Q) 1 if Q.queue-empty 2 error underflow 3 elsex =Q[Q.head] 4 if Q.head < Q.length 5 Q.head =Q.head+1 6 elseq.head =1 7 if Q.tail == Q.head 8 Q.queue-empty = TRUE 9 Q.queue-full = FALSE 10 return x

27 Dequeue DEQUEUE(Q) 1 if Q.queue-empty 2 error underflow 3 elsex =Q[Q.head] 4 if Q.head < Q.length 5 Q.head =Q.head+1 6 elseq.head =1 7 if Q.tail == Q.head 8 Q.queue-empty = TRUE 9 Q.queue-full = FALSE 10 return x Q.head Q.tail

28 Dequeue DEQUEUE(Q) 1 if Q.queue-empty 2 error underflow 3 elsex =Q[Q.head] 4 if Q.head < Q.length 5 Q.head =Q.head+1 6 elseq.head =1 7 if Q.tail == Q.head 8 Q.queue-empty = TRUE 9 Q.queue-full = FALSE 10 return x Q.head Q.tail

29 Dequeue DEQUEUE(Q) 1 if Q.queue-empty 2 error underflow 3 elsex =Q[Q.head] 4 if Q.head < Q.length 5 Q.head =Q.head+1 6 elseq.head =1 7 if Q.tail == Q.head 8 Q.queue-empty = TRUE 9 Q.queue-full = FALSE 10 return x Q.head Q.tail

30 Dequeue DEQUEUE(Q) 1 if Q.queue-empty 2 error underflow 3 elsex =Q[Q.head] 4 if Q.head < Q.length 5 Q.head =Q.head+1 6 elseq.head =1 7 if Q.tail == Q.head 8 Q.queue-empty = TRUE 9 Q.queue-full = FALSE 10 return x Q.head Q.tail

31 Linked List Interface LIST-INSERT(L,x)addselementxatbeginningofalistL LIST-DELETE(L,x)removeselementxfromalistL LIST-SEARCH(L,k)findsanelementwhosekeyiskinalistL

32 Linked List Interface LIST-INSERT(L,x)addselementxatbeginningofalistL LIST-DELETE(L,x)removeselementxfromalistL LIST-SEARCH(L,k)findsanelementwhosekeyiskinalistL Implementation a doubly-linked list eachelementxhastwo links x.prevandx.nexttothe previous and next elements, respectively eachelementxholdsakeyx.key itisconvenienttohaveadummy sentinel elementl.nil

33 Linked List With a Sentinel LIST-INIT(L) 1 L.nil.prev = L.nil 2 L.nil.next = L.nil LIST-INSERT(L, x) 1 x.next = L.nil.next 2 L.nil.next.prev = x 3 L.nil.next =x 4 x.prev =L.nil LIST-SEARCH(L, k) 1 x =L.nil.next 2 whilex L.nil x.key k 3 x =x.next 4 returnx

34 Trees Structure fixed branching unbounded branching

35 Trees Structure fixed branching unbounded branching Implementation foreachnodex T.root,x.parentisx sparentnode fixed branching: e.g., x. left-child and x. right-child in a binary tree unbounded branching: x. left-child is x s first(leftmost) child x. right-sibling is x closest sibling to the right

36 Complexity

37 Algorithm Complexity Complexity

38 Complexity Algorithm Complexity STACK-EMPTY

39 Complexity Algorithm Complexity STACK-EMPTY O(1) PUSH

40 Complexity Algorithm Complexity STACK-EMPTY O(1) PUSH POP ENQUEUE DEQUEUE O(1) O(1) O(1) O(1) LIST-INSERT

41 Complexity Algorithm Complexity STACK-EMPTY O(1) PUSH POP ENQUEUE DEQUEUE LIST-INSERT O(1) O(1) O(1) O(1) O(1) LIST-DELETE

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

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

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

45 Dictionary A dictionary is an abstract data structure that represents a set of elements(or keys) adynamicset Interface(generic interface) INSERT(D,k)addsakeyktothedictionaryD DELETE(D,k)removeskeykfromD SEARCH(D,k)tellswhetherDcontainsakeyk

46 Dictionary A dictionary is an abstract data structure that represents a set of elements(or keys) adynamicset Interface(generic interface) INSERT(D,k)addsakeyktothedictionaryD DELETE(D,k)removeskeykfromD SEARCH(D,k)tellswhetherDcontainsakeyk Implementation many(concrete) data structures

47 Dictionary A dictionary is an abstract data structure that represents a set of elements(or keys) adynamicset Interface(generic interface) INSERT(D,k)addsakeyktothedictionaryD DELETE(D,k)removeskeykfromD SEARCH(D,k)tellswhetherDcontainsakeyk Implementation many(concrete) data structures hash tables

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

49 Direct-Address Table A direct-address table implements a dictionary TheuniverseofkeysisU = {1,2,...,M}

50 Direct-Address Table A direct-address table implements a dictionary TheuniverseofkeysisU = {1,2,...,M} Implementation anarraytofsizem eachkeyhasitsownpositionint

51 Direct-Address Table A direct-address table implements a dictionary TheuniverseofkeysisU = {1,2,...,M} Implementation anarraytofsizem eachkeyhasitsownpositionint 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]

52 Complexity Direct-Address Table (2)

53 Direct-Address Table (2) Complexity All direct-address table operations are O(1)!

54 Direct-Address Table (2) Complexity All direct-address table operations are O(1)! So why isn t every set implemented with a direct-address table?

55 Direct-Address Table (2) Complexity All direct-address table operations are O(1)! So why isn t every set implemented with a direct-address table? ThespacecomplexityisΘ( U ) U istypicallyaverylargenumber Uistheuniverseofkeys! therepresentedsetistypicallymuchsmallerthan U i.e.,adirect-addresstableusuallywastesalotofspace

56 Direct-Address Table (2) Complexity All direct-address table operations are O(1)! So why isn t every set implemented with a direct-address table? ThespacecomplexityisΘ( U ) U istypicallyaverylargenumber Uistheuniverseofkeys! therepresentedsetistypicallymuchsmallerthan U i.e.,adirect-addresstableusuallywastesalotofspace Canwehavethebenefitsofadirect-addresstablebutwitha table of reasonable size?

57 Hash Table Idea useatabletwith T U mapeachkeyk UtoapositioninT,usingahashfunction h :U {1,..., T }

58 Hash Table Idea useatabletwith T U mapeachkeyk UtoapositioninT,usingahashfunction h :U {1,..., T } HASH-INSERT(T, k) 1 T[h(k)] =TRUE HASH-DELETE(T, k) 1 T[h(k)] =FALSE HASH-SEARCH(T, k) 1 returnt[h(k)]

59 Hash Table Idea useatabletwith T U mapeachkeyk UtoapositioninT,usingahashfunction h :U {1,..., T } HASH-INSERT(T, k) 1 T[h(k)] =TRUE HASH-DELETE(T, k) 1 T[h(k)] =FALSE HASH-SEARCH(T, k) 1 returnt[h(k)] Are these algorithms correct?

60 Hash Table Idea useatabletwith T U mapeachkeyk UtoapositioninT,usingahashfunction h :U {1,..., T } HASH-INSERT(T, k) 1 T[h(k)] =TRUE HASH-DELETE(T, k) 1 T[h(k)] =FALSE HASH-SEARCH(T, k) 1 returnt[h(k)] Are these algorithms correct? No!

61 Hash Table Idea useatabletwith T U mapeachkeyk UtoapositioninT,usingahashfunction h :U {1,..., T } HASH-INSERT(T, k) 1 T[h(k)] =TRUE HASH-DELETE(T, k) 1 T[h(k)] =FALSE HASH-SEARCH(T, k) 1 returnt[h(k)] Are these algorithms correct? No! Whatiftwodistinctkeysk 1 k 2 collide?(i.e.,h(k 1 ) =h(k 2 ))

62 Hash Table U T

63 Hash Table U k 1 T

64 Hash Table U k 1 T k 2

65 Hash Table U k 1 T k 2 k 3

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

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

68 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

69 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)

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

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

72 Analysis We assume uniform hashing for our hash function h :U {1... T }(where T =T.length) Pr[h(k) =i] = 1 T foralli {1... T } (The formalism is actually a bit more complicated.)

73 Analysis We assume uniform hashing for our hash function h :U {1... T }(where T =T.length) Pr[h(k) =i] = 1 T foralli {1... T } (The formalism is actually a bit more complicated.) So,givenndistinctkeys,theexpectedlengthn i ofthelinked listatpositioniis E[n i ] = n T = α

74 Analysis We assume uniform hashing for our hash function h :U {1... T }(where T =T.length) Pr[h(k) =i] = 1 T foralli {1... T } (The formalism is actually a bit more complicated.) So,givenndistinctkeys,theexpectedlengthn i ofthelinked listatpositioniis E[n i ] = n T = α Wefurtherassumethath(k)canbecomputedinO(1)time

75 Analysis We assume uniform hashing for our hash function h :U {1... T }(where T =T.length) Pr[h(k) =i] = 1 T foralli {1... T } (The formalism is actually a bit more complicated.) So,givenndistinctkeys,theexpectedlengthn i ofthelinked listatpositioniis E[n i ] = n T = α Wefurtherassumethath(k)canbecomputedinO(1)time Therefore, the complexity of CHAINED-HASH-SEARCH is Θ(1+α)

76 Open-Address Hash Table U T

77 Open-Address Hash Table U k 1 T

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

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

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

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

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

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

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

85 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 fori =1toT.length 3 ift[j]==nil 4 T[j] =k 5 return j 6 elseifj<t.length 7 j =j+1 8 elsej =1 9 error overflow

86 Open-Addressing (2) Idea:insteadofusinglinkedlists,wecanstoreallthe elements in the table thisimpliesα 1

87 Open-Addressing (2) Idea:insteadofusinglinkedlists,wecanstoreallthe elements in the table thisimpliesα 1 Whenacollisionoccurs,wesimplyfindanotherfreecellinT

88 Open-Addressing (2) Idea:insteadofusinglinkedlists,wecanstoreallthe elements in the table thisimpliesα 1 Whenacollisionoccurs,wesimplyfindanotherfreecellinT A sequential probe may not be optimal canyoufigureoutwhy?

89 Open-Addressing (3) HASH-INSERT(T, k) 1 fori =1toT.length 2 j =h(k,i) 3 ift[j]==nil 4 T[j] =k 5 return j 6 error overflow

90 Open-Addressing (3) HASH-INSERT(T, k) 1 fori =1toT.length 2 j =h(k,i) 3 ift[j]==nil 4 T[j] =k 5 return j 6 error overflow Noticethath(k, )mustbeapermutation i.e.,h(k,1),h(k,2),...,h(k, T )mustcovertheentiretablet

Elementary Data Structures and Hash Tables

Elementary Data Structures and Hash Tables Elementary Data Structures and Hash Tables Antonio Carzaniga Faculty of Informatics University of Lugano November 24, 2006 Outline Common concepts and notation Stacks Queues Linked lists Trees Direct-access

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

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

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

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

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

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

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

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 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

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

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

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

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

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

Red-Black Trees (2) Antonio Carzaniga. April 23, Faculty of Informatics Università della Svizzera italiana Antonio Carzaniga

Red-Black Trees (2) Antonio Carzaniga. April 23, Faculty of Informatics Università della Svizzera italiana Antonio Carzaniga Red-Black Trees (2) Antonio Carzaniga Faculty of Informatics Università della Svizzera italiana April 23, 2013 Recap on Red-Black Trees 2006 Antonio Carzaniga Recap on Red-Black Trees 12 5 18 2 9 15 19

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

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

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

1 Lower bound on runtime of comparison sorts

1 Lower bound on runtime of comparison sorts 1 Lower bound on runtime of comparison sorts So far we ve looked at several sorting algorithms insertion sort, merge sort, heapsort, and quicksort. Merge sort and heapsort run in worst-case O(n log n)

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

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

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

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

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

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

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

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

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

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

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

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

Abstract Data Types CHAPTER 12. Review Questions

Abstract Data Types CHAPTER 12. Review Questions PTR bstract ata Types Review Questions. n abstract data type is a data declaration packaged together with the operations that are meaningful for the data type with the implementation hidden from the user..

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

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

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

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

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

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

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

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

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

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

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

University of Waterloo Department of Electrical and Computer Engineering ECE250 Algorithms and Data Structures Fall 2014

University of Waterloo Department of Electrical and Computer Engineering ECE250 Algorithms and Data Structures Fall 2014 University of Waterloo Department of Electrical and Computer Engineering ECE250 Algorithms and Data Structures Fall 2014 Midterm Examination Instructor: Ladan Tahvildari, PhD, PEng, SMIEEE Date: Tuesday,

More information

(2,4) Trees. 2/22/2006 (2,4) Trees 1

(2,4) Trees. 2/22/2006 (2,4) Trees 1 (2,4) Trees 9 2 5 7 10 14 2/22/2006 (2,4) Trees 1 Outline and Reading Multi-way search tree ( 10.4.1) Definition Search (2,4) tree ( 10.4.2) Definition Search Insertion Deletion Comparison of dictionary

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

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

Objective Questions for Online Practical Exams under CBCS Scheme Subject: Data Structure-I (CS-113)

Objective Questions for Online Practical Exams under CBCS Scheme Subject: Data Structure-I (CS-113) Objective Questions for Online Practical Exams under CBCS Scheme Subject: Data Structure-I (CS-113) 1. The number of interchanges required to sort 5, 1, 6, 2 4 in ascending order using Bubble Sort (A)

More information

COSC160: Data Structures: Lists and Queues. Jeremy Bolton, PhD Assistant Teaching Professor

COSC160: Data Structures: Lists and Queues. Jeremy Bolton, PhD Assistant Teaching Professor COSC160: Data Structures: Lists and Queues Jeremy Bolton, PhD Assistant Teaching Professor Outline I. Queues I. FIFO Queues I. Usage II. Implementations II. LIFO Queues (Stacks) I. Usage II. Implementations

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

(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

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

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

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

Linked Structures. See Section 3.2 of the text.

Linked Structures. See Section 3.2 of the text. Linked Structures See Section 3.2 of the text. First, notice that Java allows classes to be recursive, in the sense that a class can have an element which is itself an object of that class: class Person

More information

21# 33# 90# 91# 34# # 39# # # 31# 98# 0# 1# 2# 3# 4# 5# 6# 7# 8# 9# 10# #

21# 33# 90# 91# 34# # 39# # # 31# 98# 0# 1# 2# 3# 4# 5# 6# 7# 8# 9# 10# # 1. Prove that n log n n is Ω(n). York University EECS 11Z Winter 1 Problem Set 3 Instructor: James Elder Solutions log n n. Thus n log n n n n n log n n Ω(n).. Show that n is Ω (n log n). We seek a c >,

More information

Most of this PDF is editable. You can either type your answers in the red boxes/lines, or you can write them neatly by hand.

Most of this PDF is editable. You can either type your answers in the red boxes/lines, or you can write them neatly by hand. 15-122 : Principles of Imperative Computation, Spring 2016 Written Homework 7 Due: Monday 7 th March, 2016 Name:q1 Andrew ID: q2 Section:q3 This written homework covers amortized analysis and hash tables.

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

Postfix (and prefix) notation

Postfix (and prefix) notation Postfix (and prefix) notation Also called reverse Polish reversed form of notation devised by mathematician named Jan Łukasiewicz (so really lü-kä-sha-vech notation) Infix notation is: operand operator

More information

Stack. 4. In Stack all Operations such as Insertion and Deletion are permitted at only one end. Size of the Stack 6. Maximum Value of Stack Top 5

Stack. 4. In Stack all Operations such as Insertion and Deletion are permitted at only one end. Size of the Stack 6. Maximum Value of Stack Top 5 What is Stack? Stack 1. Stack is LIFO Structure [ Last in First Out ] 2. Stack is Ordered List of Elements of Same Type. 3. Stack is Linear List 4. In Stack all Operations such as Insertion and Deletion

More information

CS171 Midterm Exam. October 29, Name:

CS171 Midterm Exam. October 29, Name: CS171 Midterm Exam October 29, 2012 Name: You are to honor the Emory Honor Code. This is a closed-book and closed-notes exam. You have 50 minutes to complete this exam. Read each problem carefully, and

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

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

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

CS 206 Introduction to Computer Science II

CS 206 Introduction to Computer Science II CS 206 Introduction to Computer Science II 03 / 31 / 2017 Instructor: Michael Eckmann Today s Topics Questions? Comments? finish RadixSort implementation some applications of stack Priority Queues Michael

More information

CS61BL. Lecture 3: Asymptotic Analysis Trees & Tree Traversals Stacks and Queues Binary Search Trees (and other trees)

CS61BL. Lecture 3: Asymptotic Analysis Trees & Tree Traversals Stacks and Queues Binary Search Trees (and other trees) CS61BL Lecture 3: Asymptotic Analysis Trees & Tree Traversals Stacks and Queues Binary Search Trees (and other trees) Program Efficiency How much memory a program uses Memory is cheap How much time a

More information

Module 3: Hashing Lecture 9: Static and Dynamic Hashing. The Lecture Contains: Static hashing. Hashing. Dynamic hashing. Extendible hashing.

Module 3: Hashing Lecture 9: Static and Dynamic Hashing. The Lecture Contains: Static hashing. Hashing. Dynamic hashing. Extendible hashing. The Lecture Contains: Hashing Dynamic hashing Extendible hashing Insertion file:///c /Documents%20and%20Settings/iitkrana1/My%20Documents/Google%20Talk%20Received%20Files/ist_data/lecture9/9_1.htm[6/14/2012

More information

Assume you are given a Simple Linked List (i.e. not a doubly linked list) containing an even number of elements. For example L = [A B C D E F].

Assume you are given a Simple Linked List (i.e. not a doubly linked list) containing an even number of elements. For example L = [A B C D E F]. Question Assume you are given a Simple Linked List (i.e. not a doubly linked list) containing an even number of elements. For example L = [A B C D E F]. a) Draw the linked node structure of L, including

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

CS350 - Exam 1 (100 Points)

CS350 - Exam 1 (100 Points) Spring 2013 Name CS350 - Exam 1 (100 Points) 1.(25 points) Stacks and Queues (a) (5) For the values 4, 8, 2, 5, 7, 3, 9 in that order, give a sequence of push() and pop() operations that produce the following

More information

Data Structure Advanced

Data Structure Advanced Data Structure Advanced 1. Is it possible to find a loop in a Linked list? a. Possilbe at O(n) b. Not possible c. Possible at O(n^2) only d. Depends on the position of loop Solution: a. Possible at O(n)

More information

Lecture 4 Stack and Queue

Lecture 4 Stack and Queue Lecture 4 Stack and Queue Bo Tang @ SUSTech, Spring 2018 Our Roadmap Stack Queue Stack vs. Queue 2 Stack A stack is a sequence in which: Items can be added and removed only at one end (the top) You can

More information

Name CPTR246 Spring '17 (100 total points) Exam 3

Name CPTR246 Spring '17 (100 total points) Exam 3 Name CPTR246 Spring '17 (100 total points) Exam 3 1. Linked Lists Consider the following linked list of integers (sorted from lowest to highest) and the changes described. Make the necessary changes in

More information

Abstract Data Type: Stack

Abstract Data Type: Stack Abstract Data Type: Stack Stack operations may involve initializing the stack, using it and then de-initializing it. Apart from these basic stuffs, a stack is used for the following two primary operations

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

Hash Table. A hash function h maps keys of a given type into integers in a fixed interval [0,m-1]

Hash Table. A hash function h maps keys of a given type into integers in a fixed interval [0,m-1] Exercise # 8- Hash Tables 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

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

CPSC 221: Algorithms and Data Structures ADTs, Stacks, and Queues

CPSC 221: Algorithms and Data Structures ADTs, Stacks, and Queues CPSC 221: Algorithms and Data Structures ADTs, Stacks, and Queues Alan J. Hu (Slides borrowed from Steve Wolfman) Be sure to check course webpage! http://www.ugrad.cs.ubc.ca/~cs221 1 Lab 1 available very

More information

CP2 Revision. theme: dynamic datatypes & data structures

CP2 Revision. theme: dynamic datatypes & data structures CP2 Revision theme: dynamic datatypes & data structures structs can hold any combination of datatypes handled as single entity struct { }; ;

More information

Algorithms and Data Structures

Algorithms and Data Structures Algorithms and Data Structures PD Dr. rer. nat. habil. Ralf Peter Mundani Computation in Engineering / BGU Scientific Computing in Computer Science / INF Summer Term 2018 Part 2: Data Structures PD Dr.

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

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

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

Sample Question Paper

Sample Question Paper Scheme - I Sample Question Paper Marks : 70 Time: 3 Hrs. Q.1) Attempt any FIVE of the following. 10 Marks a. Write any four applications of data structure. b. Sketch the diagram of circular queue. c. State

More information

Section 05: Solutions

Section 05: Solutions Section 05: Solutions 1. Memory and B-Tree (a) Based on your understanding of how computers access and store memory, why might it be faster to access all the elements of an array-based queue than to access

More information

Announcements. CS18000: Problem Solving And Object-Oriented Programming

Announcements. CS18000: Problem Solving And Object-Oriented Programming Announcements Exam 1 Monday, February 28 Wetherill 200, 4:30pm-5:20pm Coverage: Through Week 6 Project 2 is a good study mechanism Final Exam Tuesday, May 3, 3:20pm-5:20pm, PHYS 112 If you have three or

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 18 EXAMINATION Subject Name: Data Structure Model wer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in

More information

Hashed-Based Indexing

Hashed-Based Indexing Topics Hashed-Based Indexing Linda Wu Static hashing Dynamic hashing Extendible Hashing Linear Hashing (CMPT 54 4-) Chapter CMPT 54 4- Static Hashing An index consists of buckets 0 ~ N-1 A bucket consists

More information

LECTURE 11 TREE TRAVERSALS

LECTURE 11 TREE TRAVERSALS DATA STRUCTURES AND ALGORITHMS LECTURE 11 TREE TRAVERSALS IMRAN IHSAN ASSISTANT PROFESSOR AIR UNIVERSITY, ISLAMABAD BACKGROUND All the objects stored in an array or linked list can be accessed sequentially

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

Congestion Control in TCP

Congestion Control in TCP Congestion Control in TCP Antonio Carzaniga Faculty of Informatics Università della Svizzera italiana November 22, 2017 Outline Intro to congestion control Input rate vs. output throughput Congestion window

More information

GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER ENGINEERING (07) / INFORMATION TECHNOLOGY (16) / INFORMATION & COMMUNICATION TECHNOLOGY (32) DATA STRUCTURES

GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER ENGINEERING (07) / INFORMATION TECHNOLOGY (16) / INFORMATION & COMMUNICATION TECHNOLOGY (32) DATA STRUCTURES GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER ENGINEERING () / INFMATION TECHNOLOGY (6) / INFMATION & COMMUNICATION TECHNOLOGY (32) DATA STRUCTURES Type of course: Compulsory SUBJECT CODE: 2302 B.E. 3 rd Semester

More information

Department of Computer Science and Technology

Department of Computer Science and Technology UNIT : Stack & Queue Short Questions 1 1 1 1 1 1 1 1 20) 2 What is the difference between Data and Information? Define Data, Information, and Data Structure. List the primitive data structure. List the

More information

Trees. Courtesy to Goodrich, Tamassia and Olga Veksler

Trees. Courtesy to Goodrich, Tamassia and Olga Veksler Lecture 12: BT Trees Courtesy to Goodrich, Tamassia and Olga Veksler Instructor: Yuzhen Xie Outline B-tree Special case of multiway search trees used when data must be stored on the disk, i.e. too large

More information

Introduction to Data Structures and Algorithms

Introduction to Data Structures and Algorithms Introduction to Data Structures and Algorithms Data Structure is a way of collecting and organising data in such a way that we can perform operations on these data in an effective way. Data Structures

More information

Access Methods. Basic Concepts. Index Evaluation Metrics. search key pointer. record. value. Value

Access Methods. Basic Concepts. Index Evaluation Metrics. search key pointer. record. value. Value Access Methods This is a modified version of Prof. Hector Garcia Molina s slides. All copy rights belong to the original author. Basic Concepts search key pointer Value record? value Search Key - set of

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

DDS Dynamic Search Trees

DDS Dynamic Search Trees DDS Dynamic Search Trees 1 Data structures l A data structure models some abstract object. It implements a number of operations on this object, which usually can be classified into l creation and deletion

More information

Problem One: Loops and ASCII Graphics

Problem One: Loops and ASCII Graphics Problem One: Loops and ASCII Graphics Write a program that prompts the user for a number between 1 and 9, inclusive, then prints a square of text to the console that looks like this: 1**** 22*** 333**

More information