Introduction to DSA

Data Structures and Algorithms (DSA) are the building blocks of efficient problem solving in computer science.

They help manage data logically and perform operations like searching, sorting, and traversing quickly.

Big O Notation is used to measure time and space complexity of algorithms.
Arrays

An array is a collection of elements stored at contiguous memory locations.

It allows constant-time access to any element using its index.

let numbers = [10, 20, 30, 40];
Linked Lists

A linked list is a linear data structure where each element points to the next.

It allows dynamic memory allocation and efficient insertion/deletion.

class Node { constructor(data) { this.data = data; this.next = null; } }
Stacks and Queues

A stack follows LIFO (Last In First Out), whereas a queue follows FIFO (First In First Out).

They are used in recursion, scheduling, and memory management.

stack.push(1); stack.pop(); // LIFO
Searching and Sorting

Searching algorithms find a target element in a data structure. Sorting algorithms arrange data in order.

Binary Search is efficient for sorted data; Merge Sort is a stable divide-and-conquer sorting technique.

int binarySearch(int arr[], int x)