Question
compute the compexity for the following code #include #include #include #include using namespace std; // Create class for hotel data. class Hotel { public: string
compute the compexity for the following code
#include
using namespace std;
// Create class for hotel data. class Hotel { public: string name; int roomAvl; string location; int rating; int pricePr; };
// Create class for user data. class User : public Hotel { public: string uname; int uId; int cost; };
// Function to Sort Hotels by // kl location bool sortByBan(Hotel& A, Hotel& B) { return A.name > B.name; }
// Function to sort hotels // by rating. bool sortByr(Hotel& A, Hotel& B) { return A.rating > B.rating; }
// Function to sort hotels // by rooms availability. bool sortByRoomAvalable(Hotel& A, Hotel& B) { return A.roomAvl
// Print hotels data. void PrintHotelData(vector for (int i = 0; i // Sort Hotels data by name. void SortHotelByName(vector std::sort(hotels.begin(), hotels.end(), sortByBan); for (int i = 0; i // Sort Hotels by rating void SortHotelByRating(vector std::sort(hotels.begin(), hotels.end(), sortByr); for (int i = 0; i // Print Hotels for any city Location. void PrintHotelBycity(string s, vector if (hotels[i].location == s) { cout // Sort hotels by room Available. void SortByRoomAvailable(vector std::sort(hotels.begin(), hotels.end(), sortByRoomAvalable); for (int i = hotels.size() - 1; i >= 0; i--) { cout // Print the user's data void PrintUserData(string userName[], int userId[], int bookingCost[], vector vector // Access user data. for (int i = 0; i // Print User data. cout for (int i = 0; i // Functiont to solve // Hotel Management problem void HotelManagement(string userName[], int userId[], string hotelName[], int bookingCost[], int rooms[], string locations[], int ratings[], int prices[]) { // Initialize arrays that stores // hotel data and user data vector // Create Objects for // hotel and user. Hotel h; // Initialise the data for (int i = 0; i // Call the various operations PrintHotelData(hotels); SortHotelByName(hotels); SortHotelByRating(hotels); PrintHotelBycity("kl", hotels); SortByRoomAvailable(hotels); PrintUserData(userName, userId, bookingCost, hotels); } // Driver Code. int main() { // Initialize variables to stores // hotels data and user data. string userName[] = { "U1", "U2", "U3" }; int userId[] = { 2, 3, 4 }; string hotelName[] = { "H1", "H2", "H3" }; int bookingCost[] = { 1000, 1200, 1100 }; int rooms[] = { 4, 5, 6 }; string locations[] = { "kl", "kl", "perlis" }; int ratings[] = { 5, 5, 3 }; int prices[] = { 100, 200, 100 }; // Function to perform operations HotelManagement(userName, userId, hotelName, bookingCost, rooms, locations, ratings, prices); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started