Skip to content

Rahwik/DSA-IN-CPP

Repository files navigation

Data Structures and Algorithms in C++

Introduction to DSA

Data Structures and Algorithms are fundamental concepts in computer science.

They provide efficient ways to organize and process data, solving problems effectively.

Asymptotic Notations

Big O Notation (O)

Represents an upper bound or exact bound.

O(f(n)) denotes an upper limit on the growth rate of a function.

Theta Notation (Θ)

Represents an exact bound.

Θ(f(n)) denotes a tight bound on the growth rate of a function.

Omega Notation (Ω)

Represents an exact or lower bound.

Ω(f(n)) denotes a lower limit on the growth rate of a function.

Comparison of Notations

Big O is used to describe the upper bound, Theta provides a tight bound, and Omega represents the lower bound.

Direct Ways to Reduce Order of Growth

  • Ignore lower-order terms.
  • Ignore leading constants.

Comparison of Terms

The order of growth from smaller to larger:

c < loglogn < logn < n1/3 < n1/2 < n < n2 < n3 < 2n

Mathematics :

Mathematics is a vast field encompassing various branches, each serving different purposes in problem-solving and understanding the nature of relationships and patterns. Here, we'll touch upon Arithmetic and Geometric Progressions, Quadratic Equations, and basics of Permutation and Combination And Many more in this Section.

Arithmetic Progression (AP) and Geometric Progression (GP):

  • AP (Arithmetic Progression): A sequence where each term is obtained by adding a constant difference to the previous term. For example, 2, 4, 6, 8, ... with a common difference (d) of 2.
  • GP (Geometric Progression): A sequence where each term is obtained by multiplying the previous term by a constant ratio. For example, 2, 4, 8, 16, ... with a common ratio (r) of 2.

Quadratic Equations:

  • A quadratic equation is in the form \(ax^2 + bx + c = 0\).
  • The discriminant (\(D = b^2 - 4ac\)) determines the nature of roots:
    • D < 0: Imaginary roots.
    • D = 0: Two equal real roots.
    • D > 0: Two distinct real roots.
  • The quadratic formula is used to find the roots: \(x = \frac{-b \pm \sqrt{D}}{2a}\).

Permutation and Combination Basics:

  • Permutation (nPr): Arrangement of r items out of n, denoted by \(nPr = \frac{n!}{(n-r)!}\). It represents the number of ways to arrange a subset of items.
  • Combination (nCr): Selection of r items out of n, denoted by \(nCr = \frac{n!}{r!(n-r)!}\). It represents the number of ways to select a subset of items without considering the arrangement.

In summary, these mathematical concepts play crucial roles in various fields, from pure mathematics to applications in physics, engineering, and computer science. They provide tools for analyzing patterns, solving real-world problems, and understanding the fundamental structures underlying diverse phenomena.

Understanding Bitwise Operators

Bitwise operators are used in programming to perform operations at the bit level. They work with the binary representation of numbers.

Types of Bitwise Operators

  • & - AND
  • | - OR
  • ^ - XOR (Exclusive OR)
  • ~ - NOT
  • << - Left Shift
  • >> - Right Shift

Recursion

Recursion is a programming concept where a function calls itself in its own definition. In C++, recursion is a powerful technique that allows a function to solve a problem by breaking it down into smaller instances of the same problem.

Factorial using Recursion, Tail recursion, Sum of Digits, Rope cutting Problem, Generate Subsets, Tower of Hanoi, Josephus Problem,printing all permutations, sum of all subsets.

Array

In C++, an array is a data structure that allows you to store a fixed-size sequential collection of elements of the same type. Each element in the array is identified by an index or a key.

Insert Element , Delete Element , Second largest , Check if array is Sorted , Remove Duplicates From a Sorted Array.

About

This comprehensive guide covers fundamental concepts of Data Structures and Algorithms (DSA) in C++, including asymptotic notations like Big O, Theta, and Omega, mathematical foundations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages