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

Datastructure

A data structure is a method for organizing and storing data for efficient access and modification. It includes primitive types like int and float, and non-primitive types such as linear structures (arrays, linked lists, stacks, queues) and non-linear structures (trees, graphs). Key operations on data structures include traversal, insertion, deletion, searching, and sorting, with various applications across computing tasks.

Uploaded by

dihoncho.pro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Datastructure

A data structure is a method for organizing and storing data for efficient access and modification. It includes primitive types like int and float, and non-primitive types such as linear structures (arrays, linked lists, stacks, queues) and non-linear structures (trees, graphs). Key operations on data structures include traversal, insertion, deletion, searching, and sorting, with various applications across computing tasks.

Uploaded by

dihoncho.pro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

DATA STRUCTURES – FULL NOTES

🧠 1. What is a Data Structure?

A data structure is a way of organizing and storing data in a computer so it can be accessed
and modified efficiently.

Example: Like organizing books on a shelf by subject so you can find them quickly.

📚 2. Types of Data Structures

A. Primitive Data Structures

 Basic types provided by programming languages.


 Examples: int, float, char, boolean.

B. Non-Primitive Data Structures

Divided into:

1. Linear
2. Non-Linear

🔁 3. Linear Data Structures

Data elements are arranged in a sequence.

i. Arrays

 Fixed-size collection of elements of the same type.


 Accessed using index.
 Example: int arr[5] = {1,2,3,4,5};

ii. Linked List

 A list of nodes where each node contains data and a reference to the next node.
 Types:
o Singly Linked List
o Doubly Linked List
o Circular Linked List

iii. Stacks

 LIFO (Last In First Out)


 Operations: push, pop, peek
 Example: Undo feature in software

iv. Queues

 FIFO (First In First Out)


 Operations: enqueue, dequeue
 Types:
o Simple Queue
o Circular Queue
o Priority Queue
o Deque (Double-ended queue)

🌲 4. Non-Linear Data Structures

Data elements are not in sequence.

i. Trees

 Hierarchical structure with nodes.


 Root node at the top, child nodes below.
 Types:
o Binary Tree
o Binary Search Tree (BST)
o AVL Tree
o Heap Tree

ii. Graphs

 Set of nodes (vertices) connected by edges.


 Can be:
o Directed or Undirected
o Weighted or Unweighted
 Applications: Maps, social networks, routing algorithms.

📦 5. Abstract Data Types (ADT)


An abstract model for a data structure.

 Defines what operations are allowed, not how they are implemented.
 Examples:
o List
o Stack
o Queue
o Map
o Set

📈 6. Operations on Data Structures

Common operations include:

 Traversal – Visiting elements (e.g., loop through array).


 Insertion – Adding data.
 Deletion – Removing data.
 Searching – Finding data.
 Sorting – Arranging data.

🧠 7. Time & Space Complexity

Analyzes efficiency of data structures.

Data Structure Access Search Insertion Deletion


Array O(1) O(n) O(n) O(n)
Linked List O(n) O(n) O(1) O(1)
Stack/Queue O(n) O(n) O(1) O(1)
Binary Search Tree O(log n) O(log n) O(log n) O(log n)

🧠 8. Applications of Data Structures

 Arrays – Storing list of elements.


 Stacks – Undo operations, function calls.
 Queues – Task scheduling, printer queue.
 Linked Lists – Dynamic memory allocation.
 Trees – File systems, hierarchical data.
 Graphs – GPS systems, social networks.
✍️ 9. Example Code Snippet (Python – Stack using List)
python
CopyEdit
stack = []

# Push
stack.append(10)
stack.append(20)

# Pop
print(stack.pop()) # Outputs 20

# Peek
print(stack[-1]) # Outputs 10

You might also like