Data Structures and Algorithms

Group Members:

-Naman Vohra

-Ikhsan Maulana

Problem Description

The problem which arises when designing a movie booking system is deciding which data structures are suitable for the program to run efficiently. In this case, our group must think of a way to achieve the goal of managing and storing seat details with minimum memory possible. Apart from that, we must ensure that related data (movie name, it’s timing, and the seats) are “interconnected” with each other to avoid mixing of data which can lead to confusion. Lastly, a minor problem is storing user names in alphabetical order.

Proposed Solution

Figure 1. Initializing vectors of type viewSeats.
Figure 2. Inserting the movie name and its corresponding vectors of type viewSeats to the map.

We believe that using a vector is an efficient way of storing the seats that have been booked through the viewSeats. The viewSeats is a class that shows the user how many seats are currently available, and books the available seats that the user wants. If the seat is already booked, the viewClass will show a “[x]” on the booked seat to indicate that the seat is not available and has already been booked by another person.  The data structure implemented by this class is a doubly circular linked where each node represents a single seat and stores the details associated with it (such as the row name, seat number, and seat availability).

It is given that each time for each movie has different available seats. For example, seat A-13 for Avengers at 3 pm is available, but that doesn’t mean that seat A-13 for Avengers (or any other movie) at 1 pm is also available. Therefore, for each timing in each movie, an object of the viewSeats is called, and their object is stored on their movie’s vector. For example, Avengers has a screening time of 12 pm, 5 pm, and 10 pm. This would mean that 3 objects of viewClass is made and is stored on vector<viewSeats> seatsAvengers.

But the storing of the booked seats doesn’t stop there. After using the vector we decided to also use a map in order to store both the movie name and its (booked) seats. The map stores the movie’s name as its key, then the vector that stores all booked seats for the movie as its value.

Figure 3. The Hash class.

Lastly, to store the user names in alphabetical order, our group designed a simple hash function, which is the ASCII value of the first letter in username subtracted by 65. Now, let us look at how this works. We know that the ASCII value of A is 65 and the ASCII value will increment by 1 as we move down the alphabet (B will have ASCII value of 66, C will have ASCII value of 67, and so on) and if we subtract it with 65, it will result in values like 0 (which will be the index for storing account details which have username starting with letter A), 1 (for B as 66-65 = 1) making the index much clearer and less confusing. Moreover, we are sure that the size of the array can be fixed before running the program and that it won’t change. It will have 25 indexes starting with 0 (storing usernames starting with A-Z), as there 26 alphabets.

My Contribution

  • Came up with the idea of utilizing the map as it uses a key that can be used to represent the movie name. The key can be accessed to retrieve the value which stores the details (available seats at different move timings) of the corresponding movie.
  • Created the viewSeats class with my partner.
  • Developed the Hash class which validates the username and password of the user trying to log in. It implements the hashing with chaining concept so that a particular key can store multiple values, for example, key/index 0 which represents the letter “A” can store all the usernames starting with the letter A, and so on. By doing this, collision is avoided. This class also registers new users and delete their accounts if the users choose to. Lastly, it can display the details of all the registered users.
  • Created the Info class. Objects of the Info class stores the personal information (username and password) of the user. The Hash class utilizes these objects.

Further Details

The complete code can be seen in the following link:

https://github.com/NamanV19/Movie-Booking-System

https://github.com/NamanV19/Movie-Booking-System

Comments are closed.