Dsa Report
Dsa Report
SOCIETY’S
K. L. E. INSTITUTE OF TECHNOLOGY,
Opp. Airport, Gokul, Hubballi-580 027
Phone: 0836-2232681 Website: www.kleit.ac.in
Submitted By
Mr. Gagan Ashok Marer
(USN: 2KE23CS039)
Mr. G Bhuvan
(USN: 2KE23CS038)
Mr. Shivkumar S H
(USN: 2KE22CS138)
Mrs.Vijeeta Patil.
1
Department of Computer Science & Engineering
K. L. E. SOCIETY’S
K. L. E. INSTITUTE OF TECHNOLOGY,
Opp. Airport, Gokul, Hubballi-580 027
Phone: 0836-2232681 Website: www.kleit.ac.in
CERTIFICATE
Certified that the mini project work entitle “Cash Flow Minimiser” is a bonafide
work carried out by Mr. Gagan A M, G Bhuvan, Bhuvan Pattar, Shivkumar S H bearing
USN number 2KE23CS039, 2KE23CS038, 2KE23CS028, 2KE22CS138, in partial
2
ACKNOWLEDGEMENT
The mini project report on “Cash Flow Minimiser” is the outcome of guidance,
moral support and devotion bestowed on me throughout my work. For this I
acknowledge and express my profound sense of gratitude and thanks to everybody who
have been a source of inspiration during the project work.
First and foremost I offer my sincere phrases of thanks with innate humility to our
Principal Dr. Manu T M who has been a constant source of support and
encouragement. I would like to thank our Dean Academics Dr. Yerriswamy T for his
constant support and guidance. I feel deeply indebted to our H.O.D.Rajesh
Yakkundimath. for the right help provided from the time of inception till date. I
would take this opportunity to acknowledge our Guide Mrs.Vijeeta Patil.
who not only stood by us as a source of inspiration, but also dedicated his/her time for
me to enable me to present the project on time.
Last but not least, I would like to thank my parents, friends & well wishers who have
helped me in this work.
Mr.G Bhuvan
Mr.Bhuvan Pattar
Mr.Shivkumar S H
3
INDEX
1. INTRODUCTION....................................................................... 5
1.1 Project Overview
1.2 Introduction to Data Structures And Applications
1.3 Application of Data Structures in project
1.4 Flowchart and Algorithm
4
1. INTRODUCTION.
1. Product Management:
o Users can add, display, search, and delete products from the inventory.
Each product record includes a unique ID, name, price, and quantity.
The linked list structure facilitates efficient management of the
inventory by enabling dynamic addition and deletion of products.
5
1.2 Introduction to Data Structures and Algorithms (DSA):
2. Queue:
o A queue follows the First-In-First-Out (FIFO) principle and is perfect
for managing tasks that need sequential processing. In this project, a
6
queue is used for order management, ensuring that orders are processed
in the same order they were added, which mirrors real-world e-
commerce order processing.
3. Algorithms for Searching and Deleting:
o The project incorporates basic search and deletion algorithms to locate
products by ID and remove specific records from the inventory. These
algorithms demonstrate the practical application of DSA concepts in
building interactive, user-friendly applications.
7
orders, contributing to smoother operations and customer satisfaction.
3. Application of Algorithms for Search, Addition, and Deletion
o Search Algorithm: The search functionality allows users to locate
products based on specific criteria, such as ID. This is critical in
inventory management where quick retrieval of product details is
essential.
o Deletion Algorithm: The deletion algorithm in the linked list allows
products to be removed efficiently without affecting the overall
structure of the inventory, which is essential in maintaining data
integrity.
4. Scalability and Efficiency
o The use of linked lists and queues makes this system scalable, as new
products or orders can be added without significantly impacting
system performance. This scalability is essential in e-commerce
applications, where product lines and customer demand often grow
over time.
o Efficient data structures ensure that operations on large data sets (like
a vast inventory or high order volume) remain responsive and
manageable, improving user experience.
1.4 Algorithem and Flowchart
1. Compute the net amount for every person. The net amount for person ‘i’ can be
computed by subtracting sum of all debts from sum of all credits.
2. Find the two persons that are maximum creditor and maximum debtor. Let the
maximum amount to be credited maximum creditor be maxCredit and maximum
amount to be debited from maximum debtor be maxDebit. Let the maximum debtor
be Pd and maximum creditor be Pc.
3. Find the minimum of maxDebit and maxCredit. Let minimum of two be x.
Debit ‘x’ from Pd and credit this amount to Pc
4. If x is equal to maxCredit, then remove Pc from set of persons and recur for
remaining (n-1) persons.
5. If x is equal to maxDebit, then remove Pd from set of persons and recur for
remaining (n-1) persons.
8
9
2. Project Definition (Purpose and Scope)
Purpose:
The purpose of the E-commerce Project Management System is toIn liberalized electricity markets, it is
common for electricity retailing companies to purchase spot electricity through the central power
exchange and deliver it to their consumers (or demanders). On the other hand, power generation
companies place sales
orders on power exchange and produce electricity based on the executed volume. In this situation, their
profit or loss may depend on the cashflows defined by the product of spot electricity price and volume.
In this section, we introduce the minimum variance hedging problems to mitigate cashflow fluctuations
for power retailers and generators.
Scope:
The scope of this project covers the core functionalities required in a basic e-commerce
management system:
1. Inventory Operations:
o Adding Products: Users can input product details (ID, name, price,
quantity) to dynamically expand the inventory list.
o Displaying loans: The entire product inventory can be viewed, listing
each product's ID, name, price, and quantity.
o Searching for Products: Users can search for a specific product by ID,
allowing quick access to specific item details within the inventory.
o Deleting Products: Products can be removed from the inventory based
on their ID, which is useful for keeping the inventory up-to-date.
2. Order Management Operations:
o Enqueuing Orders: Products can be added to an order queue, simulating
a customer's order being placed.
10
o Dequeuing Orders: Orders are processed in a first-in-first-out manner,
ensuring that orders are handled in the order they were received.
o Viewing Order Queue: Users can view all orders in the queue, which
provides transparency and assists in tracking pending orders.
3. Data Structures and Algorithms:
o The project utilizes a linked list for inventory management, allowing
dynamic addition and deletion of products.
o A queue data structure is used to manage orders in a sequential
processing order.
o Basic algorithms for searching and deletion are applied to optimize
interactions with the inventory and orders.
Program Structure:
Begin by describing the core functions:
o addProduct: Adds a new product to the list.
o displayProducts: Displays all products in the list.
o searchProduct: Finds a product by ID.
o deleteProduct: Deletes a product from the list.
o enqueueOrder: Adds a product to the order queue.
o dequeueOrder: Processes an order (removes it from the queue).
o printQueue: Displays the current order queue.
Detailed Function Walkthrough with Test Cases:
For each function, describe how it works and give a test case.
Example Format for Each Function:
Function Name: addProduct
Purpose: Adds a new product to the linked list.
Input:
o Product ID: integer
o Product Name: string
11
o Product Price: float
o Product Quantity: integer
Algorithm:
o Allocate memory for a new product node.
o Populate the node with user inputs.
o Insert the node at the beginning of the list.
Test Case:
o Input:
Product ID: 101
Product Name: Laptop
Product Price: 75000.50
Product Quantity: 10
o Expected Output: "Product added successfully."
o Result: Product with ID 101 is added to the linked list and can be
displayed in the product list.
Function Name: searchProduct
Purpose: Searches for a product by ID in the linked list.
Input:
o Product ID: integer
Algorithm:
o Traverse the linked list to find the product with the specified ID.
o If found, display product details; otherwise, print "Product not found."
Test Case:
o Input: Product ID: 101
o Expected Output: "Product found: ID: 101, Name: Laptop, Price:
75000.50, Quantity: 10."
o Result: Displays the details of the product with ID 101 if it exists.
12
o Create a new queue node containing the product.
o If the queue is empty, set the front and rear pointers to this node.
o Otherwise, add it to the end of the queue and update the rear pointer.
Test Case:
o Input: Product pointer to the product with ID 101.
o Expected Output: "Product added to order queue."
o Result: Product is added to the queue and appears when printQueue is
called.
Testing Summary:
Briefly summarize the results of each test case, confirming that the program
works as expected for adding, deleting, and processing products.
13
2. Compiler:
o GCC (GNU Compiler Collection): The project is developed in C, and
GCC is commonly used for compiling C programs.
Windows: MinGW (Minimalist GNU for Windows) or Cygwin.
Linux/macOS: GCC is typically pre-installed, or it can be easily
installed via package managers like apt (Ubuntu) or brew
(macOS).
3. IDE/Text Editor:
o Code::Blocks: A popular free IDE for C/C++ development.
o Dev-C++: Another simple and lightweight IDE for C/C++.
o Visual Studio Code: A versatile and widely used text editor with C/C++
extensions.
o Vim/Emacs: For experienced users comfortable with terminal-based
text editors.
4. Libraries:
o The project uses basic standard C libraries such as:
stdio.h for input/output operations.
stdlib.h for dynamic memory allocation.
string.h for string manipulation functions.
5. Other Tools:
o Git: A version control tool for managing the source code and
collaborating with others.
o Textbook/Documentation: A reference for understanding data
structures and C programming (e.g., The C Programming Language by
Brian Kernighan and Dennis Ritchie).
4.3 Network Requirements (Optional)
Internet Connection: Not strictly required for the program to run but is
necessary for downloading and installing development tools or libraries.
14
5. Implementation
Program Code:
#include <stdio.h>
#include <stdlib.h>
// Sort the maxQ in descending order (credits) and minQ in ascending order (debits)
qsort(maxQ, maxCount, sizeof(Transaction), compareMax);
qsort(minQ, minCount, sizeof(Transaction), compareMin);
int owed_amount = 0;
if (transaction_value == 0) {
owed_amount = credit;
i++;
j++;
} else if (transaction_value < 0) {
owed_amount = credit;
maxQ[i].cash = -transaction_value;
i++;
j++;
} else {
owed_amount = -debit;
minQ[j].cash = -transaction_value;
i++;
j++;
}
// Function to calculate the minimum cash flow for the given graph
void minCashFlow(int n, int graph[n][n]) {
int balance[n];
calculateBalance(n, graph, balance);
16
solveTransaction(n, balance);
}
int main() {
// Test case 1
int graph1[3][3] = {
{0, 1000, 2000},
{0, 0, 5000},
{0, 0, 0}
};
printf("Solution 1 :\n");
minCashFlow(3, graph1);
// Test case 2
int graph2[5][5] = {
{2, 63, 0, 85, 49},
{0, 76, 0, 0, 27},
{0, 0, 0, 17, 0},
{73, 32, 50, 6, 71},
{0, 86, 0, 0, 10}
};
printf("Solution 2 :\n");
minCashFlow(5, graph2);
return 0;
}
17
Output:
Solution 1 :
Solution 2 :
18
6. snapshots
19
7.Conclusion
20
References (Textbook Names):
21
o
22