[DSA] Overview: Complexity Analysis

  • Data Structure
    How to manipulate data?
    Data structure is a way to manipulate, organize data for different applications.
    Like we retrieve data through front-end, getting data from database, and see how to present them in the interactive interface (GUI/CLI).

  • Complexity (Space-Time Complexity)
    During coding interview, you may be asked if there is a better solution?
    A better solution, we need to consider Space-Time Complexity.

  1. Space Complexity
    A measure of how much auxiliary memory an algorithm takes up, space complexity is a central concept in the field of algorithms and in coding interviews.
    In Space Complexity, we care about the memory/storage used. The less memory used, the better space complexity we get.
    It's expressed using Big O notation.

  2. Time Complexity
    A measure of how fast an algorithm runs, time complexity is a central concept in the field of algorithms and in coding interviews.
    In Time Complexity, we care about the Time of the algorithm takes.
    The less time it spends, the better Time Complexity we get.
    It's expressed using Big O notation

  • Caution
    Each algorithms have different Space-Time Complexity, we cannot both get the best Space Complexity and Time Complexity at the same time.
    Thus, when solving different problems, we have to consider Space-Time Complexity before choosing the data structure to tackle.

  • Time Complexity

  1. The actual act of inserting the node in Linked Lists is Constant Time and Constant Space O(1)

<<:  [Shell] Common Shells: sh, csh, tcsh, ash, bash

>>:  [Day08] 什麽是贪婪法

[影片]第27天:英雄指南-5. 新增应用内导航(2)

GitHub:https://github.com/dannypc1628/Angular-Tou...

Day 11:将你的 Hexo 部落格部属到 Github Pages

我相今天的篇章是大家期待已久的,因为经过前面十天的努力,今天终於要将我们的部落格公开在世人面前啦!不...

Day 5. Hashicorp Nomad: How to configure one service advertise multiple ports

Hashicorp Nomad: How to configure one service adve...

30天程序语言研究

今天是30天程序语言研究的第二十六天,由於最近写unix语言的东西用到很多,所以做了很多笔记,就想说...

【C++】Binary Search Tree

Binary Search Tree的优势在於寻找、插入的时间复杂度较低,它只需要O(log n)~...