DSA

 

What is DSA?

DSA stands for Data Structure and Algorithms. This is a very important form for managing and organizing data. Data Structure is a way to store data efficiently. Algorithms are nothing but a way to solve problems. This will give you an efficient way to solve problems while working with data.

Abstract Data Type

An Abstract Data Type (ADT) in Data Structures and Algorithms (DSA) is a mathematical model that defines a data structure along with its operations but hides the underlying implementation. It focuses on what operations can be performed rather than how they are implemented. Common ADTs include List, Stack, Queue, Deque, Set, and Map, each serving different purposes in data management. For example, a Stack follows the LIFO (Last In, First Out) principle, while a Queue follows FIFO (First In, First Out). ADTs provide a structured way to organize and manipulate data efficiently, ensuring encapsulation, reusability, and flexibility in programming. 

Arrays 

An array is a linear data structure that stores elements of the same data type in nearby memory locations. It allows fast random access using an index but has a fixed size (in static arrays).

Key Features:

✅ Indexed Access – Elements can be accessed using indices (0-based in most languages).
✅ Efficient Retrieval – Access time is O(1) for direct indexing.
✅ Fixed Size – The size is defined at declaration (for static arrays).
✅ Homogeneous Data – Stores elements of the same type.

Operations & Complexity:

OperationDescriptionTime Complexity
AccessRetrieve an element by indexO(1)
SearchFind an element (Linear/Binary Search)O(n) / O(log n)
InsertAdd an element (At end: O(1), At middle: O(n))O(n)
DeleteRemove an element (At end: O(1), At middle: O(n))O(n)

Types of Arrays:

  1. One-Dimensional Array (1D) – int arr[5] = {1, 2, 3, 4, 5};
  2. Multi-Dimensional Array (2D/3D) – int matrix[3][3] (for grids, matrices).
  3. Dynamic Arrays – Resizable versions like ArrayList in Java

 

 To declare array in java we can use:

int[] marks = new int[3] -- Here 3 means here 3 values should be stored. If there were 20, that means there would be 20 values stored.


 

 

 


Comments

Popular posts from this blog

Nest js

Malware Analysis

Internet Computer (ICP) - Blockchain