0% found this document useful (0 votes)
28 views11 pages

DSA Portfolio

The document is a student portfolio for Pola Gautam Sai, a BTECH CSE Data Science student, detailing their contact information, coursework, and project work related to Data Structures and Algorithms. It includes a ticket booking system implementation in C, a solution for finding the longest increasing path in a binary tree, and outlines their coding competition achievements. Additionally, it provides links to their LinkedIn and GitHub profiles.

Uploaded by

goutam300505
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)
28 views11 pages

DSA Portfolio

The document is a student portfolio for Pola Gautam Sai, a BTECH CSE Data Science student, detailing their contact information, coursework, and project work related to Data Structures and Algorithms. It includes a ticket booking system implementation in C, a solution for finding the longest increasing path in a binary tree, and outlines their coding competition achievements. Additionally, it provides links to their LinkedIn and GitHub profiles.

Uploaded by

goutam300505
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
You are on page 1/ 11

Student Portfolio

Pola Gautam Sai

Register Number: RA2311056010183


Mail ID: [email protected]
Department: BTECH CSE DATA SCIENCE
Year / Sem/ Section: II / III / AN1 – UB513

Subject Title: 21CSC201J Data Structures and Algorithms


Handled By: Dr Rajakane M

Email: [email protected]

LinkedIn: https://www.linkedin.com/in/pola-gautam-sai-597641288

GitHub: https://github.com/GautamSai05
Portfolio Website (if any): None
ELab Completion Status

Lab Experiment Completion status


SOLVED REAL WORLD PROBLEM / CONCEPTUAL TASK
Managing ticket bookings efficiently is essential for any ticketing system, as it affects customer satisfaction,
booking accuracy, and overall operational efficiency.
Step-by-Step Solution Outline

Data Structure Selection


• Primary Options: Array or Linked List.
• Array: Ideal for sequential data storage and fixed-size structures, providing constant-time access for
indexed elements.
• Linked List: Allows dynamic resizing, but is slower for indexed retrieval and less memory-efficient
for predictable-sized data.
• Choice: Since ticket data is fixed in size and needs indexed access (e.g., booking ID), an array is the
best choice.

Define Ticket Structure


• Create a struct Ticket to represent each ticket, including fields such as booking ID, customer name,
event name, date, seat number, and booking status (confirmed or pending).

Implement Core Operations


• Add Ticket: Insert each ticket record into the array. If the array is full, handle by resizing or
notifying the user of capacity limits.
• Retrieve Ticket: Retrieve by booking ID by searching through the array.
• Update Ticket: Locate the ticket by booking ID in the array and update necessary fields (e.g., seat
number or booking status).
• Delete Ticket: Mark the ticket as canceled by updating the booking status, or remove it by shifting
elements in the array.

Sort and Display by Specific Attributes


• For sorting by event date or seat number, copy tickets into a temporary array or vector and sort using
std::sort with custom comparators.

Optimize for Real-World Scale


• Error Handling: Handle cases like retrieving non-existent records, duplicate booking IDs, and full
array capacity.
• Scalability: Use a dynamically resizing array approach if the number of tickets may grow beyond
initial capacity.

CODE-

#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define TOTAL_SEATS 10 // Total number of seats


#define MAX_USERS 10 // Maximum number of users allowed

// Structure to store user information


struct User {
char name[50];
char username[50];
char password[50];
};

// Array to store seats; 0 for available, and index+1 of the user if booked
int seats[TOTAL_SEATS] = {0};
struct User users[MAX_USERS];
int num_users = 0; // Counter for registered users
int current_user = -1; // Index of the currently logged-in user (-1 means no one is logged in)

// Function to register a new user


void register_user() {
if (num_users >= MAX_USERS) {
printf("User limit reached. Cannot register more users.\n");
return;
}
struct User new_user;
printf("Enter your name: ");
scanf(" %[^\n]", new_user.name);
printf("Enter username: ");
scanf("%s", new_user.username);
printf("Enter password: ");
scanf("%s", new_user.password);

// Add new user to the users array


users[num_users] = new_user;
num_users++;
printf("Registration successful! You can now log in.\n");
}

// Function to log in a user


bool login_user() {
char username[50], password[50];
printf("Enter username: ");
scanf("%s", username);
printf("Enter password: ");
scanf("%s", password);

for (int i = 0; i < num_users; i++) {


if (strcmp(users[i].username, username) == 0 && strcmp(users[i].password, password) == 0) {
current_user = i; // Set current_user to logged-in user’s index
printf("Login successful! Welcome, %s.\n", users[current_user].name);
return true;
}
}
printf("Login failed. Incorrect username or password.\n");
return false;
}

// Function to book a seat


void book_seat() {
if (current_user == -1) {
printf("Please log in to book a seat.\n");
return;
}

int seat_num;
printf("Enter seat number to book (1-%d): ", TOTAL_SEATS);
scanf("%d", &seat_num);

if (seat_num < 1 || seat_num > TOTAL_SEATS) {


printf("Invalid seat number.\n");
return;
}

if (seats[seat_num - 1] == 0) {
seats[seat_num - 1] = current_user + 1; // Store the index+1 of the user
printf("Seat %d booked successfully under the name %s.\n", seat_num, users[current_user].name);
} else {
printf("Seat %d is already booked.\n", seat_num);
}
}

// Function to cancel a booked seat


void cancel_seat() {
if (current_user == -1) {
printf("Please log in to cancel a seat.\n");
return;
}

int seat_num;
printf("Enter seat number to cancel (1-%d): ", TOTAL_SEATS);
scanf("%d", &seat_num);

if (seat_num < 1 || seat_num > TOTAL_SEATS) {


printf("Invalid seat number.\n");
return;
}

if (seats[seat_num - 1] == current_user + 1) {
seats[seat_num - 1] = 0; // Mark the seat as available
printf("Seat %d booking canceled successfully.\n", seat_num);
} else {
printf("You cannot cancel this seat. It’s either not booked or booked by another user.\n");
}
}

// Function to display seat availability with booked seat information


void display_seats() {
printf("Seat Status:\n");
for (int i = 0; i < TOTAL_SEATS; i++) {
if (seats[i] == 0) {
printf("Seat %d: Available\n", i + 1);
} else {
printf("Seat %d: Booked by %s\n", i + 1, users[seats[i] - 1].name);
}
}
}

// Main function to handle the ticket booking system


int main() {
int choice;

while (1) {
printf("\n--- Ticket Booking System ---\n");
printf("1. Register\n");
printf("2. Login\n");
printf("3. Book Seat\n");
printf("4. Cancel Seat\n");
printf("5. Display Available Seats\n");
printf("6. Logout\n");
printf("7. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

switch (choice) {
case 1:
register_user();
break;

case 2:
if (current_user == -1) {
login_user();
} else {
printf("Already logged in as %s.\n", users[current_user].name);
}
break;

case 3:
book_seat();
break;

case 4:
cancel_seat();
break;

case 5:
display_seats();
break;

case 6:
if (current_user != -1) {
printf("Logging out %s.\n", users[current_user].name);
current_user = -1; // Logout the current user
} else {
printf("No user is currently logged in.\n");
}
break;

case 7:
printf("Exiting the system.\n");
return 0;

default:
printf("Invalid choice. Please try again.\n");
}
}

return 0;
}

CERTIFICATIONS (Coursera/edX/etc.)

Include any online courses, workshops, or certifications related to Dat Structures and
algorithms, problem-solving
NPTEL/HOTS QUESTIONS SOLUTION

Problem Statement:
Given a binary tree where each node contains an integer, find the longest path from the root
to any leaf node where the values in the path strictly increase. If there is no such path,
return 0.

Objective:
Implement a function that returns the length of the longest increasing path from the root to
a leaf node in the tree.
Solution Outline:
1. Use Depth-First Search (DFS) starting from the root node.
2. At each node, if the child node value is greater than the current node value,
continue down that path.
3. Track the length of the current path and update the maximum path length if a longer
path is found.
Complexity:
● Time Complexity: 0(N), where N is the number of nodes in the tree, as each node
is visited once.
● Space Complexity: O(H), where Hbis the height of the tree, for the recursive call
stack.
Code-
#include <iostream>
#include <algorithm>

struct TreeNode {
int val;
TreeNode *left, *right;
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
};

int longestIncreasingPath(TreeNode* node, int prevVal, int currentLength) {


if (!node) return currentLength;

if (node->val > prevVal) {


int leftPath = longestIncreasingPath(node->left, node->val, currentLength + 1);
int rightPath = longestIncreasingPath(node->right, node->val, currentLength + 1);
return std::max(leftPath, rightPath);
}

return currentLength;
}

int findLongestIncreasingPath(TreeNode* root) {


return longestIncreasingPath(root, INT_MIN, 0);
}

int main() {
TreeNode* root = new TreeNode(10);
root->left = new TreeNode(12);
root->right = new TreeNode(15);
root->left->left = new TreeNode(11);
root->right->right = new TreeNode(18);

std::cout << "Longest Increasing Path Length: " <<


findLongestIncreasingPath(root) << "\n";
return 0;
}

Conclusion-

This solution efficiently finds the longest path from the root to a leaf node where values
strictly increase by using Depth-First Search (DFS). By keeping track of each node’s value
and comparing it with the previous value in the path, the algorithm ensures that only paths
with strictly increasing values are considered

CODING COMPETITIONS

Any notable rankings or achievements in coding contests


(e.g., LeetCode, CodeChef, HackerRank, Codeforces, ICPC)
Signature of the Student

You might also like