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 compute the compexity for the following code #include #include #include #include using

#include #include #include #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 hotels) { cout

for (int i = 0; i

// Sort Hotels data by name. void SortHotelByName(vector hotels) { cout

std::sort(hotels.begin(), hotels.end(), sortByBan);

for (int i = 0; i

// Sort Hotels by rating void SortHotelByRating(vector hotels) { cout

std::sort(hotels.begin(), hotels.end(), sortByr);

for (int i = 0; i

// Print Hotels for any city Location. void PrintHotelBycity(string s, vector hotels) { cout

if (hotels[i].location == s) {

cout

// Sort hotels by room Available. void SortByRoomAvailable(vector hotels) { cout

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 hotels) {

vector user; User u;

// 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 hotels;

// 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; }

Task 2: Complexity Analysis - Theoretically discuss and compute the complexity of all important algorithms that you implemented. The discussion will describe your understanding of the algorithm. Put the complexity on a table as shown in Table 1. Table 1: Complexity Analysis Algorithm Algorithm 1 Algorithm 2 Complexity O(log n) 0 (n)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!