Skip to content

Instantly share code, notes, and snippets.

View anyone21's full-sized avatar

annoying_code anyone21

  • Jaipur,India
View GitHub Profile
@anyone21
anyone21 / table.md
Last active October 26, 2021 10:18
@anyone21
anyone21 / File.md
Created August 30, 2021 17:40
Time complexity in python

Prerequisite knowledge required

  1. Popping the intermediate element at index k from a list of size n shifts all elements after k by one slot to the left using memmove. n - k elements have to be moved, so the operation is O(n - k). The best case is popping the second to last element, which necessitates one move, the worst case is popping the first element, which involves n - 1 moves. The average case for an average value of k is popping the element the middle of the list, which takes O(n/2) = O(n) operations. Since we are popping first element of the list of we have 1 pop() operation = O(n) time.
  2. Lists in Python are analysed using "(Amortized analysis)[https://en.wikipedia.org/wiki/Amortized_analysis]". This is similar to dynamic arrays. Here how dynamic array works
 ---
|   |   ----> new_list = []

Prerequisite knowledge required

  1. Popping the intermediate element at index k from a list of size n shifts all elements after k by one slot to the left using memmove. n - k elements have to be moved, so the operation is O(n - k). The best case is popping the second to last element, which necessitates one move, the worst case is popping the first element, which involves n - 1 moves. The average case for an average value of k is popping the element the middle of the list, which takes O(n/2) = O(n) operations. Since we are popping first element of the list of we have 1 pop() operation = O(n) time.
  2. Lists in Python are analysed using "(Amortized analysis)[https://en.wikipedia.org/wiki/Amortized_analysis]". This is similar to dynamic arrays. Here how dynamic array works
 ---
|   |   ----> new_list = []
### Prerequisite knowledge required
1. Popping the intermediate element at index k from a list of size n shifts all elements after k by one slot to the left using memmove. n - k elements have to be moved,
so the operation is O(n - k). The best case is popping the second to last element, which necessitates one move, the worst case is popping the first element, which involves
n - 1 moves. The average case for an average value of k is popping the element the middle of the list, which takes O(n/2) = O(n) operations. Since we are popping first element
of the list of we have **1 pop() operation = O(n) time**.
2. Lists in Python are analysed using "(Amortized analysis)[https://en.wikipedia.org/wiki/Amortized_analysis]". This is similar to dynamic arrays. Here how dynamic array works
```python
---
| | ----> new_list = []
@anyone21
anyone21 / bash-cheatsheet.sh
Created July 14, 2021 19:05 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04