0% found this document useful (0 votes)
2 views2 pages

Data Structures with Python Examples

This document provides notes on various data structures including Arrays, Linked Lists, Stacks, Queues, and Trees, along with code examples in Python. It explains the characteristics and operations of each data structure, such as traversal, insertion, and deletion for arrays, and the structure of linked lists and binary trees. Each section includes sample Python code to illustrate how to implement these data structures.

Uploaded by

sk k
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 views2 pages

Data Structures with Python Examples

This document provides notes on various data structures including Arrays, Linked Lists, Stacks, Queues, and Trees, along with code examples in Python. It explains the characteristics and operations of each data structure, such as traversal, insertion, and deletion for arrays, and the structure of linked lists and binary trees. Each section includes sample Python code to illustrate how to implement these data structures.

Uploaded by

sk k
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

Data Structures Notes (with Code Examples)

1. Arrays

Array ek fixed-size data structure hai jisme same type ke elements store hote hain.
Operations: Traversal, Insertion, Deletion, Searching.

# Array Traversal in Python


arr = [1, 2, 3, 4, 5]
for i in arr:
print(i)

2. Linked List

Linked List ek linear data structure hai jisme elements (nodes) ek dusre se linked hote hain.
Types: Singly, Doubly, Circular.

# Singly Linked List Node in Python


class Node:
def __init__(self, data):
[Link] = data
[Link] = None

# Creating nodes
node1 = Node(10)
node2 = Node(20)
[Link] = node2

3. Stack

Stack ek LIFO (Last In First Out) data structure hai.


Operations: push, pop, peek.

# Stack using list


stack = []
[Link](10) # push
[Link](20)
print([Link]()) # pop

4. Queue

Queue ek FIFO (First In First Out) data structure hai.


Operations: enqueue, dequeue.

# Queue using list


queue = []
[Link](10) # enqueue
[Link](20)
print([Link](0)) # dequeue
Data Structures Notes (with Code Examples)

5. Trees (Binary Tree)

Tree ek hierarchical data structure hai.


Binary Tree me har node ke 2 children ho sakte hain.

# Binary Tree Node in Python


class Node:
def __init__(self, data):
[Link] = data
[Link] = None
[Link] = None

You might also like