1.
Function Pointer-Based Sorting
Problem 1: Sorting Player Scores in a Game Leaderboard
Problem Statement:
In an online multiplayer game, players earn points after completing challenges. The game
leaderboard allows sorting scores either in ascending order (low to high) or descending
order (high to low).
Your task is to:
1. Take a list of player scores.
2. Allow the user to choose a sorting order.
3. Use function pointers to dynamically call the appropriate sorting function.
Input Format:
● N: The number of players.
● N space-separated integers representing the scores.
● 1 for ascending order OR 2 for descending order.
Sample Input:
5
200 150 450 300 400
2
Sample Output:
450 400 300 200 150
Problem 2: Custom Sorting for an E-commerce Website 🛒
Problem Statement:
An e-commerce website allows users to sort products based on:
1. Price (low to high)
2. Price (high to low)
3. Rating (high to low)
Implement a program that:
1. Accepts N products, each with price and rating.
2. Allows the user to choose sorting criteria.
3. Uses function pointers to dynamically call the appropriate sorting function.
Input Format:
● N: Number of products.
● N lines with each containing price rating.
● 1 for sorting by price ascending, 2 for price descending, 3 for rating descending.
Sample Input:
4
1000 4.5
500 4.2
750 4.7
1200 4.3
1
Sample Output:
500 4.2
750 4.7
1000 4.5
1200 4.3
2. Nested Loops-Based Problems (5 Detailed Problems)
Problem 3: Maze Generator for Disneyland’s Treasure Hunt
Problem Statement:
Disneyland is creating an interactive maze game where users navigate through 0s (open path)
and 1s (walls).
● The maze should be randomly generated.
● The entry is always at (0,0) and the exit is at (N-1, N-1).
● Users must navigate from start to exit.
Input Format:
● N: The size of the maze (N x N).
Sample Input:
5
Sample Output:
S0110
10101
10001
11011
0100E
Problem 4: Seating Arrangement for a Concert
Problem Statement:
A concert hall has M rows and N columns of seats.
● VIP guests sit in odd rows while regular guests sit in even rows.
● Generate a seating chart where:
○ V represents VIP seats
○ R represents Regular seats
Input Format:
● M (rows)
● N (columns)
Sample Input:
45
Sample Output:
VVVVV
RRRRR
VVVVV
RRRRR
3. Sorting Problems Without Pyramid (5 Detailed
Problems)
Problem 5: Marathon Leaderboard Sorting 🏃
Problem Statement:
In a marathon race, runners are ranked based on their completion time.
● The system allows sorting by:
1. Fastest first
2. Slowest first
3. Alphabetical order of runners
Input Format:
● N: Number of runners
● N lines containing RunnerName TimeInMinutes
● 1 for sorting by fastest first, 2 for slowest first, 3 for name order.
Sample Input:
3
Alice 120
Bob 110
Charlie 130
1
Sample Output:
Bob 110
Alice 120
Charlie 130
Problem 6: Sorting a Bank Statement 🏦
Problem Statement:
A bank provides its customers an option to sort their transactions:
1. By transaction amount (low to high)
2. By transaction amount (high to low)
3. By date (earliest to latest)
Input Format:
● N: Number of transactions
● N lines containing TransactionID Amount Date
● 1 for amount (low to high), 2 for amount (high to low), 3 for date order.
Sample Input:
4
T001 500 2024-01-10
T002 300 2024-01-05
T003 1000 2024-01-15
T004 700 2024-01-08
1
Sample Output:
T002 300 2024-01-05
T001 500 2024-01-10
T004 700 2024-01-08
T003 1000 2024-01-15
4. Matrix-Based Problems (5 Detailed Problems)
Problem 7: Rotating an Image in a Photo Editing App 🖼️
Problem Statement:
A photo editing app allows users to rotate an image clockwise (90°) or counterclockwise
(-90°).
● The image is represented as an N x N matrix.
Input Format:
● N: Size of the image matrix
● N x N matrix elements
● 1 for clockwise rotation, 2 for counterclockwise rotation
Sample Input:
3
123
456
789
1
Sample Output:
741
852
963
Problem 8: Pathfinding in a Grid for a Self-Driving Car 🚗
Problem Statement:
A self-driving car must find the shortest path from a starting point (S) to a destination (D) in
an N x N grid.
● 0 represents open roads.
● 1 represents obstacles.
Input Format:
● N: Grid size
● N x N matrix
Sample Input:
5
S0100
00110
10001
11101
D0000
Sample Output:
Shortest path: Right → Down → Down → Right → Down
1. Function Pointer-Based Sorting Pyramid 🏗️
Problem Statement:
Alex wants to create a dynamic pyramid where numbers are sorted based on a chosen
sorting function. Implement a program that:
1. Takes a list of numbers.
2. Lets the user choose a sorting method (Ascending or Descending).
3. Uses function pointers to dynamically sort the list.
4. Prints the sorted numbers in a pyramid format.
Input Format:
● n (total count of numbers; must be sum of 1+2+3...+k).
● n space-separated integers.
● 1 for ascending order OR 2 for descending order.
Example Input:
10
5 3 9 1 8 4 6 10 7 2
Example Output (Ascending Pyramid):
2 3
4 5 6
7 8 9 10
Concepts Tested:
✅ Function pointers for sorting
✅ Nested loops for pyramid printing
✅ Dynamic function execution
2. Matrix Rotation Using Function Pointers 🔄
Problem Statement:
A game board in Disneyland allows players to rotate the board either clockwise or
counterclockwise. Implement a program that:
1. Accepts an NxN matrix.
2. Lets the user choose rotation direction.
3. Uses function pointers to call the appropriate function for rotation.
4. Displays the rotated matrix.
Input Format:
● N (matrix size, N x N).
● N*N space-separated integers.
● 1 for clockwise rotation, 2 for counterclockwise rotation.
Example Input:
123
456
789
Example Output (Clockwise Rotation):
741
852
963
Concepts Tested:
✅ Function pointers for different transformations
✅ Nested loops for matrix manipulation
✅ Understanding of 2D arrays
3. Recursive Triangle Sum Pyramid
Problem Statement:
The Magic Triangle game in Disneyland allows players to generate a pyramid where each row
contains the sum of two adjacent numbers from the row below. Implement a recursive
function to generate this pyramid.
Input Format:
● n (number of elements in the bottom row)
● n space-separated integers.
Example Input:
12345
Example Output:
35
15 20
6 9 11
3 3 4 5
1 2 3 4 5
Concepts Tested:
✅ Recursion for pyramid generation
✅ Function with pointers to modify arrays
✅ Nested loops for formatting
4. Dynamic Pascal’s Triangle Generator
Problem Statement:
Tinkerbell found an ancient book that generates Pascal's Triangle dynamically using function
pointers. Implement a program that:
1. Accepts an integer n (number of rows).
2. Uses a function pointer to compute binomial coefficients.
3. Prints Pascal’s Triangle.
Input Format:
● n (number of rows).
Example Input:
Example Output:
11
121
1331
14641
Concepts Tested:
✅ Function pointers for binomial coefficient calculations
✅ Nested loops for formatting
✅ Understanding of combinatorics
5. Zigzag Waveform Pattern Generator
Problem Statement:
In Disneyland’s Hall of Mirrors, there is a zigzag reflection pattern. Implement a program that:
1. Accepts a list of n numbers.
2. Uses a function pointer to sort the list in alternating increasing-decreasing order.
3. Prints the numbers in a zigzag waveform.
Input Format:
● n (total count of numbers; must be sum of 1+2+3...+k).
● n space-separated integers.
Example Input:
10
5 3 9 1 8 4 6 10 7 2
Example Output:
10
2 9
3 8 4
6 1 7 5
Concepts Tested:
✅ Function pointers for sorting logic
✅ Nested loops for zigzag formatting
✅ Understanding of alternate sorting techniques