0% found this document useful (0 votes)
2 views

Data structures

Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Data structures

Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

"Data structure" refers to a specific way of organizing and storing data in a computer so that it can be

accessed and modified efficiently. The choice of an appropriate data structure can greatly affect the
performance of algorithms that operate on the data. Below are some common types of data structures:

1. Arrays

Description: A collection of elements identified by index or key. All elements are of the same data type.

Use Cases: When you need to store multiple items of the same type, such as a list of numbers or strings.

Example: A list of temperatures recorded daily.

2. Linked Lists

Description: A linear collection of elements, where each element (node) contains a value and a reference
(link) to the next element in the sequence.

Types:

Singly Linked List: Each node points to the next node.

Doubly Linked List: Each node points to both the next and the previous node.

Use Cases: When you need efficient insertion and deletion of elements, particularly at the beginning or
end of the list.

Example: A playlist of songs where you can easily add or remove songs.

3. Stacks

Description: A collection of elements that follows the Last In, First Out (LIFO) principle. You can only
insert and remove elements from the top.

Use Cases: Undo functionality in software, backtracking algorithms.

Example: A stack of books where you can only remove the top book.

4. Queues

Description: A collection of elements that follows the First In, First Out (FIFO) principle. Elements are
added at the back and removed from the front.

Types:

Simple Queue

Circular Queue
Priority Queue

Use Cases: Order processing systems, task scheduling.

Example: A line of customers waiting at a bank.

5. Trees

Description: A hierarchical data structure where each element is called a node, and each node has a
parent and zero or more children.

Types:

Binary Tree: Each node has at most two children.

Binary Search Tree (BST): A binary tree where the left child contains values less than the parent, and the
right child contains values greater than the parent.

AVL Tree, Red-Black Tree: Self-balancing binary search trees.

Heap: A tree-based data structure that satisfies the heap property.

Use Cases: Hierarchical data, fast lookup, insertion, and deletion.

Example: File systems, decision trees.

6. Graphs

Description: A collection of nodes (vertices) connected by edges. Can be directed or undirected.

Types:

Directed Graph (Digraph): Edges have a direction.

Undirected Graph: Edges have no direction.

Weighted Graph: Edges have weights or costs associated with them.

Unweighted Graph

Use Cases: Social networks, route optimization, web page ranking.

Example: A map where locations are vertices and roads are edges.

7. Hash Tables

Description: A data structure that maps keys to values using a hash function. Allows for fast data
retrieval.

Use Cases: Fast lookup, insertion, and deletion operations.


Example: Implementing a dictionary where words are keys and definitions are values.

8. Heaps

Description: A specialized tree-based data structure that satisfies the heap property. A Max-Heap or Min-
Heap can be used.

Use Cases: Priority queues, efficient sorting algorithms like heap sort.

Example: Managing tasks in an operating system with different priorities.

9. Tries (Prefix Trees)

Description: A tree-like data structure used to store dynamic sets or associative arrays where the keys
are usually strings.

Use Cases: Autocomplete systems, spell checkers.

Example: A phone directory where searching for names is efficient.

10. Sets

Description: A collection of unique elements (no duplicates).

Use Cases: Membership testing, removing duplicates from a list.

Example: A list of unique email addresses.

Why Data Structures Matter:

Efficient data storage and retrieval are critical in programming and computer science. Choosing the right
data structure can lead to mor

You might also like