fundamental components of computer science that enable the efficient organization, storage, and manipulation of data.
Data Structure
They provide a systematic way of representing and managing collections of data elements, allowing algorithms to operate effectively on them.
Data Structures
is a particular way of organizing data in a computer so that it can be used effectively.
Data Structure
Data structures are fundamental components of computer science that enable the efficient organization, storage, and manipulation of data.
A data structure is not only used for organising the data. It is also used for processing, retrieving, and storing data.
The structure of the data and the synthesis of the algorithm are relative to each other.
are basic data types provided by a programming language's syntax and are typically built into the language itself.
Primitive Data Types
Primitive Data Types
Integer
Float/Double
Boolean
Character
High-level models of data structures that specify a set of operations that can be performed on the data, without specifying the implementation details.
Abstract Data Types
Abstract Data Types
Stack
Queue
List
Supports operations such as push (to add an element), pop (to remove the top element), and peek (to view the top element).
Stack
Supports operations such as enqueue (to add an element), dequeue (to remove the front element), and peek (to view the front element).
Queue
Supports operations such as insert (to add an element at a specific position), delete (to remove an element), and retrieve (to access an element).
List
Data elements are arranged sequentially, and each element has a unique predecessor and successor.
Linear Data Structures
Elements are stored in contiguous memory locations, and access to elements is based on their index.
Arrays
Elements are stored as nodes where each node contains data and a reference to the next node in the sequence.
Linked List
Elements follow the Last-In-First-Out (LIFO) principle, where insertion and deletion occur at one end called the top.
Stack
Elements follow the First-In-First-Out (FIFO) principle, where insertion occurs at the rear end and deletion occurs at the front end.
Queue
Data elements are not arranged sequentially, and each element may have multiple predecessors and successors.
Non-Linear Data Structures
Elements are organized hierarchically, with each node having a parent and zero or more children.
Trees
Elements (vertices) are connected by edges, and there can be multiple paths between vertices.
Graphs
also known as software or code, is a set of instructions written in a programming language to perform specific tasks or solve particular problems.
Programs
is a step-by-step procedure or set of rules designed to solve a specific problem or perform a particular task.
Algorithm
Characteristics of an Algorithm
Well-defined
Finite
Effective
Deterministic
Precise
Efficient
Generalizable
Modular
Correctness
Optimality
Characteristics of Linear Data Structure
Sequential Organization
Order Preservation
Fixed or Dynamic Size
Efficient Access
Types of Linear DS
Array
Stack
Queue
Linked List
is a collection of elements of the same data type, stored in contiguous memory locations.
Array
In an array, elements are identified by their indexes. Array index starts from 0.
Array Index
Elements are items stored in an array and can be accessed by their index.
Array Element
The length of an array is determined by the number of elements it can contain.
Array Length
The representation of an array can be defined by its declaration. A declaration means allocating memory for an array of a given size.
One-dimensional array (1-D arrays): You can imagine a 1d array as a row, where elements are stored one after another.
Two-dimensional array: 2-D Multidimensional arrays can be considered as an array of arrays or as a matrix consisting of rows and columns.
Three-dimensional array: A 3-D Multidimensional array contains three dimensions, so it can be considered an array of two-dimensional arrays.
Traversal: Traverse through the elements of an array.
Insertion: Inserting a new element in an array.
Deletion: Deleting element from the array.
Searching: Search for an element in the array.
Sorting: Maintaining the order of elements in the array.
A linked list is a linear data structure consisting of a sequence of elements called nodes.
If there are no beads (an empty list)in a linked list, the head pointer just points to nothing.
At the start of the string is the first bead, marked by a pointer called the head pointer.
Each bead (node) holds some info (data) and a link to the next bead.
In a Singly Linked List (SLL), each node contains a data element and a pointer to the next node in the sequence.