DSA Report.pdf

2,253 views 74 slides Sep 27, 2023
Slide 1
Slide 1 of 74
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74

About This Presentation

Data Structure Reports.


Slide Content

1

Annexure-I
DSA Self-paced
GeeksForGeeks
A training report
Submitted in partial fulfillment of the requirements for the award of degree of


Master Of Computer Application
(School of Computer Application)
Submitted to

LOVELY PROFESSIONAL UNIVERSITY
PHAGWARA, PUNJAB




From 06/06/23 to 08/22/23
SUBMITTED BY


Name of student: Navneet Kumar
Registration Number: 12219190


Signature of the student:

2

Annexure-II: Student Declaration

To whom so ever it may concern

I, Navneet Kumar, 12219190, hereby declare that the work done by me on “DSA” from
June, 2023 to August, 2023, is a record of original work for the partial fulfillment of the
requirements for the award of the degree, Master of Computer Application.




Navneet Kumar (12219190)

Signature of the student
Dated: 26
th
August, 2023

3
ACKNOWLEDGEMENT

Primarily I would like to thank God for being able to learn a new technology. Then I would
like to express my special thanks of gratitude to the teacher and instructor of the course
DSA Self-Paced from GeeksForGeeks who provide me the golden opportunity to learn a
new technology from home.

I would like to also thank my own college Lovely Professional University for offering
such a course which not only improve my programming skill but also taught me other new
technology.

Then I would like to thank my parents and friends who have helped me with their valuable
suggestions and guidance for choosing this course.

Last but not least I would like to thank my all classmates who have helped me a lot.










Date: 26/08/2023 Navneet Kumar

Reg no: 12219190

4


Summer Training Certificate

5










Table of Contents

S. No. Title Page
1 Cover Page 1
2 Declaration of the student 2
3 Acknowledgement 3
4 Training Certification from organization 4
5 Table of Contents 5
6 List of abbreviation 6
7 Introduction 7
8 Technology learnt 8
9 Reason for choosing DSA 18
10 Learning Outcome 19
11 Introducing of Mini project, designing Project and Code snippets

22
12 Bibliography 74

6


Abbreviation

 DSA: Data Structures and Algorithms.

7
INTRODUCTION

 The course name DSA stands for “Data Structures and Algorithms” and Self-paced
means, one can join the course anytime. All of the content will be available once
one gets enrolled. One can finish it at his own decided speed.
 What is Data Structure? Data Structure is a way of collecting and organizing data
in such a way that we can perform operations on these data in an effective way.
Data Structures is about rendering data elements in terms of some relationship, for
better organization and storage. For example, we have some data which has,
player's name "Virat" and age 26. Here "Virat" is of String data type and 26 is
of integer data type.
 What is Algorithm? An algorithm is a finite set of instructions or logic, written in
order, to accomplish a certain predefined task. Algorithm is not the complete code
or program, it is just the core logic(solution) of a problem, which can be expressed
either as an informal high-level description as pseudocode or using a flowchart

 This course is a complete package that helped me learn Data Structures and
Algorithms from basic to an advanced level. The course curriculum has been
divided into 8 weeks where one can practice questions & attempt the assessment
tests according to his own pace. The course offers me a wealth of programming
challenges that will help me to prepare for interviews with top-notch companies
like Microsoft, Amazon, Adobe etc.

8
TECHNOLOGY LEARNT

 Learn Data Structures and Algorithms from basic to an advanced level like:
 Learn Topic-wise implementation of different Data Structures & Algorithms as
follows
 Analysis of Algorithm

o
In this I learned about background analysis through a Program and its
functions.
 Order of Growth

o
A mathematical explanation of the growth analysis through limits and
functions.
o
A direct way of calculating the order of growth

 Asymptotic Notations

o
Best, Average and Worst case explanation through a program.

 Big O Notation

o
Graphical and mathematical explanation.

o
Calculation

o
Applications at Linear Search

 Omega Notation

o
Graphical and mathematical explanation.

o
Calculation.

 Theta Notation

o
Graphical and mathematical explanation.

o
Calculation.

 Analysis of common loops

o
Single, multiple and nested loops

9
 Analysis of Recursion

o
Various calculations through Recursion Tree method

 Space Complexity

o
Basic Programs

o
Auxiliary Space

o
Space Analysis of Recursion

o
Space Analysis of Fibonacci number

MATHEMATICS

 Finding the number of digits in a number.

 Arithmetic and Geometric Progressions.

 Quadratic Equations.

 Mean and Median.

 Prime Numbers.

 LCM and HCF

 Factorials

 Permutations and Combinations

 Modular Arithmetic
BITMAGIC
 Bitwise Operators in C++

o
Operation of AND, OR, XOR operators

o
Operation of Left Shift, Right Shift and Bitwise Not

 Bitwise Operators in Java

o
Operation of AND, OR

o
Operation of Bitwise Not, Left Shift

o
Operation of Right Shift and unsigned Right Shift

10
 Problem(With Video Solutions): Check Kth bit is set or not

o
Method 1: Using the left Shift.

o
Method 2: Using the right shift

RECURSION

Introduction to Recursion


Applications of Recursion


Writing base cases in Recursion

o
Factorial

o
N-th Fibonacci number

ARRAYS

 Introduction and Advantages

 Types of Arrays

o
Fixed-sized array

o
Dynamic-sized array

 Operations on Arrays

o
Searching

o
Insertions

o
Deletion

o
Arrays vs other DS

o
Reversing - Explanation with complexity

SEARCHING

 Binary Search Iterative and Recursive

 Binary Search and various associated problems

 Two Pointer Approach Problems
SORTING

11
 Implementation of C++ STL sort() function in Arrays and Vectors

o
Time Complexities

 Sorting in Java

 Arrays.sort() in Java

 Collection.sort() in Java

 Stability in Sorting Algorithms

o
Examples of Stable and Unstable Algos

 Insertion Sort

 Merge Sort

 Quick Sort

o
Using Lomuto and Hoare

o
Time and Space analysis

o
Choice of Pivot and Worst case

 Overview of Sorting Algorithms
MATRIX
 Introduction to Matrix in C++ and Java

 Multidimensional Matrix

 Pass Matrix as Argument

 Printing matrix in a snake pattern

 Transposing a matrix

 Rotating a Matrix

 Check if the element is present in a row and column-wise sorted matrix.

 Boundary Traversal

 Spiral Traversal

 Matrix Multiplication

12
 Search in row-wise and column-wise Sorted Matrix
HASHING

Introduction and Time complexity analysis


Application of Hashing


Discussion on Direct Address Table


Working and examples on various Hash Functions


Introduction and Various techniques on Collision Handling


Chaining and its implementation


Open Addressing and its Implementation


Chaining V/S Open Addressing


Double Hashing


C++

o
Unordered Set

o
Unordered Map


Java

o
HashSet

o
HashMap

STRINGS

 Discussion of String DS

 Strings in CPP

 Strings in Java

 Rabin Karp Algorithm

 KMP Algorithm
LINKED LIST
 Introduction

13
o
Implementation in CPP

o
Implementation in Java

o
Comparison with Array DS

 Doubly Linked List

 Circular Linked List

 Loop Problems

o
Detecting Loops

o
Detecting loops using Floyd cycle detection

o
Detecting and Removing Loops in Linked List

STACK

 Understanding the Stack data structure

 Applications of Stack

 Implementation of Stack in Array and Linked List

o
In C++

o
In Java

QUEUE


Introduction and Application


Implementation of the queue using array and LinkedList

o
In C++ STL

o
In Java

o
Stack using queue

DEQUE

 Introduction and Application

 Implementation

o
In C++ STL

14
o
In Java

 Problems(With Video Solutions)

o
Maximums of all subarrays of size k

o
ArrayDeque in Java

o
Design a DS with min max operations

TREE

 Introduction

o
Tree

o
Application

o
Binary Tree

o
Tree Traversal

 Implementation of:

o
Inorder Traversal

o
Preorder Traversal

o
Postorder Traversal

o
Level Order Traversal (Line by Line)

o
Tree Traversal in Spiral Form

BINARY SEARCH TREE

 Background, Introduction and Application

 Implementation of Search in BST

 Insertion in BST

 Deletion in BST

 Floor in BST

 Self Balancing BST

 AVL Tree

15
HEAP

 Introduction & Implementation

 Binary Heap

o
Insertion

o
Heapify and Extract

o
Decrease Key, Delete and Build Heap

 Heap Sort

 Priority Queue in C++

 PriorityQueue in Java
GRAPH
 Introduction to Graph

 Graph Representation

o
Adjacency Matrix

o
Adjacency List in CPP and Java

o
Adjacency Matrix VS List

 Breadth-First Search

o
Applications

 Depth First Search

o
Applications

 Shortest Path in Directed Acyclic Graph

 Prim's Algorithm/Minimum Spanning Tree

o
Implementation in CPP

o
Implementation in Java

 Dijkstra's Shortest Path Algorithm

o
Implementation in CPP

16
o
Implementation in Java

 Bellman-Ford Shortest Path Algorithm

 Kosaraju's Algorithm

 Articulation Point

 Bridges in Graph

 Tarjan’s Algorithm
GREEDY

Introduction


Activity Selection Problem


Fractional Knapsack


Job Sequencing Problem
BACKTRACKING
 Concepts of Backtracking

 Rat In a Maze

 N Queen Problem
DYNAMIC PROGRAMMING 
 Introduction

 Dynamic Programming

o
Memoization

o
Tabulation

TREE

 Introduction

o
Representation

o
Search

o
Insert

17
o
Delete

 Count Distinct Rows in a Binary Matrix
SEGMENT TREE 

Introduction


Construction


Range Query


Update Query



DISJOINT SET

 Introduction

 Find and Union Operations

 Union by Rank

 Path Compression

 Kruskal's Algorithm



 Improved my problem-solving skills by practicing problems to become a stronger
developer
 Practice problems
o
This track contains many practice problems for the users which are
considered important and must-do as far as Data Structure and
Algorithm is concerned


 Developed my analytical skills on Data Structures to use them efficiently

 Solved problems asked in product-based companies’ interviews

 Solved problems in contests similar to coding round for SDE role

18
“In order to be irreplaceable, one must always be efficient.”
Reason for choosing this technology

 With advancement and innovation in technology, programming is becoming a
highly in-demand skill for Software Developers. Everything you see around
yourself from Smart TVs, ACs, Lights, Traffic Signals uses some kind of
programming for executing user commands.



Data Structures and Algorithms are the identity of a good Software Developer.
The interviews for technical roles in some of the tech giants like Google,
Facebook, Amazon, Flipkart is more focused on measuring the knowledge of Data
Structures and Algorithms of the candidates. The main reason behind this is Data
Structures and Algorithms improves the problem-solving ability of a candidate to
a great extent.
 This course has video lectures of all the topics from which one can easily learn. I
prefer learning from video rather than books and notes. I know books and notes
and thesis have their own significance but still video lecture or face to face lectures
make it easy to understand faster as we are involved Practically.
 It has 200+ algorithmic coding problems with video explaind solutions.

 It has track based learning and weekly assesment to test my skills.

 It was a great opportunity for me to invest my time in learning instead of wasting
it here and there during my summer break in this Covid-19 panademic.
 This was a life time accessable course which I can use to learn even after my
training whenever I want to revise.

19
LEARNING OUTCOMES

Programming is all about data structures and algorithms. Data structures are used to hold
data while algorithms are used to solve the problem using that data.
Data structures and algorithms (DSA) goes through solutions to standard problems in
detail and gives you an insight into how efficient it is to use each one of them. It also
teaches you the science of evaluating the efficiency of an algorithm. This enables you to
choose the best of various choices.
For example, you want to search your roll number in 30000 pages of documents, for that
you have choices like Linear search, Binary search, etc. So, the more efficient way will
be Binary search for searching something in a huge number of data.
So, if you know the DSA, you can solve any problem efficiently.
The main use of DSA is to make your code scalable because
 Time is precious
 Memory is expensive


One of the use DSA is to crack the interviews to get into the product-
based companies
In our daily life, we always go with that person who can complete the task in a
short amount of time with efficiency and using fewer resources. The same things happen
with these companies. The problem faced by these companies is much harder and at a
much larger scale. Software developers also have to make the right decisions when it
comes to solving the problems of these companies.
For example, in an interview, your given a problem to find the sum of first N natural
numbers.
One candidate solves it by using loop like

Initialize sum = 0

for every natural number n in range 1 to N (inclusive):
add n to sum

20
sum is the answer

And you solve it using the sum of first N natural numbers is given by the formula:

Sum=N*(N+1)/2

Obviously, they will choose you over other one because your solution is more efficient.

Knowledge of data structures like Hash Tables, Trees, Tries, Graphs, and
various algorithms goes a long way in solving these problems efficiently and the
interviewers are more interested in seeing how candidates use these tools to solve a
problem. Just like a car mechanic needs the right tool to fix a car and make it run
properly, a programmer needs the right tool (algorithm and data structure) to make the
software run properly. So, the interviewer wants to find a candidate who can apply the
right set of tools to solve the given problem. If you know the characteristics of one data
structure in contrast to another you will be able to make the right decision in choosing
the right data structure to solve a problem.


Another use of DSA, if you love to solve the real-world complex
problems.
Let’s take the example of Library. If you need to find a book on Set Theory from a
library, you will go to the math section first, then the Set Theory section. If these books
are not organized in this manner and just distributed randomly then it will be frustrating
to find a specific book. So, data structures refer to the way we organize information on
our computer. Computer scientists process and look for the best way we can organize the
data we have, so it can be better processed based on input provided.
A lot of newbie programmers have this question that where we use all the stuff of data
structure and algorithm in our daily life and how it’s useful in solving the real-world
complex problem. We need to mention that whether you are interested in getting into the
top tech giant companies or not DSA still helps a lot in your day to day life.
Let’s consider some examples

 In Facebook you can represent your friends on facebook, friends of friends,
mutual friends easily by Graph.

21

“Data structure and algorithms help in understanding the nature of the
problem at a deeper level and thereby a better understanding of the
world.”
 If you need to keep a deck of cards and arrange it properly how would you do that? You will throw
it randomly or you will arrange the cards one over another and from a proper deck. You can use
Stack here to make a proper arrangement of cards one over another.
 If you need to search a word in the dictionary, what would be your approach? Do you go page by
page or you open some page and if the word is not found you open a page prior/later to one opened
depending upon the order of word to the current page (Binary Search).
The first two were a good example of choosing the right data structure for a real-world problem and the
third one is a good example of choosing the right algorithm to solve a specific problem in less amount of
time.

22

PART 1: INTRODUCTION


1.1 Synopsis Project

Our C++ mini project is the Hotel Booking System. The project is for the admin of the
hotel to manage the room and the booking details of customers and for the customer to book the
hotel room.

The type of data structures used in this system are sorting, linked list and queue. There
are several classes in this system which are customer, bill and hotel room class. The admin can
add, delete and check the availability of the hotel room with the linked list data structures which
add or delete the room to the list. The room types have single, double, premium and deluxe. The
customer can book, cancel the room and check the availability of the hotel room by updating the
linked list of rooms. They have to fill in their personal details in order to book the room. The
system updates the information of customers booking by linked list and sorts it by using the
sorting technique. The customer booking is added to the queue of pending booking. After the
customer booked the room, the admin can check the customer booking and review the booking
information. The admin needs to confirm the pending booking and provide the bill for the
customer by using queue data structure. The queue is for the pending booking to add to the bill
queue for confirmation of booking and delete the last pending booking if want to cancel.



1.2 Objective of The Project

● For admin to manage the details of hotel room, booking and customers
● To simplify the booking process of customer

23

PART 2: SYSTEM ANALYSIS AND DESIGN (USE CASE, FLOWCHART AND
CLASS DIAGRAM)

2.1 System Requirements

2.1.1 Use case diagram




Figure 1: Use case diagram for Hotel Booking System


2.1.2 Use Cases Description for Hotel Booking
System The system users are admin and
customer.


Actor Task

24

Admin The admin can add, delete and check the availability of the hotel room. The
admin also can change the room price. After the customer booked the
room, the admin can check the customer booking and review the booking

25


information. The admin needs to confirm the pending booking and provide
the bill for the customer.
Customer The customer can book, cancel the room and check the availability of
the hotel room. They have to fill in their personal details in order to book
the room.





2.1.3 Detail Description for Each Use Cases
The system has 6 main use cases


Use Case Purpose
Update room Update information of room includes the updated room price
by adding or deleting the room.
Check room availability View the room information and availability of the room
Change room price Change and update the price of each type of room
Check customer booking View the detail list of the customer’s booking
Review and confirm pending
booking
Show all the details of the customers and the room before
confirm the booking
Book room Book the room and fill in their personal details by adding the
booking to the booking list.
Cancel room Make cancellation of their booking by deleting the booking
from the booking list.

26

2.2 System Design

FlowChart 1: Add room (Admin - Update room)



Explanation based on flowchart 1:


The data structure applied in this flowchart is insertion sort and linked list. The user is required
to enter the room number that he/she wants to add to the system. It will first check whether the
room number exists in the system or not. If the room number is unique, it will start the flow
chart. The flowchart starts with initializing room number=n, current index = 0, points the
current node to the head of the room linked list and the previous node set to NULL. The
flowchart is divided into two-part, insertion sort and add a node into the room linked list. In the

27

insertion sort part, it will find the correct position for the inserted node in ascending order of the
room number. The flow chart starts to point current nodes to the head of the linked list. If the
condition is true(the current node and the room number inserted by the user are greater than the
room number of the current node), the loop will continue by changing the
previousNode=currentNode, currentNode= the next of the current node and current
index=current index+1. The loop will continue until the condition is false. When the condition is
false, it will start the part to insert a node into the linked list. It starts with creating a new node.
If the current index is equal to 0, it is an empty linked list, the next of the new node is pointing
to the head(NULL) and the head is pointing to the new node. Otherwise, the next of the new
node is pointing to the next of the previous node and the next of the previous node is pointing to
the new node.

Prepared By: Navneet Kumar

28

FlowChart 2: Delete room (Admin - Update room)
Data Structure: Delete node in linked

29

Explanation based on flowchart 2:


Delete a room from the system including two parts. First, it checks whether the room exits in the
link list. If the first condition is true, it will continue to find the node in the linked list and delete
it. For the first part, it will initialize room number as n, current node is pointing to the head of the
linked list and current index equal to 1. If the current node and the room number of the current
node is not equal to the room number entered by the user, it will continue to loop by pointing the
current node to the next of the current node and increase the current index by 1. Once the loop is
done, it will check whether the current node is Null or not. If it is null, it will return zero,
otherwise, it will return the current node. For the second part, it will use the same theory as
explained before to find the node that contains the room number entered by the user and delete
the node. After delete the node, it will prompt a message of “You successfully delete the room
number(n)”. For the fail case(cannot find the corresponding node in the linked list), the system
will prompt an error message.

Prepared By: Navneet Kumar

30

FlowChart 3: Display room (Customer and Admin)
Data Structure:




Explanation based on flowchart 3:
For the function to print the room in the hotel, it will apply the data structure of display in the
linked list. The flowchart starts with initializing an integer to zero and pointing the current node
to the head of the linked list. The loop will start and continue with the condition that the current
node is not null. The loop will display the floor number, room number, room type, room price
and status availability of the room. The loop is changing the current node by pointing the current
node to the next node in the linked list and increasing the integer by 1. The loop is ended when
the condition is false(current node is null).

Prepared By: Navneet Kumar

31

FlowChart 4: Change price (Admin)
Data Structure: Delete node and find node in the linked list

32

Explanation based on flowchart 4:
For the change in the price of the room by the admin, First, it checks whether the room exists in
the linked list. If the first condition is true, it will continue to find the node in the linked list and
change the price. For the first part, the current node is pointing to the head of the linked list and
current index equal to 1. If the current node and the room number of the current node is not
equal to the room number entered by the user, it will continue to loop by pointing the current
node to the next of the current node and increase the current index by 1. Once the loop is done,
it will check whether it is the current node or not. If it is, it will return zero, otherwise, it will
return the current node. For the second part, if the room exists, it will let the admin input the
price that wants to change. The newNode points to the result of find room which is the first part
then the price of newNode points to the input price. After that, it will display the room number
and the changed price. If the room does not exist, it will let the user enter another room number
again.

Prepared By: Navneet Kumar

33

FlowChart 5: Check customer booking list (Admin)
Data Structure:




Explanation for flowchart 5:
Once the customer books a room from the system, it will create a customer linked list to store the
information of the customers with their corresponding booked room. Admin have a function of
checking the customer booking list in the system. If the customers cancel the room, the
customers records and their booked room will be deleted. The flowchart starts to initialize num
to zero and points the current node to the head. A loop will be started with a condition that the
current node is not null. Inside the loop, it will display the information in the customer node,
point the current node to the next node in the linked list, and increment num by 1. The flowchart
is ended when the condition of the loop is false and displays the total number of rooms in the
system.
Prepared By: Navneet Kumar

34

FlowChart 6: Review and confirm pending booking (Admin)
Data Structure: Queue

35

Explanation based on flowchart 6:


The review and confirm pending booking involve the implementation of a queue. The flowchart
of this module is mainly about the function of deQueue() that under the class billQueue. The
deQueue() function is used to remove and change the status of the rooms in the hotel. The new
billNode is dynamically allocated and assigned to pointer temp, the, frontPtr is assigned into
location pointed to by pointer temp.First, if the frontPtr is null, it will display to the user that
there is no pending booking for review. Else if the next pointer in billNode is not null, the system
will request the user to change the status of booking. To confirm the booking, the temp will be
assigned to be the next pointer of billNode, and frontPtr will be assigned to be temp which may
result in the pending booking to be removed from the queue. Or else if the case does not match
with the above condition, the system will request the user to change the status of booking and
only the status of the booking that is “CONFIRMED” will be removed from the queue.

Prepared By: Navneet Kumar

36

Flowchart 7: Book Room
Data Structure: linked list and queue

37

38

Explanation based on flowchart 7:
The book room implemented the linked list and queue.For the linked list implementation, first, it
checks whether the room number is exits.For the first part, it will initialize the current index
equal to 0, current node pointing to the head of linked list and previous node pointing to the
NULL of linked list. If the condition of current node and the room number are bigger than the
room number of the current node, it will continue looping by pointing previous node is equal to
the node and the current node is equal to the next of the current node and last increases the
current index by 1.For the second part, if the condition are false, the new node that reference to
the custnode is equal to the new room node. It will initialize the new node pointer to custname as
n, new node pointer to custphone as p, newnode pointer to ic are ic, newnode pointer to datein as
in, newnode pointer to dateout as out an newnode pointer to roomnum as rn.
It will continue the loop by pointing that the current index is equal to 0. If this condition are true,
it will continue looping by pointing the next of newnode equal to head and the head is equal to
the next of newnode and end the booking process.However, it will continue looping by pointing
the next of newnode is equal to the next of previous node if the condition is false.Then, it will
continue looping by pointing the next of the previous node equal newnode and end the booking
process.

For the implementation of queue, it initializes the room number as rn, price as p, ic number as ic,
number of days as days, datein as in, dateout as out, name as n and the temp reference to
billNode equal to new billNode.If the back pointer of the queue equal to NULL, it will continue
looping by pointing the temp point to next equal to NULL.Then,user needs to insert the
information of the customer into the temp node and front pointer of the queue equal to back
pointer of the queue equal to temp.It will end the process or continue regarding the choice of
user. However, if the back pointer of the queue is not equal to NULL, the next of the back
pointer in the queue equal to temp.Then, user needs to insert the information of the customer into
the temp node, the back pointer of queue equal to temp and last ended the flowchart.

Prepared By: Navneet Kumar

39

Flowchart 8: Cancel Room
Data Structure: Delete node in linked list

40

Explanation based on flowchart 8:
For the cancel booking room function, it will first start the find room function and check the
room number entered by the user exits in the system and check whether the room is booked. It
will only start the flowchart above(delete the customer node in the customer linked list) if the
condition(the room exists and is booked) is true. The flowchart will initialize current index as 1
and string rn as the room number. It will point the previous node as NULL, and point the current
node to the head of the linked list. It will start a condition to find the position of the finding node
by comparing and checking the room number entered by the user. The loop will be continued by
pointing previous node to the current node, pointing the current node to the next of the current
node and increasing the current index by 1. After the loop is done it will check whether the ic
entered by the user is the same with the ic in the found node. If the condition is true, it will start
to point the current node to the next of current node(found node in middle or last of the linked
list) or point the head to the next of the current node(found node in the first of the linked list)
and delete the node. It is done with delete customer nodes in the customer linked list. Lastly, it
will change the status of the room node to “available” if the delete customer node process is
successful.

Prepared By: Navneet Kumar

41

PART 3: SYSTEM PROTOTYPE

Below are some of the interfaces of our hotel booking system prototype. The users include
admin and customer, therefore the interfaces below will be divided based on each user.





Screen 1: Hotel Booking menu


Screen 1:The user needs to enter the integer value in the range of 1 to 3.If the user enter 1 ,
user will login as an admin, and if user enter 2 will login as a customer and if user enter 3 it will
exit the program. Otherwise, the program will prompt invalid choice and the screen will display
again after the user presses any key.

Prepared By; Navneet Kumar

42



Screen 2: Admin Menu


Screen 2: If the user enters integer 1 after choosing admin, it will display an admin menu.The
user needs to enter the integer value in the range of 1 to 7 according to what choices they want. If
the user enters the other number, the system will prompt invalid choice and the screen will
display again after the user presses any key.


Prepared By: Navneet Kumar

43



Screen 3: Admin - Adding room

Screen 3: For choice 1, if the user enters a new room number, it will display a successful
message. If the user enters an existing room number, it will display an error message and request
the user to try another room number. After that, it will display an option to have or not for
continuing the adding room process. If wanted, enter 1 else enter 0 if not interested to continue
adding. The screen of the admin menu will display again after the user presses any key.
Prepared By: Navneet Kumar

44



Screen 4: Admin - Deleting room


Screen 4: For choice 2, it will allow the user to enter a room number to delete a room. If the user
enters an existing room number, it will display a successful message or else it will request the
user to enter another room number. After that, it will display an option to have or not for
continuing the deleting room process. If wanted, enter 1 else enter 0 if not interested to continue
deleting. The screen of the admin menu will display again after the user presses any key.


Prepared By: Navneet Kumar

45



Screen 5: Admin - Displaying rooms in the hotel

Screen 5: For choice 3 of admin, it will display the rooms in the hotel and their status. The
details of the room in the hotel included floor, room number, room type, price and status of
availability. If the user enters any key, the system will prompt to the admin menu.
Prepared By: Navneet Kumar

46



Screen 6: Admin - Change price of the rooms
Screen 6: User needs to insert a room number that wants to change price. After that, the user
needs to insert a new price for the related room number. Then, the system will display a
successful message on the screen. Users need to enter 0 or 1 to continue or not for changing the
room price.
Prepared By: Navneet Kumar





Screen 7: Admin - Checking booking list

47

Screen 7: The system will show all the booking details of the customer. Admin able to check
with the existing booking and the customer details. Users need to enter any key to continue.
Prepared By: Navneet Kumar





Screen 8: Admin - Reviewing and confirm booking


Screen 8: The system will show all the bookings that need to be confirmed. To change the status
of booking, the user needs to enter the integer value in the range of 0 to 2 where 0 is pending, 1
is confirmed and 2 is cancelled.

Prepared By; Navneet Kumar

48





Screen 9: Customer Menu


Screen 9: The user needs to enter the integer value in the range of 1 to 4 according to what
choices they want. If the user enters the other number, the system will prompt invalid choice and
the screen will display again after the user presses any key.

Prepared By: Navneet Kumar

49



Screen 10: Customer - Displaying room in the hotel

Screen 10: It will display all the rooms in the hotel. The details of the room in the hotel included
floor, room number, room type, price and status. If the user enters any key, the system will
prompt to the customer menu.


Prepared By: Navneet Kumar

50



Screen 11: Customer - Booking a room

Screen 11: It will display a successfully booked message if the user entered the matched room
number in the hotel. After that, users need to enter their personality such as their name, phone
number, number of ic, date check in and date check out with the correct format.Then, it will
display “please proceed to the bill at the counter”. Users will then need to enter 1 or 0 to continue
or not for their booking.


Prepared By: Navneet Kumar

51



Screen 12: Customer UNABLE cancelling the room

Screen 12: If the user enters the room that wishes to cancel is invalid, then the system will
display a record not found and unable to make cancellation. After that, the user needs to enter 1
for continuing or 0 quit the cancellation process.
Prepared By: Navneet Kumar



Screen 13: Customer SUCCESSFULLY cancelling the room

Screen 13: User needs to enter the room that wishes to cancel is valid, then the system will
display successfully cancelled. After that, the user needs to enter 1 to continue or 0 to stop the
cancellation process.
Prepared By: Navneet Kumar

52

PART 4: SYSTEM TESTING

1. Test Case Matrix for the Book Room By Customer Use Case


Scenario Custome
r Name
Expected
Result
Test Result
1. Successfully
Booking
Jane Successfully
booked
message
displayed and
request for
continue
Successfully
booked
message
displayed
and request
for continue
2. Successfully
Booking
WC
Chiam
Successfully
booked
message
displayed and
request for
continue
Successfully
booked
message
displayed
and request
for continue
3. Unidentified
room
number
N/A Error message
displayed and
request for
continue
Wrong room
number


2. Test Case Matrix for the Cancel Room By Customer Use Case

Scenario Expected Result Test Result
1. Successfully
cancelling the
room
Booking room is
successfully
cancelled
Booking room with
room number under
customer with IC has
been deleted.
2. Unidentified room
number
Error messages and
back to customer
menu
Error: Record cannot
be found
unable to make
cancellation
3. Unidentified IC Error messages and
back to customer
menu
Error: Record cannot
be found
unable to make
cancellation

53



3. Test Case Matrix for the Update Room By Admin Use Case

Scenario Expected Result Test Result
1. Successfully add a
new room
Successfully added
message displayed and
request for continue
Successfully added message
displayed and request for
continue

Adding an existing
room
Error message displayed
and request for continue
Error: The room exists.
2. Successfully delete a
room
Successfully added
message displayed and
request for continue
Successfully deleted message
displayed and request for
continue
3. Unidentified room
number to be delete
Error message displayed
and request for continue
Error: The room number cannot
be found




4. Test Case Matrix for the Change Room Price By Admin Use Case

Scenario Price (RM) Expected Result Test Result
1. Successfully changed
a room price
100 Successfully changed
message displayed and
request for continue
Successfully changed
message displayed
and request for
continue
2. Unidentified room
number
400 Error message
displayed and request
for continue
Error: The room
number cannot be
found

54



5. Test Case Matrix for the Check Room Availability Use Case

Scenario Expected Result Test Result
1. Successfully checked room
availability
Floor number, room number,
room type, room price and
room availability are displayed.
Floor number, room number,
room type, room price and room
availability are displayed.


6. Test Case Matrix for the Check Customer Booking Use Case

Scenario Expected Result Test Result
1. Successfully checked
customer booking list
Customer name, room no.,
phone no., IC, date in, date out
and number of rooms are
displayed.
Customer name, room no., phone
no., IC, date in, date out and
number of rooms are displayed.
2. No customer book the room No record of customer booking
list
No record of customer booking
list




7. Test Case Matrix for the Review and Confirm Pending Booking By Admin Use
Case




Scenario Status Expected Result Test Result
1. Review and confirm
the pending
booking (0-
PENDING
1- CONFIRMED
2- CANCELLED)
1 Customer name, IC, booking
room no., date check in, date
check out, number of days, room
price per night and total room
price are displayed.
The status of room availability
changed.
Customer name, IC, booking
room no., date check in, date
check out, number of days,
room price per night and total
room price are displayed.
The status of room availability
changed.
2. No pending booking N/A No record of customer booking
information
No record of customer
booking information

56

PART 6 : APPENDIX HARDCOPY OF SOURCE CODE

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

APPENDIX V: PEER REVIEW ASSESSMENT



Team member
name:
Cooperative
(1-min, 5-max)
Hardworking
(1-min, 5-max)
Punctuality
(1-min, 5-max)
Knowledge
Sharing
(1-min, 5-max)
Good
personality
(1-min, 5-max)
Goh Jo Ey 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
Ng Jing Er 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
Ong Yin Ren 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
TOTAL 15 15 15 15 15





Team member
name:
Cooperative
(1-min, 5-max)
Hardworking
(1-min, 5-max)
Punctuality
(1-min, 5-max)
Knowledge
Sharing
(1-min, 5-max)
Good
personality
(1-min, 5-max)
Chiam Wooi Chin 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
Ng Jing Er 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
Ong Yin Ren 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
TOTAL 15 15 15 15 15

74



Team member
name:
Cooperative
(1-min, 5-max)
Hardworking
(1-min, 5-max)
Punctuality
(1-min, 5-max)
Knowledge
Sharing
(1-min, 5-max)
Good
personality
(1-min, 5-max)
Goh Jo Ey 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
Chiam Wooi Chin 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
Ong Yin Ren 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
TOTAL 15 15 15 15 15





Team member
name:
Cooperative
(1-min, 5-max)
Hardworking
(1-min, 5-max)
Punctuality
(1-min, 5-max)
Knowledge
Sharing
(1-min, 5-max)
Good
personality
(1-min, 5-max)
Goh Jo Ey 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
Ng Jing Er 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
Chiam Wooi Chin 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
TOTAL 15 15 15 15 15

76
BIBLIOGRAPHY

 Google

 GeeksforGeeks website

 GeeksforGeeks DSA self-paced Course
Tags