Data Structures Complete Visual Notes BCA 3rd Semester TU, Study notes of Data Structures and Algorithms

Complete Data Structures study notes for BCA 3rd Semester students at Tribhuvan University (TU), Nepal. Topics covered: - Introduction to Data Structures & ADT - Arrays (operations, types, complexity) - Linked Lists (singly, doubly, circular) - Stacks (LIFO, applications, expressions) - Queues (FIFO, circular queue, types) - Trees & Binary Search Tree (BST) - Sorting Algorithms (Bubble, Merge, Quick) - Searching Algorithms (Linear, Binary) Features: - Visual diagrams for every topic - Color-coded chapters - Time complexity tables - Important exam questions with answers - Easy to understand language Perfect for exam preparation and last-minute revision! Academic Year: 2025/2026

Typology: Study notes

2025/2026

Available from 05/20/2026

lahana-shrestha
lahana-shrestha 🇳🇵

2 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
DATA STRUCTURES | BCA 3rd Semester | Tribhuvan University Page 1
Well-structured notes for exam success | Best of luck!
DATA STRUCTURES
Complete Visual Study Notes
BCA 3rd Semester · Tribhuvan University · Nepal
8 Chapters Visual Diagrams Exam Q&A Color-coded Complete Syllabus
8
Chapters 50+
Concepts 8+
Diagrams 20+
Exam Q&A 100%
Syllabus
TIP: These notes cover the complete BCA 3rd Semester Data Structures syllabus with visual diagrams, examples, and exam-oriented Q&A. Perfect for last-minute revision!
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Data Structures Complete Visual Notes BCA 3rd Semester TU and more Study notes Data Structures and Algorithms in PDF only on Docsity!

n

DATA STRUCTURES

Complete Visual Study Notes

BCA 3rd Semester · Tribhuvan University · Nepal

n 8 Chapters n Visual Diagrams n Exam Q&A n Color-coded n Complete Syllabus

Chapters

Concepts

Diagrams

Exam Q&A

Syllabus

n TIP: These notes cover the complete BCA 3rd Semester Data Structures syllabus with visual diagrams, examples, and exa

n Table of Contents

n Chapter 1 Introduction to Data Structures n

n Chapter 2 Arrays n

n Chapter 3 Linked Lists n

n Chapter 4 Stacks n

n Chapter 5 Queues n

n Chapter 6 Trees & BST n

n Chapter 7 Sorting Algorithms n

n Chapter 8 Searching Algorithms n

n Important Exam Questions n

n EXAM: Always aim for O(1) or O(log n) algorithms. O(n²) is fine for small data but terrible for large inputs!

n Chapter 2: Arrays n DEF: An Array is a collection of elements of the same data type stored in CONTIGUOUS memory locations, accessed usin Index: 0 1 2 3 4 5 6 Value: 10 25 8 42 17 33 5 n Each box = one memory cell | Index starts at 0 | Access any element in O(1)!

Array Operations & Time Complexity Operation Time Complexity Reason Access (read/write) O(1) n FAST Direct index calculation Search (unsorted) O(n) Must check each element Insert at end O(1) No shifting needed Insert at beginning O(n) n SLOW Must shift all elements right Delete from end O(1) Just reduce size Delete from middle O(n) n SLOW Must shift elements left Traversal O(n) Visit every element once n EXAM: Arrays are BEST when: you know the size in advance & need fast random access. Use Linked Lists when: frequent

n Chapter 4: Stacks n DEF: A Stack is a linear data structure following LIFO — Last In, First Out. Think of a stack of plates: you can only add/rem

5 <-- TOP

<-- BOTTOM

Operation Action Time push(x) Add x to top O(1) pop() Remove top O(1) peek() View top O(1) isEmpty() Check empty O(1) isFull() Check full O(1)

Applications of Stack

n Function Call Stack^ OS uses stack to track function calls & returns

nn Undo/Redo^ Text editors use stacks for undo operations

n

Expression

Evaluation Evaluate Infix, Prefix, Postfix expressions

n Bracket Matching^ Compilers check ( ) [ ] { } using stacks

n Browser History^ Back button works using a stack

n DFS Traversal^ Depth-First Search in graphs/trees

Infix / Prefix / Postfix Expressions Type Operator Position Example Evaluation Infix Between operands A + B * C Use rules of precedence Prefix Before operands + A * B C Right to left scan Postfix After operands A B C * + Left to right with stack n EXAM: Infix to Postfix conversion using Stack is a VERY common exam question. Practice tracing it step by step!

n Chapter 5: Queues n DEF: A Queue follows FIFO — First In, First Out. Think of a ticket counter line: first person in line is served first.

Visual Diagram: Queue

10 25 8 42 17 FRONT REAR

DEQ ENQ

Queue Operations Operation Description Where Time enqueue(x) Add element x At REAR end O(1) dequeue() Remove element From FRONT end O(1) front() View front element At FRONT O(1) isEmpty() Check if empty Whole queue O(1) isFull() Check if full Whole queue O(1)

Types of Queues Type Key Feature Problem Solved Simple Queue Basic FIFO Basic ordering Circular Queue Rear wraps around to front Solves wasted space in linear queue Deque Insert/delete from both ends Flexible: acts as both stack and queue Priority Queue Highest priority served first CPU scheduling, Dijkstra algorithm

Stack vs Queue — Know the Difference! Feature n Stack n Queue Principle LIFO — Last In First Out FIFO — First In First Out Insert push() — at TOP enqueue() — at REAR Delete pop() — from TOP dequeue() — from FRONT Pointers One: top Two: front & rear Real-life Stack of plates Bank/ticket queue Use case Expression eval, DFS CPU scheduling, BFS n EXAM: Stack vs Queue difference is asked in EVERY exam. Memorize: Stack=LIFO, Queue=FIFO. One uses top pointer,

Operation Average Case Worst Case When worst happens Insert O(log n) O(n) Inserting sorted data (e.g., 1,2,3,4,5) Delete O(log n) O(n) Same — skewed tree

n Chapter 7: Sorting Algorithms n DEF: Sorting = arranging elements in order (ascending/descending). Different algorithms have very different speeds — cho

Bubble Sort — Step by Step Visual Original: 64 34 25 12 22 Pass 1: 34 25 12 22 64 Pass 2: 25 12 22 34 64 Sorted: 12 22 25 34 64 Bubble Sort: Compare adjacent pairs, swap if wrong order. Largest element "bubbles up" to end each pass. All Sorting Algorithms Comparison Algorithm Best Average Worst Space Stable? Method Bubble Sort O(n) O(n²) O(n²) O(1) YES Comparison Selection Sort O(n²) O(n²) O(n²) O(1) NO Comparison Insertion Sort O(n) O(n²) O(n²) O(1) YES Comparison Merge Sort O(n log n) O(n log n) O(n log n) O(n) YES Divide & Conquer Quick Sort O(n log n) O(n log n) O(n²) O(log n) NO Divide & Conquer Heap Sort O(n log n) O(n log n) O(n log n) O(1) NO Heap-based

Which Algorithm to Use? Situation Best Choice Why Small data (n < 20) Insertion Sort Fast in practice, simple code General purpose Quick Sort Best average case, in-place Need guaranteed O(n log n) Merge Sort Always O(n log n), stable Nearly sorted data Insertion Sort Near O(n) for almost-sorted Memory is limited Heap Sort O(1) extra space n EXAM: Know TIME COMPLEXITY of all 6 sorting algorithms by heart — this appears in EVERY exam. Also: Merge Sort alw

n Important Exam Questions & Answers

Q1. What is a Data Structure? Why is it important?

Ans: A Data Structure is a way of organizing and storing data so it can be accessed and modified efficiently. It is importa

Q2. What is LIFO and FIFO? Name the data structures that use them.

Ans: LIFO (Last In First Out): The last inserted element is the first to be removed. Used by STACK. FIFO (First In First O

Q3. Write 5 differences between Array and Linked List.

Ans: 1. Memory: Array=contiguous, Linked List=non-contiguous. 2. Size: Array=fixed, Linked List=dynamic. 3. Access: A

Q4. What are tree traversals? Give the result for Inorder, Preorder, Postorder for BST with root 50.

Ans: Tree traversal = visiting each node exactly once. For BST with root=50, left=30, right=70: Inorder (LNR): 20,30,40,

Q5. What is a Circular Queue? How does it solve the problem of linear queue?

Ans: A Circular Queue connects the last position back to the first (rear = (rear+1) % size). Problem with linear queue: Aft

Q6. Compare Bubble Sort and Merge Sort with time complexities.

Ans: Bubble Sort: Best=O(n), Average=O(n²), Worst=O(n²), Space=O(1), Stable=Yes. Simple but slow for large data. Me

Q7. What is Binary Search? Write its time complexity and when it can be applied.

Ans: Binary Search finds an element in a sorted array by repeatedly dividing the search space in half. Algorithm: (1) Find

Q8. What is ADT? Give two examples with operations.

Ans: Abstract Data Type (ADT) = defines data + operations WITHOUT specifying implementation. Example 1 — Stack A

n Best of Luck in Your Exams! | Study Hard, Score High! n