Misc
Misc
Topics
Time Complexity
Time Complexity != Time taken
Time complexity is a function that gives us the relationship about how the processing time will grow as the input grows
- Procedure for analysing complexity
- Look for worst case complexity
- Look at complexity for large/infinte data
- Ignore the constants
- Ignore less dominating terms
- Notations
- Big Oh: Upper bound
- Big Omega: Lower bound
- Theta: When both upper and lower bounds are same
Bitwise Operators
- Operators
- AND
|a|b|a&b|
|-|-|–|
|0|0|0|
|0|1|0|
|1|0|0|
|1|1|1|
When you &1 with any number, digits remain same
- OR |a|b|ab| |-|-|–| |0|0|0| |0|1|1| |1|0|1| |1|1|1|
- XOR (^)
|a|b|a^b|
|-|-|–|
|0|0|0|
|0|1|1|
|1|0|1|
|1|1|0|
When you ^1 any number, it’s reverse: 1^1 = 0
When you ^0 any number, it’s same: a^0 = a
When you ^a any number, it’s 0: a^a = 0 - Complement (~)
- Left Shift («): Shifts the bits one left
10 = (1010) becomes (10100) = 20
Doubles the number, a « 1 = 2a
Generalized as, a « b= a*2^b - Right Shift (»): Shift the bits one right
001101 becomes 001100
Halves the number, a » b = a/(2^b)
- AND
|a|b|a&b|
|-|-|–|
|0|0|0|
|0|1|0|
|1|0|0|
|1|1|1|
- Questions
- Check if number is prime? If last bit is 0 -> even, 1 -> odd As, 1&1=1, hence n&1 == 1 -> odd else even
Misc
Gradle
Gradle is a build tool that we use for Android development to automate the process of building and publishing apps.
- When we click on Run button, it exceutes multiple built-in tasks like:
- reads app’s build configuration file (build.gradle)
- downloads and resolves the app’s dependencies
- compiles the apps code, including converting java and kotlin files into bytecode
- packs the compiled code and resources into an APK
- installs the APK file on the device and runs the app
DSL
: Gradle comes with lot of built-in functionalities, but we can write our own logic too using DSL (domain specific language), which is tailored to build automation domain based on Groovy or Kotlin.
Git
- Git Commands
git init
: initialize a empty gitgit status
: shows all the changed filesgit add .
: add all the files/changed filesgit commit -m "message"
: commit the changes with message
Heroku
- Heroku CLI Commands
heroku login
heroku create
: create a new appgit add .
->git commit -m "message"
->git push heroku master
: deploy the latest codeheroku open
: open the appheroku logs
–tail : get logs