Algorithms and Their Habitat

Algorithms and Their Habitat

Algorithms are mysterious beasts that hard to catch in the source code. However, well-chosen data structures and efficient algorithms applied to a web app is key to performance. I want to show how to fit the knowledge you got at the university can solve your daily routines.


Vitalii Bobrov

April 08, 2019


  1. Algorithms and Their Habitat

  2. Vitalii Bobrov Lead JS Engineer @AngularWroclaw organizer ngGirls mentor @bobrov1989
  3. Algorithms

  4. unambiguous specification of how to solve a class of problems

  5. Why should I care?!

  6. They are EVERYWHERE

  7. Maintain your library to find the way

  8. Complexity

  9. understand how application will scale

  10. Big O

  11. None
  12. None
  13. TIME and SPACE Complexity estimate resources highlight bottlenecks force to

    find better solution
  14. Data Normalization

  15. WHEN? related state entities recursive state entities fast entity lookup

  16. Data with Relations

  17. Recursive Data

  18. WHY? get entity by id get entities by related id

    reduce memory footprint
  19. Data with relations - get entity O(n) O(n*m)

  20. Recursive data - get entity memory O(n) time O(n)

  21. None
  22. Normalized data

  23. Normalized data - get entity O(1) O(1) O(n*m)

  24. prepare index to get entities faster

  25. Normalized data - index

  26. Normalized data - get entity O(n)

  27. HOW? do it yourself use library normalizr @ngrx/entity

  28. Memoization

  29. WHEN? data selection repeated computations derived data

  30. Fibonacci numbers

  31. Call tree

  32. WHY? reduce expensive calls frequently used data reduce callstack

  33. Memoized

  34. HOW? do it yourself use library reselect mem

  35. Levenshtein Distance

  36. calculates how many edits required to get one string from

  37. Distance matrix

  38. None
  39. WHEN? auto-correction auto-completion smart suggestions

  40. None
  41. None
  42. use Levenshtein distance for smart 404 page

  43. HOW? get the list of available routes sort

    routes by Levenshtein
 distance to a user input suggest route with the smallest distance
  44. Get all available routes

  45. Sort by Levenshtein distance

  46. Suggest route

  47. None
  48. Create non-standard use-case

  49. @bobrov1989