DSA : Day 1

DSA : Day 1

Happy Learning! Happy Programming!


Topics

1?? Decimal to Binary, Binary to Decimal

??Binary of -ve numbers ? Sign Magnitude vs 2s Complement

2?? Data Types

??Primitive Data Types

??Data Types: Space and Range [VVI for solving problems (reflect CONSTRAINTS)]

??Signed vs Unsigned

3?? Errors

??Compile Time Error

??Runtime Error

??Time Limit Exceeded Error

??Wrong Answer

4?? Operators

??Arithmetic: +, -, *, /, %

??Logical: &&, ||, !

??Relational: <, >, <=, >=, ==, !=

??Bitwise: amp;, |, ^, ~, <<, >>

??Assignment: =, +=, -=, ...

??Unary: +, -, ++, --

??Miscellaneous Operators: ???: : Ternary (conditional) operator??, : Comma operator??: Size of an object??. : Member access operator (dot)??->; : Member access operator (arrow)??[] : Array subscript??() : Function call


Data Types

??Primitive Data Type

??Sizes & Constraint Ranges

  • int --> 4 B --> (2*10^9)
  • long --> 4/8 B long long --> 8 B --> (9*10^18)
  • float --> 4 B
  • double --> 8 B

??Key Points

  • 'string' is not a primitive data type
  • Data type 'byte' exists only in Java
  • Keywords 'unsigned' and 'long long' in Java, unlike C++.
  • 'long long' in C++ = 'long' in Java.
  • 'long' in C++ can be of 4 or 8 bytes, based on the system architecture. But, takes 8 bytes in Java.
  • By default, all primitive datatypes are 'signed'.
  • Range of signed = (-2^n-1 to 2^n-1 - 1)
  • Range of unsigned = (0 to 2^n - 1) ; where n = #bits
  • 'double' provides more precision than 'float'. Good Practice: Always use double instead of float incase of decimals.


Errors

??Compile Time Error (CTE): Example: Type mismatches, unresolved references.

??Runtime Error (RTE):Example: Division by zero, accessing out-of-bounds array elements.

??Time Limit Exceeded Error (TLE): If there exists some better solution with lesser time complexity.

??Wrong Answer

??Syntax Error: Example: Missing semicolons, unmatched brackets.

要查看或添加评论,请登录

Anushkaa Ambuj的更多文章

  • Why do we 'return 0' at the end of int main()?

    Why do we 'return 0' at the end of int main()?

    #C #C++ #Programming Languages C In C, the int main() or int main(void) function is declared to return an int. Hence…

  • Shebang Line (#!)

    Shebang Line (#!)

    #Python #Bash #JS #NodeJS #Interpretors #Programming Languages What Is a Shebang Line? A shebang () is the first line…

  • Difference between int main() & int main(void)

    Difference between int main() & int main(void)

    #C #C++ #Programming Languages In C: int main(): An empty parameter list in C means the function's parameters are…

  • Why midpoint is calculated as 'low + (high-low)/2' instead of (low+high)/2?

    Why midpoint is calculated as 'low + (high-low)/2' instead of (low+high)/2?

    The formula is often used to calculate the mid-value (or midpoint) between two numbers, and , rather than using the…

  • DSA : Day 2

    DSA : Day 2

    Understanding Problem Constraints and Time Complexity Happy Learning! Happy Programming! Topics 1?? Relation of…

  • SDE Internship @JohnsonControls

    SDE Internship @JohnsonControls

    ??DAY 7: DEVELOPMENT Exploring Angular18 Topics What are Directives? What are Pipes? How to create custom pipe? How to…

    3 条评论
  • SDE Internship @JohnsonControls

    SDE Internship @JohnsonControls

    ??DAY 3: TESTING Manual Testing Terms 3.1 Priority vs Severity (BUGS) 'Severity' = How serious is the defect?…

  • SDE Internship @JohnsonControls

    SDE Internship @JohnsonControls

    ??DAY 6: DEVELOPMENT Tasks Task 1: Setting Up AngularJS on Windows To build a new angular project Step 1: Install…

  • SDE Internship @JohnsonControls

    SDE Internship @JohnsonControls

    ??DAY 5: TESTING [Automation | Selenium] Selenium is a powerful tool for web automation, and one of its core…

  • SDE Internship @JohnsonControls

    SDE Internship @JohnsonControls

    ??DAY 4: TESTING [Automation] 4.1 When does Automation Testing start? Ans- When the build is stable and no frequent…