Assignment 3 PDF
Assignment 3 PDF
Assignment 3 PDF
Instructions:
1. Use either C/C++ for solving the assignment.
2. Throughout the assignment, n represents the number of rows, and N is the maximum
number of passengers.
3. Array index starts with 0 in C/C++.
4. RED color indicates the input in each test case.
Problem. Consider an aeroplane with a front door and a rear door, and the rear door is permanently
LOCKED (passenger is not allowed to go IN and OUT from the rear door). There are n number of
homogeneous rows in the flight, and each row is arranged with 6 seats and divided into two equal halves
(3 seats of each).
Example:
(window side) s1(A), s2(B), s3(C) | passenger entryway | s6(F), s5(E), s4(D) (window side)
Two steps are followed by a passenger to get a seat. First, a passenger searches for the row number that is
mentioned on the boarding pass (e.g., 15A: 15 is row number, and A is the seat ID of the respective
row). Second, a passenger can go either left or right as per the seat ID sequence. Second step is followed
after the first step. LIFO order is followed by each passenger for an Entry/Exit of the respective seat in
each halve (left or right). Similarly, LIFO order is followed by the passengers during a full Exit from the
flight based on ROW NUMBER, and a random row number passenger can be opted for SOLE
Entry/Exit .
Considering this scenario, write a program to implement a data structure for the flight with two
functions Entry() and Exit() for the passenger’s entry and exit into flight. In order to do this, the
following assumptions can be made.
1. A passenger can enter in the flight with a boarding pass of random ordered seat numbers.
2. A passenger can exit from the flight following a random order.
3. At a time only one passenger can be in/out.
4. A Passenger can be represented with an ID (e.g., P1).
5. Error messages should be shown if the passenger already exists on ENTRY.
6. Error messages should be shown if the passenger does not exist on EXIT.
7. Entry/Exit function must check the UPPER BOUND of the Passenger count < N(= n*6 )
(maximum value for N= 60)