Skip to content

SaPhyoThuHtet/algos-and-data-structure

Repository files navigation

algos-and-data-structure

Algorithms and Data Structure

If you are the beginner to data structure and algorithms, I recommend the following videos from Free Code Camp.

  1. Algorithms and Data Structures Tutorial - Full Course for Beginners: https://youtu.be/8hly31xKli0
  2. Data Structures Easy to Advanced Course - Full Tutorial from a Google Engineer: https://youtu.be/RBSGKlAvoiM And you must know about Big O Notation.
  3. Big O Notation: https://youtu.be/Mo4vesaut8g

First Part

  1. array Time and Space Complexity of Array:
    Traversing
    Traversing Array: Time Complexity O(n), Space Complexity O(1)
    Insertion
    Inserting the element to the first position of the Arrray: Time Complexity O(n)
    Inserting the element to the last position of the arry: Time Complexity O(n) if the array is static O(1) if the array is dynamic,
    Inserting the element (not first and last): Time Complexity O(n)
    Deletion
    Deleting the first element from an array: Time Complexity O(n)
    Deleting the last element from an array: Time Complexity O(1)
    Deleting an element in the middle of the array: Time Complexity O(n)
    Copying
    Copying array: Time Complexity O(n) Space Complexity O(n)
    Accessing
    Accessing an element at a given index: Time Complexity O(1) Space Complexity O(1)
    Updating Updating and element at a given index: Time Complexity O(1)

  2. matrix

  3. string Time and Space Complexity of Array:
    Traversing
    Traversing String: Time Complexity O(n), Space Complexity O(1)
    Copying
    Copying string: Time Complexity O(n) Space Complexity O(n)
    Accessing
    Accessing an element at a given index: Time Complexity O(1) Space Complexity O(1)

    Time Complexity of O(nm) n is the number of words, m is the the max length of the words Space Complexity also O(nm) if there can be any length of the word, it would be more accurate if we contains m words = ["cat", "dog", "cow"] ans = [] for i in words: reveresed_word = i[::-1] ans.append(i)

  4. linked-list

  5. tree Tree is a type of graph. Common Types of Trees: Binary Tree and Binary Search Tree, Min Heap, Max Heap, Tries

  6. graph Vertices are values and edges are connection.

Second Part

  1. sliding window
  2. bit manipulation
  3. stack/ queue
  4. dictionary
  5. recursion and dynamic programming.

Some Patterns

  1. Tree (Use Stack or Queue or recursive)
  2. Zero Sum ()

Other Notes

Time Complexity of finding the length of array or string in Python is O(1) not O(n).

Time complexity of copying a string is O(n**2) not O(n). (Generally, but can be different based on the programming language)

To Start With

  1. Two Sum
  2. Binary Search
  3. Move Zeros
  4. Remove Elements

About

Algorithms and Data Structure for Coding Interviews

Resources

License

Stars

Watchers

Forks

Languages