Develop an algorithm to simulate a single elevator

Assignment Help Data Structure & Algorithms
Reference no: EM132195734

Question: We are going to develop an algorithm and implement in C++ to simulate a single elevator in a 10-story building. There will be some simplifying assumptions that will make this a bit less complex than a real-world implementation. The number of floors is not important, nor is the number of people getting on or getting off the elevator. The following rules apply to movement of the elevator:

1. By default, the elevator will always begin to operate from the 1st floor.

2. The algorithm needs to support the 2 separate directions of up and down.

3. The algorithm needs to support the 2 separate requirements of "get on" and "get off".

4. Wherever the elevator happens to be, it always continues in the same direction, unless there are no passengers and no people waiting for the elevator with "get on" requests.

5. When the elevator stops moving in one direction, it checks to see if there are additional "get on" requests. The elevator does not move again until it receives a request to move.

6. Once the elevator starts to move, there can be no "get on" requests until the elevator has stopped and has no more pickups or drop-offs in the same direction. In other words, the elevator does not move in the opposite direction until you receive a request to move.

The approach to simulating the elevator is as follows:

1. The events that you will need to simulate are described below. The 2 event types are ‘GET ON' and ‘MOVE. Since they are fixed by me, you can populate them into an array if you like. Each event can have a maximum of 3 pieces of information, as described by #2.

2. ‘GET ON' has 2 parameters: the number of the floor on which a person or persons will enter the elevator and the number of the floor on which the person(s) will get off. ‘MOVE' has no parameters but you can assign 2 parameters with values of zeros so that the 2 events are parallel.

3. Implement the elevator as a doubly-linked list. When the elevator is moving up, it follows from the head to determine where to go to next. When it is moving down, it follows from the tail backwards.

4. When there are no more nodes in the same direction as the elevator is moving, it checks the array for its next requests and either moves or adds "get on" requests. It then continues to move in the same direction it was moving, if there are now requests for that direction, or it reverses direction to pick up people. If the entire list is empty, it returns to the 1st floor to wait.

5. The doubly-linked list nodes need to contain two items of information: a primary floor number to stop at and, for an arriving passenger, a secondary floor number representing the "get off". You cannot add the "get off" as a node until the passenger has gotten on. Otherwise, you may try to discharge a passenger who is not yet on the elevator.

6. To summarize, when you pick up a ‘GET ON' request, add it to the list, along with the ‘get off', as an additional parameter. When the ‘GET ON' is satisfied, you remove its node and add the ‘get off' node.

EVENT LIST

GET ON 4,6 (means a person wants to get on at 4 and get off at 6)

MOVE

GET ON 8,2

GET ON 1,5

GET ON 9,3

MOVE

GET ON 10,2

GET ON 7,4

MOVE

GET ON 1,7

MOVE

NOTE: "MOVE" makes the elevator move

(a) in the same direction if there are requests,

(b) in the opposite direction if there are requests or

(c) down to 1 if there are no requests in the list.

The output from this program should identify each of the elevator stops and whether people get off, get on, or both. You should produce output when you encounter a MOVE instruction. In other words, there should be 4 separate outputs, each identifying a set of floors and "get on" or "get off" actions.

Reference no: EM132195734

Questions Cloud

Examples of discrete data besides grades or blood type : What are some other examples of discrete data besides grades or blood type?
Confidence interval for the proportion of fatal accidents : A survey of 300 fatal accidents showed that 123 were alcohol related. Construct a 98% confidence interval for the proportion of fatal accidents
Difference between a census and a sampling : Explain the difference between a census and a sampling and describe the advantages and disadvantages of each.
Write description of the application and brief history : Each paper will be at least 10 full pages in length but no longer than 25 pages in length (do not number or count the title page, the pledge page.
Develop an algorithm to simulate a single elevator : We are going to develop an algorithm and implement in C++ to simulate a single elevator in a 10-story building. There will be some simplifying assumptions.
State the null and alternative hypotheses : (i) State the null and alternative hypotheses. (ii) What is an appropriate test statistic to use?
Investigate a specific natural disaster topic : The Paper utilizes professional health care knowledge and skills and applies those proficiencies to the context of quality improvement.
Create a step-by-step it security policy : Create a step-by-step IT security policy for handling user accounts/rights for a student who is leaving prematurely (drops, is expelled, and so on).
Create an entity relationship diagram : ITECH 1103 BIG DATA AND ANALYTICS - Entity Relationship Modelling - create an Entity Relationship Diagram using Crow's Foot notations

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Finding equation has no solutions mod m

Let the equation ax = b mod m, where x is unknown and a, b and m are given. Illustrate that this equation has either no solutions mod m, or d solutions mod m.

  How to sort using one of the additional algorithms

In addition, create a flowchart to show how to sort using one of the additional algorithms. Give the pseudocode for the flowchart as well.

  Discuss in detail the time complexity of your algorithm

Discuss (in detail) the time complexity of your algorithm. What can you say about the efficiency of your algorithm? Explain. Can you think of a better way to represent and add two polynomials? Explain.

  Show that there exists an election algorithm for hypercubes

Show that there exists an 0 (N log N) election algorithm for hypercubes without a sense of direction. Show that there exists an O(N(log N +k)) election algorithm for networks with bounded degree k

  Write an algorithm for testing primality

Write an algorithm for testing primality, i.e. given n, the algorithm must decide if n is a prime

  Question 1you are required to create a detailed analysis

question 1you are required to create a detailed analysis for each of the following array-based sorting algorithmsa

  Test your algorithm with various possible inputs

Test your algorithm with various possible inputs for a to make sure the algorithm works correctly (has no bugs) for a specific vector, a.

  Create the logic for a program that continuously prompts

Pass each entered amount to a conversion method that displays breakdown of the passed amount into the fewest bills; in other words, the method calculates the number of 20s, 10s, 5s, and 1s needed.

  Question about pure aloha

A group of N stations share a 56-kbps pure ALOHA channel. Every station outputs a 1000-bit frame on an average of once every one-hundred secs, even if the previous one has not yet been sent.

  Write a function that accepts an array of integers

Write a function that accepts an array of integers and the size of the array and prints out a table listing how many values in the array fall in each of the following ranges:

  Display the sorted list to the monitor

Your program should then sort the integers from small-est to largest using an if-else chain and then display the sorted list to the monitor.

  Review the brief intervention flow chart

Review the brief intervention flow chart. What would be easy for you to adapt and what would be more challenging for you to adapt as a SUD counselor

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd