






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







An algorithm is a set of instructions for solving a problem or accomplishing a task. One common example of an algorithm is a recipe, which consists of specific instructions for preparing a dish or meal. Bubble sort is a sorting algorithm that compares two adjacent elements and swaps them until they are in the intended order. Just like the movement of air bubbles in the water that rise up to the surface, each element of the array move to the end in each iteration. Therefore, it is called a bubble sort.The sorting is needed as the way to control the data as well as the method to visualize,such as in the hotel center,we can use the sort to print out the list of room from the most expensive one to the least.Since the number of is relative small,it does not cost too much power and time. Here are some problems in the hotel industry 1.To mark room that have been booked 2.To present highest value room 3.Show the rooms with the order from the least to the highest price. 4 .Search the room with the correct inventory.
The solutions for problem in the hotel business as example are the following: 1.To mark room that have been booked
To solve the first program we will construct the Boolean table,with each room either true for already booked or false for the opposite.Next move one by one from the first room to the last and print out all the rooms that are still available. 2.To present highest value room Each room will be a element in the list.Consider that the first room is the highest priced and move to the next room.If the next one is higher then the highest will be the second one,if not then pass and move on to the third room and so on until the end of the list.This can be show as the flow chart below
3.Show the rooms with the order from the least to the highest price. In this senerio,we will use the bubble sort that we discuss above.With the number is the price of the room.Next,simply print out the list in correct order.
search.Therefore,we need to find the approach that very cost effitive and maintain good accuracy.
we only need to search until we find the number close to that.
thousand then we close with the error of just 10%
,we need to keep in mind to maintain the program and testing since in the real world,even with 1% can change everything. The code below show the source code of the problem to find the highest price for the hotel in c#.With biggest refer to the highest price.
using System; class HelloWorld { static void Main() { int n=int. Parse(Console.ReadLine()); int[] list=new int[n]; for(int j=0;j<n;j++){ list[j]=int. Parse(Console.ReadLine()); } int biggest = list[0];//list refer to your list's name for(int i = 0;i < n;i++) { if(list[i] > biggest) { biggest = list[i]; } } //now biggest will be the biggest number of the list Console.WriteLine(biggest); } }
bigger number than the last one(we assume the 1st^ one is the biggest).Therefore after looping through all number,we can find the biggest number or the one with highest price. With C# we enter the number of elements in the array or the number of different prices.We need to keep in mind that we need to convert the input from string to number in c# with the command int.Parse() .Continue the process with looping the each elements of the array and enter the input that we like with Console.ReadLine and the loop for.