https://github.com/sibteali786/dsa-python
Data Structure and Algorithm practice questions and exercises from CodeBasics.
https://github.com/sibteali786/dsa-python
Last synced: 3 months ago
JSON representation
Data Structure and Algorithm practice questions and exercises from CodeBasics.
- Host: GitHub
- URL: https://github.com/sibteali786/dsa-python
- Owner: sibteali786
- Created: 2022-10-24T02:19:33.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-02-21T05:47:25.000Z (over 2 years ago)
- Last Synced: 2025-01-08T22:39:12.819Z (5 months ago)
- Language: Jupyter Notebook
- Size: 146 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DSA-Python ( Credits [CodeBasics](https://youtu.be/gDqQf4Ekr2A))
Data Structure and Algorithm practice questions and exercises from CodeBasics.# Data Structures and Algorithms from Codebasics Channel
## Arrays
2. Array elements are saved at a particular index inside the it.
a. These indexes are nothing but specific places in memory represented by addresses as shown. Each box is of 4 bytes or 32 bit .
b. Where 4 bytes is capacity of integer in many programming languages.

d. So in reality 298 a number is stored in this manner as shown.
### Scenario No 1
a. If 298 is our first value at index zero ( 0 ) then to get the value 320, we add the index value 2 after its product with sizeOf(Integer) which is 4 bytes .
b. And finally getting the address.### Scenario 2

a. The time complexity in this case is very simple as we can see here, because if we are finding we will take n no iterations to get to that value thus O(n) is time complexity.
### Scenario 3

a. Again we have to take n iterations
### Scenario 4

a. We are giving index value and value itself. The time complexity is when it has to swap values by one step for each thus take n steps for swapping values.### Scenario 5
a. Similar case as above example.
### Static vs Dynamic Arrays


a. In case of static array, we may get error if put value at index greater than the array's size.
b. While in dynamic arrays no such thing happens.

a. In dynamic arrays some memory is pre-allocated in continuous memory with specific amount.
b. Dark gray are boxes already allotted.c. After we have inserted 10 elements what now ? And wanna put 11th element

d. Our program assign new memory space ( 10 + 10 * 2 for instance ) at some new place and move previous values and does this every time allocated memory runs out which is overhead obviously.
### Python Dynamic Behaviour

Python infers data type on runtime and thus we can put any kind of data in it as shown here.
Can also have a multi-dimensional array.