CC Mini Project Report – Data Structures in C++
XYZ UNIVERSITY / INSTITUTE
Department of Computer Science & Engineering
Mini Project Report
Data Structures in C++
Arrays • Stack • Sorting • Graph Traversal (BFS & DFS)

Submitted in partial fulfillment of the requirements for the course

Computer Concepts (CC) / Data Structures

Academic Year: 2025 – 2026

Certificate


This is to certify that the Mini Project entitled “Data Structures in C++ — Arrays, Stack, Sorting, and Graph Traversal” has been submitted by Ankush, Roll No. ________________, in partial fulfillment of the requirements for the course Computer Concepts (CC), Department of Computer Science & Engineering.


The work presented in this report is genuine and has been carried out by the student under the guidance of the faculty. This project is an original work and has not been submitted elsewhere for any other degree or diploma.





Student’s Signature
Ankush
Faculty Signature
________________


Place: ________________     Date: ________________

Table of Contents


1. Introduction4
2. Objectives4
3. Tools & Technologies Used4
4. Array Operations5
   4.1 Theory5
   4.2 Algorithm5
   4.3 Code5
5. Stack Operations6
   5.1 Theory6
   5.2 Algorithm6
   5.3 Code6
6. Sorting Algorithms7
   6.1 Bubble Sort7
   6.2 Selection Sort7
   6.3 Comparison Table7
7. Graph Traversal — BFS & DFS8
   7.1 BFS Theory & Algorithm8
   7.2 DFS Theory & Algorithm8
   7.3 Code9
8. Sample Output10
9. Conclusion11
10. References11

1. Introduction

Data structures are the backbone of efficient computer programming. This mini project is developed in C++ to demonstrate the implementation and working of fundamental data structures and algorithms. The project covers Arrays, Stacks, Sorting Algorithms (Bubble Sort and Selection Sort), and Graph Traversal Techniques (BFS and DFS) — all managed through a user-friendly, menu-driven console interface.

Understanding these concepts is essential for every Computer Science student, as they form the foundation of advanced algorithms, operating systems, databases, and many real-world applications.

2. Objectives

3. Tools & Technologies Used

Tool / TechnologyDescription
C++ (C++17)Core programming language used for implementation
GCC / G++ CompilerCompiler used to build and run the program
VS Code / Dev-C++IDE used for writing and testing the code
STL <queue>Standard C++ queue used for BFS traversal
Windows OSOperating system environment

4. Array Operations

4.1 Theory

An Array is a linear data structure that stores elements of the same data type in contiguous memory locations. Each element in an array is accessed using its index. Arrays provide O(1) access time. In this project, arrays are used to store integers inputted by the user, upon which various operations are performed.

Operations Implemented:

4.2 Algorithm — Linear Search

  1. Start from index 0.
  2. Compare each element with the target key.
  3. If match found, return the index and print “FOUND”.
  4. If end of array is reached without match, print “NOT FOUND”.
Time Complexity: Best Case — O(1)  |  Worst Case — O(n)  |  Average — O(n/2)

4.3 Code Snippet

void arrayOps() { int n, arr[100], sum = 0; cout << “Enter number of elements: “; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; sum += arr[i]; } int maxVal = arr[0], minVal = arr[0]; for (int i = 1; i < n; i++) { if (arr[i] > maxVal) maxVal = arr[i]; if (arr[i] < minVal) minVal = arr[i]; } cout << “Sum: ” << sum << ” Average: ” << (float)sum/n; cout << ” Max: ” << maxVal << ” Min: ” << minVal; }

5. Stack Operations

5.1 Theory

A Stack is a linear data structure that follows the LIFO (Last In First Out) principle — the element inserted last is the first one to be removed. Think of it like a stack of plates: you add and remove from the top.

Operations Implemented:

Stack is implemented using a plain array with a top pointer variable. Time Complexity: Push — O(1), Pop — O(1), Peek — O(1).

5.2 Algorithm

  1. PUSH: If top == SIZE-1, print Overflow. Else, increment top and insert element at stackArr[top].
  2. POP: If top == -1, print Underflow. Else, print stackArr[top] and decrement top.
  3. PEEK: If top == -1, stack is empty. Else, return stackArr[top] without modifying top.
  4. DISPLAY: Traverse from index top down to 0 and print each element.

5.3 Code Snippet

int stackArr[100], top = -1; void push() { if (top == 99) { cout << “Stack Overflow!\n”; return; } int x; cout << “Enter value: “; cin >> x; stackArr[++top] = x; cout << x << ” pushed successfully.\n”; } void pop() { if (top == -1) { cout << “Stack Underflow!\n”; return; } cout << “Popped: ” << stackArr[top–] << “\n”; } void peek() { if (top == -1) cout << “Stack is empty.\n”; else cout << “Top element: ” << stackArr[top] << “\n”; }

6. Sorting Algorithms

6.1 Bubble Sort

Bubble Sort is a simple comparison-based sorting algorithm. It works by repeatedly swapping adjacent elements if they are in the wrong order. The largest element “bubbles up” to its correct position in each pass.

Algorithm:

  1. Repeat for i = 0 to n-2:
  2.    For j = 0 to n-i-2:
  3.      If arr[j] > arr[j+1], swap them.
  4. If no swap occurred in a pass, array is sorted — break early.
void bubbleSort(int arr[], int n) { for (int i = 0; i < n-1; i++) { bool swapped = false; for (int j = 0; j < n-i-1; j++) { if (arr[j] > arr[j+1]) { swap(arr[j], arr[j+1]); swapped = true; } } if (!swapped) break; // Already sorted } }

6.2 Selection Sort

Selection Sort works by selecting the minimum element from the unsorted portion and placing it at the beginning. It performs fewer swaps compared to Bubble Sort.

Algorithm:

  1. Repeat for i = 0 to n-2:
  2.    Find the index of minimum element in arr[i..n-1].
  3.    Swap arr[i] with arr[minIdx].
void selectionSort(int arr[], int n) { for (int i = 0; i < n-1; i++) { int minIdx = i; for (int j = i+1; j < n; j++) if (arr[j] < arr[minIdx]) minIdx = j; swap(arr[i], arr[minIdx]); } }

6.3 Comparison Table

Parameter Bubble Sort Selection Sort
Best CaseO(n) (with optimization)O(n²)
Worst CaseO(n²)O(n²)
Average CaseO(n²)O(n²)
Space ComplexityO(1)O(1)
SwapsManyAt most n-1
StableYesNo

7. Graph Traversal — BFS & DFS

7.1 BFS — Breadth First Search

BFS traverses a graph level by level, starting from a source node (node 0). It uses a Queue (FIFO) to keep track of nodes to visit. BFS is used in shortest path finding, web crawlers, and network broadcasting.

Algorithm:

  1. Mark source node as visited, enqueue it.
  2. While queue is not empty: Dequeue a node, print it.
  3. For each unvisited neighbor of the node: mark visited, enqueue it.
  4. Repeat until queue is empty.
Data Structure Used: Queue  |  Time Complexity: O(V + E)  |  Space Complexity: O(V)

7.2 DFS — Depth First Search

DFS traverses a graph by going as deep as possible from a node before backtracking. It uses Recursion (Call Stack) internally. DFS is used in topological sorting, cycle detection, and maze solving.

Algorithm (Recursive):

  1. Mark the starting node as visited and print it.
  2. For each neighbor of the current node:
  3.    If not visited, recursively call DFS on that neighbor.
Data Structure Used: Recursion (Stack)  |  Time Complexity: O(V + E)  |  Space Complexity: O(V)

7.3 BFS & DFS Comparison

ParameterBFSDFS
Data StructureQueue (FIFO)Stack / Recursion
TraversalLevel by LevelDepth First
Time ComplexityO(V + E)O(V + E)
Memory UsageMore (stores all nodes at level)Less (path only)
Best ForShortest PathCycle Detection, Topological Sort

7.4 Code Snippet

// BFS using queue void bfs() { queue<int> q; for (int i = 0; i < n; i++) visited[i] = 0; q.push(0); visited[0] = 1; while (!q.empty()) { int node = q.front(); q.pop(); cout << node << ” “; for (int i = 0; i < n; i++) if (adj[node][i]==1 && visited[i]==0) { q.push(i); visited[i] = 1; } } } // DFS using recursion void dfsHelper(int node) { visited[node] = 1; cout << node << ” “; for (int i = 0; i < n; i++) if (adj[node][i]==1 && visited[i]==0) dfsHelper(i); }

8. Sample Output

Main Menu

============================================ CC MINI PROJECT – DATA STRUCTURES ============================================ ===== MAIN MENU ===== 1. Array Operations (Sum, Max, Min, Search) 2. Stack Operations (Push, Pop, Peek, Display) 3. Sorting (Bubble Sort + Selection Sort) 4. Graph Traversal (BFS + DFS) 5. Exit ——————— Enter your choice: 1

Array Operations Output

Enter number of elements (max 100): 5 Enter 5 elements: 10 45 23 7 89 —– Array Results —– Elements : 10 45 23 7 89 Sum : 174 Average : 34.8 Maximum : 89 Minimum : 7 Enter element to search (Linear Search): 23 [FOUND] Element 23 found at index 2.

Stack Operations Output

— Stack Menu — 1. Push 2. Pop 3. Peek 4. Display 5. Back Enter choice: 1 Enter value to push: 50 [SUCCESS] 50 pushed onto stack. Enter choice: 4 Stack (Top –> Bottom): 50

Sorting Output

Enter number of elements (max 100): 5 Enter 5 elements: 64 34 25 12 22 Original Array : 64 34 25 12 22 Bubble Sort : 12 22 25 34 64 Selection Sort : 12 22 25 34 64

Graph BFS & DFS Output

Enter number of nodes: 4 Enter adjacency matrix: 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 BFS Traversal: 0 1 2 3 DFS Traversal: 0 1 3 2

9. Conclusion

This mini project successfully demonstrates the implementation of fundamental data structures and algorithms in C++. Through this project, the following key learnings were achieved:

This project helped in building a strong conceptual foundation in data structures, which is essential for pursuing advanced topics like Tree traversal, Dynamic Programming, and Graph Algorithms.

10. References

  1. Book: “Data Structures and Algorithms in C++” by Michael T. Goodrich, Roberto Tamassia, David M. Mount.
  2. Book: “Introduction to Algorithms” by Thomas H. Cormen (CLRS) — MIT Press.
  3. Book: “Let Us C++” by Yashavant Kanetkar — BPB Publications.
  4. Online Resource: GeeksforGeeks — www.geeksforgeeks.org (Array, Stack, BFS, DFS, Bubble Sort).
  5. Online Resource: cplusplus.com — C++ Standard Template Library Reference.
  6. College Notes: Class notes provided by the subject faculty.


—— End of Report ——
CC Mini Project | Data Structures in C++ | Academic Year 2025–2026