Data structures and algorithms

Data structures and algorithms

What is Data Structure?

A data structure is defined as a particular way of storing and organizing data in our devices to use the data efficiently and effectively. The main idea behind using data structures is to minimize the time and space complexities. An efficient data structure takes minimum memory space and requires minimum time to execute the data.

What is Algorithm?

Algorithm is defined as a process or set of well-defined instructions that are typically used to solve a particular group of problems or perform a specific type of calculation. To explain in simpler terms, it is a set of operations performed in a step-by-step manner to execute a task.

Time and space complexity

  • Time Complexity Overview: Time complexity measures an algorithm's efficiency in relation to input size, crucial for optimal algorithm selection.

  • Big O, Omega, and Theta Notations:

    • Big O (O): Describes the upper bound on an algorithm's growth.

    • Big Omega (Ω): Represents the lower bound, denoting the best-case scenario.

    • Theta (θ): Signifies both upper and lower bounds, providing a tight estimation.

  • Examples:

    • O(1) for constant time.

    • O(n) for linear tasks.

    • O(log n) for logarithmic growth.

https://media.geeksforgeeks.org/wp-content/cdn-uploads/mypic.png

1.Array

An array is a collection of items of same data type stored at contiguous memory locations.

The array, a fundamental data structure, stands as a linear collection of similar data types. With contiguous memory allocation, accessing any element happens in constant time.

Lightbox

2.String

it's essentially an array of characters.

What makes it unique is that the last character is a null character, signaling the string's end.

3.Linked List

A chain of elements where each holds a value and a link to the next, forming a linear structure.

what is LinkedList - DSA | Data Structures and Algorithms

4.Matrix

A matrix represents a collection of numbers arranged in an order of rows and columns. It is necessary to enclose the elements of a matrix in parentheses or brackets

5.Stack

A collection of elements with last-in, first-out access. Like a stack of books—grab the top one first.

[DSA] Cấu trúc dữ liệu Stack - Sharing is caring

6.Queue

A line of elements, first-in, first-out. Imagine waiting in line; the first one there gets served first

Priority Queue Data Structure

7.Heap

A structured tree-like data storage. The root has the highest (max-heap) or lowest (min-heap) value

[DS-For Dummies] Heap. What is heap | by Truong Nhu Khang | Medium

8.Tree

A branching data structure with a root and nodes connected by edges, creating a hierarchical organization of information.

Binary Trees in DSA - Bagni Blog

9.Graph

A network of nodes connected by edges, representing relationships. It's like a web linking various elements together.

Complete Roadmap To Learn DSA From Scratch - GeeksforGeeks