Datastructure
Datastructure
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.
Divided into:
1. Linear
2. Non-Linear
i. Arrays
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
iv. Queues
i. Trees
ii. Graphs
Defines what operations are allowed, not how they are implemented.
Examples:
o List
o Stack
o Queue
o Map
o Set
# Push
stack.append(10)
stack.append(20)
# Pop
print(stack.pop()) # Outputs 20
# Peek
print(stack[-1]) # Outputs 10