This repository contains comprehensive implementations of various data structures and algorithms in C++ for the Data Structures course (Level 2, Term 1) at Chittagong University of Engineering & Technology (CUET). These implementations serve both as course assignments and learning resources.
- Institution: Chittagong University of Engineering & Technology (CUET)
- Course: Data Structures (CSE-241)
- Level: 2
- Term: 1
Course Teachers:
- Animesh Chandra Roy - Assistant Professor, Dept. of CSE, CUET
- Md. Atiqul Islam Rizvi - Assistant Professor, Dept. of CSE, CUET
Data Structures with C by Seymour Lipschutz
Location: lab1-array/
This lab covers fundamental array operations and algorithmic problems:
-
Array Operations (
1_array_operatoins.cpp)- Add integer to all elements
- Multiply all elements by integer
- Divide all elements by integer
- Swap specific elements
- Reverse array
-
Happy Runners (
2_happy_runners.cpp)- Determine happiness criteria for two runners (Alice and Bob)
- Count days when both are happy
- Alice unhappy if Bob ran > 2× her distance
- Bob unhappy if Alice ran > 2× his distance
-
Dividing Array Into Three Sets (
3_diving_array_into_three_sets.cpp)- Divide array into three non-empty sets
- First set: product is negative
- Second set: product is positive
- Third set: product is zero
-
Two Sum (
4_two_sum.cpp)- Find two different elements that sum to target
- Return indices of found elements or NULL if not found
-
Jump Game (
5_jump_game.cpp)- Determine if you can reach the last array index
- Each element represents maximum jump length from that position
Location: lab2-string/
This lab focuses on string manipulation and pattern matching:
-
World Chess Championship (
1_world_chess_championship.cpp)- Calculate prize money based on game results
- Scoring: Win = 2 pts, Draw = 1 pt each, Loss = 0 pts
- Champion gets 60% or 55% (if tied) of prize pool
- Input: String of 14 characters (C=Carlsen win, N=Chef win, D=Draw)
-
Happy String (
2_happy_string.cpp)- Generate k-th lexicographically ordered "happy string" of length n
- Happy string: contains only a, b, c with no adjacent characters being same
- Returns empty string if fewer than k happy strings exist
-
Shortest Palindrome (
3_shortest_palindrome.cpp)- Find shortest palindrome by adding characters to the right of string
- Calculate minimum length of resulting palindrome
- Handles very large strings efficiently
-
Add One to Large Number (
4_add_one_to_large_number.cpp)- Add 1 to extremely large numbers (up to 10^200000)
- Handle as string since numbers exceed standard integer limits
- Efficiently manage carry-over logic
Location: lab3-link_list/
This lab covers basic singly linked list operations:
-
Link List Operations (
link_list_perations.cpp)- Traversing linked list
- Searching (unsorted and sorted lists)
- Insertion (beginning, middle, end, and sorted)
- Deletion (at location and for specific item)
-
Problem 1: Critical Points (
problem1.cpp)- Find local minima and local maxima in linked list
- Local minima: both adjacent nodes have greater values
- Local maxima: both adjacent nodes have smaller values
- First and last nodes are not considered critical
-
Problem 2: Middle Element (
problem2.cpp)- Find middle element of singly linked list
- Middle position = floor(N/2) + 1 from head
Location: lab4-link_list_more/
This lab implements specialized linked list variants:
-
Grounded Header Linked List (
grounded_header_linked_list.cpp)- Linked list with header node at beginning
- Operations: traversing, searching, insertion, deletion
-
Circular Header Linked List (
circular_header_linked_list.cpp)- Circular linked list with header node
- Last node points back to header node
- Operations: traversing, searching, insertion, deletion
-
Doubly Linked List (
doubly_linked_list.cpp)- Two-way circular linked list (doubly linked)
- Each node has pointers to both next and previous nodes
- Operations: traversing, insertion, deletion
Location: lab5-queue_stack_recursion/
This lab explores stack, queue, and recursive applications:
-
Stack Performance (
stack_perfomance.cpp)- Stack operations: push, pop, peek
- LIFO (Last-In-First-Out) behavior
- Performance analysis
-
Queue Performance (
queue_performance.cpp)- Queue operations: enqueue, dequeue, peek
- FIFO (First-In-First-Out) behavior
- Performance metrics
-
Deque Performance (
deque_performance.cpp)- Double-ended queue operations
- Insert/delete from both ends
- Performance benchmarking
-
Priority Queue Performance (
priority_queue_performance.cpp)- Elements ordered by priority
- High priority elements dequeued first
- Performance analysis
-
Infix to Postfix (
infixToPostfix.cpp)- Convert infix expressions to postfix notation
- Evaluate postfix expressions
- Use stack-based approach
-
Tower of Hanoi (
tower_of_hanoi_performance.cpp)- Classic recursive puzzle solution
- Move disks from source to destination peg
- Minimum moves calculation: 2^n - 1
Location: lab6-binary_tree/
This lab covers tree creation and traversal algorithms:
-
Binary Tree (
bt.cpp)- Binary tree creation and traversal
- Preorder, Inorder, Postorder traversal (recursive and iterative)
- Uses stack for iterative approaches
-
Binary Search Tree (BST) (
BST.cpp)- BST creation with ordered insertion
- Searching elements in BST
- Deletion from BST
- Maintains sorted property
Location: lab7-m_way_tree/
This lab explores multi-way trees:
- M-Way Tree Performance (
m_way_performance.cpp)- Trees with more than 2 children per node
- Operations and performance analysis
- Useful for databases and file systems
Location: lab8/
Contains: READIT.txt (placeholder for future content)
Location: lab9-heap_graph/
This lab covers heap structures and graph algorithms:
-
Huffman Min Heap (
huffman_min_heap.cpp)- Min heap creation and operations
- Insertion in min heap
- Searching in min heap
- Deletion from min heap
- Huffman coding algorithm using min heap
-
Graph BFS/DFS (
graph_bfs_dfs.cpp)- Graph creation and representation
- Breadth-First Search (BFS) traversal
- Depth-First Search (DFS) traversal
- Applications in connectivity and pathfinding
.
├── README.md
├── lab1-array/
│ ├── 1_array_operatoins.cpp
│ ├── 2_happy_runners.cpp
│ ├── 3_diving_array_into_three_sets.cpp
│ ├── 4_two_sum.cpp
│ ├── 5_jump_game.cpp
│ └── problem_statement.md
├── lab2-string/
│ ├── 1_world_chess_championship.cpp
│ ├── 2_happy_string.cpp
│ ├── 3_shortest_palindrome.cpp
│ ├── 4_add_one_to_large_number.cpp
│ └── problem_statement.md
├── lab3-link_list/
│ ├── link_list_perations.cpp
│ ├── problem1.cpp
│ ├── problem2.cpp
│ └── problems_statement.md
├── lab4-link_list_more/
│ ├── circular_header_linked_list.cpp
│ ├── doubly_linked_list.cpp
│ ├── grounded_header_linked_list.cpp
│ └── problem_statement.md
├── lab5-queue_stack_recursion/
│ ├── deque_performance.cpp
│ ├── infixToPostfix.cpp
│ ├── priority_queue_performance.cpp
│ ├── queue_performance.cpp
│ ├── stack_perfomance.cpp
│ ├── tower_of_hanoi_performance.cpp
│ └── problems_statement.md
├── lab6-binary_tree/
│ ├── BST.cpp
│ ├── bt.cpp
│ └── problem_statement.md
├── lab7-m_way_tree/
│ └── m_way_performance.cpp
├── lab8/
│ └── READIT.txt
└── lab9-heap_graph/
├── graph_bfs_dfs.cpp
├── huffman_min_heap.cpp
└── problems_statement.md
- Arrays
- Strings
- Singly Linked Lists
- Grounded Header Linked Lists
- Circular Linked Lists
- Doubly Linked Lists
- Stacks
- Queues
- Deques
- Priority Queues
- Binary Trees
- Binary Search Trees
- M-Way Trees
- Heaps (Min Heap)
- Graphs
- Array manipulation and searching
- String processing
- Tree traversal (preorder, inorder, postorder)
- Graph traversal (BFS, DFS)
- Huffman coding
- Tower of Hanoi
- Expression conversion (Infix to Postfix)
- Each file is independent and can be compiled separately
- Default build task:
C/C++: g++ build active file - Ensure g++ is installed:
which g++ - Debug compilation with:
g++ -g -o program program.cpp
Feel free to contribute by:
- Forking the repository
- Creating a new branch for your feature
- Submitting a pull request
This project is open source and available for educational purposes.
- GitHub: @parvej236