1 / 62

Data Structures

Data Structures. Amazing but less known world of. Surender Baswana Visiting Professor till 31 st May 2020 Heinz Nixdorf Institute & Department of Computer Science (Algorithms and Complexity Group) sbaswana@campus.uni-paderborn.de sbaswana@gmail.com. Data Structures.

carlberry
Download Presentation

Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Structures Amazing but less known world of SurenderBaswana Visiting Professor till 31st May 2020 Heinz Nixdorf Institute & Department of Computer Science(Algorithms and Complexity Group) sbaswana@campus.uni-paderborn.de sbaswana@gmail.com

  2. Data Structures Aim: How to organize data compactly so that each operation is executed efficiently.

  3. Data Structures Phone number of Mr. XYZ ? Lexicographically sorted Binary search

  4. Data structures in courses/books (log ) () Fibonaacci heap Maximum Flow Algorithm

  5. > > > Library for Efficient Data Structures and Algorithms

  6. Data structures in courses/books Trivial Shallow Complex Impractical Theoretically less significant Fibonaacci heap Maximum Flow Algorithm

  7. Data structures • Simple and elegant • Not so difficult to code • Theoretically significant Magical

  8. Organization of the Talk Depth and elegance Range-Minima Dynamic Sequence Dynamic Tree – 1 Dynamic Tree - 2

  9. Part I Range Minima

  10. Range-Minima Given an array A storing numbers, design a data structure to answer a sequence of queries: Range-minima() : report the smallest element from A[],…,A[] () (log ) Space Range-Minima() = -6 () Query time 3 5 1 8 19 0 -1 30 99 -6 10 2 40 27 44 67 A =4 =11

  11. Key idea Tiny data structures A

  12. Details of tiny data structure stored at each 8 4 2 1 A Tiny data structure of Index stores minimum element for {A[],…,A[+ ]} for each ≤

  13. How does Collaboration work ? A

  14. Homework • Preprocessing time : • C code for Range-minima(): Hint: Use auxiliary arrays of size () (log ) lines

  15. Part II Dynamic Sequence

  16. Dynamic Sequences • Report() • Multi-Add() Multi-Add() Report()

  17. Dynamic Sequences Key Idea • Report() • Multi-Add() • Rotate() Binary Search Trees Perform Implicitly () Space () Time per operation (log ) Rotate()

  18. Binary Search Trees

  19. How much do we know about Balanced BST ? The elements with rank in the range [,] : LCA T

  20. How much do we know about Balanced BST ? The elements with rank in the range [,] : LCA T

  21. How much do we know about Balanced BST ? The elements with rank in the range [,] : LCA T

  22. How much do we know about Balanced BST ? (log ) ancestors The elements with rank in the range [,] : (log ) subtrees LCA T

  23. How much do we know about Balanced BST ? (log ) Split(T,x) < < x Merge(T1,x,T2) T2 T1 T

  24. Balanced Binary Tree : Additional information

  25. Dynamic Sequences • Report() • Multi-Add() • Rotate() 0 9 size 5 0 3 0 add 3 0 1 1 0 0 1 0 0 1 1 0 Report()

  26. Dynamic Sequences • Report() • Multi-Add() • Rotate() 0 9 size 5 0 3 0 add 3 0 1 1 0 0 1 0 0 1 1 0 Multi-Add()

  27. Dynamic Sequences • Report() • Multi-Add() • Rotate() 0 9 size 5 0 3 0 add 3 0 1 1 0 0 1 0 0 1 1 0 Multi-Add()

  28. Dynamic Sequences • Report() • Multi-Add() • Rotate() 0 9 size 5 0 3 0 add 3 0 1 1 0 0 1 0 0 1 1 0 Multi-Add()

  29. Dynamic Sequences • Report() • Multi-Add() • Rotate() 0 9 size 5 0 3 0 add 3 0 1 1 0 0 1 0 0 1 1 0 Multi-Add()

  30. Dynamic Sequences • Report() • Multi-Add() • Rotate() 0 9 size 5 0 3 2 add flip 3 1 2 1 0 1 0 0 0 1 1 0 Multi-Add()

  31. Dynamic Sequences • Report() • Multi-Add() • Rotate() 9 0 0 size 5 0 0 0 3 2 add flip 3 1 2 0 0 1 0 0 1 0 0 0 0 0 1 0 0 1 Rotate()

  32. Homework • Details of Rotate() Hint: Use Split and Merge of BST. • Implement one more operation: ReportMin()

  33. dynamic trees

  34. Dynamic Trees j g a b f e c d u u v w

  35. Dynamic Trees Aim : Maintain a forest of trees on vertices under the following operations. • Link() : Add an edge between and • Cut() :Delete an edge between and • Information :associated with nodes/edges • Query : • Related to path • Related to entire tree • Topological

  36. Part III Dynamic tree Sleator-TarjanTree with operations on paths

  37. S-Ttreesquery and updates onpaths Operations : Link() Cut() Add-weight-to-path(,): add to weight of each edge on the path between and . ReportMin-wt-on-path() : report min weight edge on the path between and . j g a b 5 17 13 2 41 c e f 7 23 37 d u +10 12 67 32 u v w Time per operation (log ) () ReportMin-wt-edge(a,g) changes ....

  38. Key Idea A tough problem Dynamic trees Generalize ? A simpler instance Dynamic paths

  39. Dynamic paths • Operations : • Link() • Cut() • Add-weight-to-path(,): add to weight of each edge on the path between and . • ReportMin-wt-on-path() : report min weight edge on the path between and . tail head

  40. Data structure for dynamic paths Each operation in O(log )worst case time. (g,h) (d,e) (b,c) (f,g) (e,f) (a,b) (c,d) Similar to Dynamic Sequence a b c d e f g h e c d h a b f g

  41. A decomposition of tree into paths ?

  42. Heavy path decomposition of tree

  43. Heavy path decomposition of tree

  44. Heavy path decomposition of tree

  45. Heavy path decomposition of tree

  46. ST trees • Maintain each tree as a collection of disjoint paths such that each path in a tree is a collection of O(log ) disjoint paths. • Maintain an augmented binary tree data structure for each path. • O() query time O(log ) using weight balanced binary trees.

  47. Homework • How to compute heavy path decomposition of a tree ? • **How to implement Link() efficiently ? Hints: • Updating the heavy path decomposition efficiently. • Need efficient way to change the root. O()

  48. Part IV Dynamic tree Euler-Tour Tree with operations on subtree

  49. ET Treesquery and updates on trees j g a b 17 2 3 5 Operations : Link(u,v) Cut(u,v) Update-node-weight(v,a): weight(v)  a Add-weight-to-tree(v, Δ): add Δ to weight of each node of tree containing v. ReportMin(u) : report min weight in the entire tree containing u. 41 f e 7 32 c d -3 12 u 44 15 67 u v w

  50. ET Treesquery and updates on trees ReportMin(v) = 12 j g a b 17 2 3 5 Operations : Link(u,v) Cut(u,v) Update-node-weight(v,a): weight(v)  a Add-weight-to-tree(v, Δ): add Δ to weight of each node of tree containing v. ReportMin(u): report min weight in the entire tree containing u 41 f e 7 32 c d -3 12 u 44 15 67 u v w

More Related