0% found this document useful (0 votes)
13 views3 pages

Programming and Data Structures Notes

The document provides beginner-friendly notes on programming and data structures, covering problem-solving techniques, trees, hashing, priority queues, sorting, graphs, heaps, and search techniques. It outlines key concepts, definitions, and examples for each topic, including algorithms for adding numbers, tree traversals, hash functions, and sorting methods. The notes aim to facilitate understanding of fundamental programming concepts and data structures.

Uploaded by

gcescse26
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)
13 views3 pages

Programming and Data Structures Notes

The document provides beginner-friendly notes on programming and data structures, covering problem-solving techniques, trees, hashing, priority queues, sorting, graphs, heaps, and search techniques. It outlines key concepts, definitions, and examples for each topic, including algorithms for adding numbers, tree traversals, hash functions, and sorting methods. The notes aim to facilitate understanding of fundamental programming concepts and data structures.

Uploaded by

gcescse26
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

Programming and Data Structures – Beginner Friendly

Notes

1. Problem Solving Techniques


Problem solving in programming involves breaking a problem into smaller steps and solving it logically.

• Understand the problem clearly

• Identify inputs and outputs

• Design an algorithm

• Convert algorithm to program

• Test with sample data


Example: Add two numbers

Step 1: Start
Step 2: Input A, B
Step 3: Sum = A + B
Step 4: Display Sum
Step 5: Stop

2. Trees
A tree is a hierarchical data structure consisting of nodes connected by edges. The top node is called the root.

• Root – Top node

• Parent – Node with children

• Child – Node under parent

• Leaf – Node with no children


A (Root)
/ B C
/ \ D E F

Tree Traversals:
Preorder: A B D E C F
Inorder: D B E A C F
Postorder: D E B F C A

3. Hashing
Hashing stores data using a hash function that converts keys into index positions.

• Provides fast data access

• Used in dictionaries, databases

• Handles collisions using chaining or probing


Hash Table Example (Size = 5)

Index : Data
0 : 15
1 : 21
2 : --
3 : 33
4 : 44

Hash Function:
Key % Table Size

4. Priority Queues
A priority queue removes elements based on priority rather than insertion order.
• Highest priority served first

• Implemented using Heaps

• Used in scheduling systems


Priority Queue Example

Insert: 10, 5, 20

Removal Order:
20 → 10 → 5

5. Sorting
Sorting arranges data in ascending or descending order.

• Bubble Sort

• Selection Sort

• Insertion Sort

• Merge Sort

• Quick Sort
Bubble Sort Example

Array: 5 3 8 4

Pass 1 → 3 5 4 8
Pass 2 → 3 4 5 8
Sorted Array → 3 4 5 8

6. Graphs
A graph consists of vertices (nodes) and edges (connections).

• Directed Graph

• Undirected Graph

• Weighted Graph

• Used in networks, maps


Graph Example

A ----- B
| |
| |
D ----- C

7. Heap
A heap is a complete binary tree that satisfies heap property.

• Max Heap – Parent greater than children

• Min Heap – Parent smaller than children

• Used in Priority Queues


Max Heap Example

50
/ 30 40
/ \ /
10 20 35

8. Search Techniques
Searching finds the location of an element in a data structure.
• Linear Search – Sequential check

• Binary Search – Divide and conquer (sorted data)


Binary Search Example

Array: 10 20 30 40 50

Search 30:
Middle → 30 → Found

You might also like