dynamic programming using histomorphisms
play

Dynamic programming using histomorphisms Jevgeni Kabanov Viinistu, - PowerPoint PPT Presentation

Dynamic programming using histomorphisms Jevgeni Kabanov Viinistu, 2005 Catamorphism (fold) Structural recursion combinator Generic foldr (Haskell) Eats (folds) trees from bottom-up, producing combined result Similar to Visitor


  1. Dynamic programming using histomorphisms Jevgeni Kabanov Viinistu, 2005

  2. Catamorphism (fold) • Structural recursion combinator • Generic foldr (Haskell) • Eats (folds) trees from bottom-up, producing combined result • Similar to Visitor pattern in OOP, but doesn’t update structures

  3. Sum fold animation ���� ���� � � � � � � � � � � ���� ���� � ���� ���� � � � � � � � � � � � � � � � � � � ���� ���� ���� ���� ���� ���� � ���� ���� � � � � � � 1 5 3 7 Let’s count this tree sum...

  4. Sum fold animation ���� ���� � � � � � � � � � � ���� ���� � ���� ���� � � � � � � � � � � � � � � � � � � ���� ���� ���� ���� � ���� ���� � � � � � � 1 5 3 7

  5. Sum fold animation ���� ���� � � � � � � � � � � ���� ���� � ���� ���� � � � � � � � � � � � � � � � � � � ���� ���� ���� ���� ���� ���� ���� ���� � ���� ���� � � � � � � 1 5 3 7

  6. Sum fold animation ���� ���� � � � � � � � � � � ���� ���� � ���� ���� � � � � � � � � � � � � � � � � � � ���� ���� ���� ���� ���� ���� � ���� ���� � � � � � � 1 5 3 7

  7. Sum fold animation ���� ���� � � � � � � � � � � ���� ���� � ���� ���� � � � � � � � � � � � � � � � � � � ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� � ���� ���� � � � � � � 1 5 3 7

  8. � � Sum fold animation ���� ���� � � � � � � � � � � � ���� ���� � � � � � � � � � � � � � � � � � � ���� ���� ���� ���� � � � � � � �

  9. Sum fold animation ���� ���� � � � � � � � � � � � ���� ���� ���� ���� � ���� ���� � � � � � � 6 � � � � � � � � ���� ���� ���� ���� � � 3 7

  10. Sum fold animation ���� ���� � � � � � � � � � � � ���� ���� ���� ���� � ���� ���� � � � � � � 6 � � � � � � � � ���� ���� � � 3 7

  11. Sum fold animation ���� ���� � � � � � � � � � � � ���� ���� ���� ���� � ���� ���� � � � � � � 6 � � � � � � � � ���� ���� ���� ���� ���� ���� � � 3 7

  12. Sum fold animation ���� ���� � � � � � � � � � � � ���� ���� ���� ���� � ���� ���� � � � � � � 6 � � � � � � � � ���� ���� ���� ���� � � 3 7

  13. Sum fold animation ���� ���� � � � � � � � � � � � ���� ���� ���� ���� � ���� ���� � � � � � � 6 � � � � � � � � ���� ���� ���� ���� ���� ���� ���� ���� � � 3 7

  14. � � Sum fold animation ���� ���� � � � � � � � � � � � ���� ���� ���� ���� � � � � � � � 6 � � � � � � � � ���� ���� ���� ���� � �

  15. Sum fold animation ���� ���� � � � � � � � � � � � � ���� ���� ���� ���� � ���� ���� ���� ���� � � � � � 6 10

  16. � � Sum fold animation � � � � � � � � � � � � ���� ���� ���� ���� � � � � � �

  17. Sum fold animation ���� ���� ���� ���� 16 And the result is 16 = 1 + 5 + 3 + 7

  18. Histomorphism • Introduced by Varmo & Tarmo in 1999 • Course-of-value structural recursion combinator • Inspired by dynamic programming technique • Moves bottom-up annotating the tree with results • Allows to reuse sub(-sub)* node results • Finally collapses the tree producing the end result

  19. Funny sum histo animation ���� ���� � � � � � � � � � � ���� ���� � ���� ���� � � � � � � � � � � � � � � � � � � ���� ���� ���� ���� ���� ���� � ���� ���� � � � � � � 1 5 3 7 Let’s count this tree (funny) sum...

  20. Funny sum histo animation ���� ���� � � � � � � � � � � ���� ���� � ���� ���� � � � � � � � � � � � � � � � � � � ���� ���� ���� ���� � ���� ���� � � � � � � 1 5 3 7

  21. Funny sum histo animation ���� ���� � � � � � � � � � � ���� ���� � ���� ���� � � � � � � � � � � � � � � � � � � ���� ���� ���� ���� ���� ���� ���� ���� � ���� ���� � � � � � � 1 5 3 7

  22. Funny sum histo animation ���� ���� � � � � � � � � � � ���� ���� � ���� ���� � � � � � � � � � � � � � � � � � � ���� ���� ���� ���� ���� ���� � ���� ���� � � � � � � 1 5 3 7

  23. Funny sum histo animation ���� ���� � � � � � � � � � � ���� ���� � ���� ���� � � � � � � � � � � � � � � � � � � ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� � ���� ���� � � � � � � 1 5 3 7

  24. � � Funny sum histo animation ���� ���� � � � � � � � � � � � ���� ���� � � � � � � � � � � � � � � � � � � ���� ���� ���� ���� � � � � � � �

  25. Funny sum histo animation ���� ���� � � � � � � � � � � � ���� ���� ���� ���� � ���� ���� � � � � � � 6 � � � � � � � � � � � � � � ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� � � � � � 1 5 3 7

  26. Funny sum histo animation ���� ���� � � � � � � � � � � � ���� ���� ���� ���� � ���� ���� � � � � � � 6 � � � � � � � � � � � � � � ���� ���� ���� ���� ���� ���� ���� ���� ���� ���� � � � � � 1 5 3 7

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend