Question

Using the data structure concept of topological ordering, demonstrate using pseudocode (please don't provide the actual...

Using the data structure concept of topological ordering, demonstrate using pseudocode (please don't provide the actual codings) how you can implement an operation to schedule picking from the mobile storage rack during a delivery process in a warehouse.

Homework Answers

Answer #1

Approach to Solve the problem
You can solve this problem in multiple ways, here are few of them.

Starting from the Source Vertex
Let us consider the above graph for demonstration purpose. Here is the steps we need to follow.

First we need to choose one of the source vertices and the obvious choice is among A and D, we choose A.
Delete all the outgoing edges from A, so we will delete (A,E) and (A,B).
Now choose among the available vertices with no incoming edges, we have D and E, we choose D here.
Delete all the outgoing edges from D, so we will delete (D,B).
Now choose among the available vertices with no incoming edges, we have E and B, we choose E here.
Delete all the outgoing edges from E, so we will delete (E,F) AND (E,G).
Now choose among the available vertices with no incoming edges, we have B and F, we choose B here.
Delete all the outgoing edges from B, so we will delete (B,C).
Now choose among the available vertices with no incoming edges, we have F, we choose F here.
Delete all the outgoing edges from F, so we will delete (F,G).
Now choose among the available vertices with no incoming edges, we have G, we choose G here.
Delete all the outgoing edges from G, so we will delete (G,C).
Now choose among the available vertices with no incoming edges, we have C, we choose C here.
Delete all the outgoing edges from C, so we will delete (C,H).
Now choose among the available vertices with no incoming edges, we have H, we choose H here.
There is no more connected vertices, hence we are done with the algorithm.
Here is an animation of the above steps which will help you understand the steps pictorially
ANIMATION

Starting from the Sink Vertex
You can perform the above set of operations from the sink vertex and arrive to one of the topological ordering by deleting the incoming edges to the sink vertex.
The approach and number of steps mostly remains the same.
Remember that the best way to delete the edges incoming or outgoing from a vertex is to delete the vertex itself.

Pseudo Code
For the purpose of the Pseudo code and the source code, we would prefer that the graph is given to us as a adjacency list, where each list contains all the nodes coming out of a given vertex. For more on Adjacency List, please refer to my tutorial on Basics of Graph Theory

Also, I would like to start from the sink as it is easier to identify all the sink vertices in an adjacency list representation.

topologicalOrdering(Graph G)
if G is NULL
return
for v in vertex set of G
if v.adjancencyList is EMPTY
Q.add(v)
while !Q.EMPTY
T <- Q.dequeue
print T
for u in vertex set of G
if u = T
u <- NULL
if u.adjacencyList contains T
u.adjacencyList.remove(T)
if u.adjacencyList is EMPTY
Q.add(u)

This is just to explain the idea behind the topological sort. We can definitely improve on the running time and get rid of inner loops to a great extent by choosing the underlying data structure carefully. May be if each vertex contains the list of vertices predecessor vertices, it will reduce the running time significantly.

Source Code
private void topologicalOrdering(List graph) {
if (graph == null)
return;
Queue topologicOrder = new ArrayDeque();
// identifying all the sink vertices
for (Vertex v : graph) {
if (v != null && v.adjacencyList == null || v.adjacencyList.size() == 0)
topologicOrder.add(v);
}
while (!topologicOrder.isEmpty()) {
Vertex currentSink = topologicOrder.remove();
System.out.print(currentSink.identifier + " ");
for (Vertex v : graph) {
if (v != null && v.equals(currentSink))
v = null;
else if (v != null && v.adjacencyList != null && v.adjacencyList.contains(currentSink)) {
v.adjacencyList.remove(currentSink);
if (v.adjacencyList.size() == 0)
topologicOrder.add(v);
}
}
}
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using the following guidelines - Write two primary helper functions - one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) - each of which Take the array and its size as input params and return a bool. Print out a message "Entering <function_name>" as the first statement of each function. Perform the code to test whether every element of the array is a Prime number. Print out...
UPS COMPETES GLOBALLY WITH INFORMATION TECHNOLOGY United Parcel Service (UPS) started out in 1907 in a...
UPS COMPETES GLOBALLY WITH INFORMATION TECHNOLOGY United Parcel Service (UPS) started out in 1907 in a closet-sized basement office. Jim Casey and Claude Ryan—two teenagers from Seattle with two bicycles and one phone—promised the “best service and lowest rates.” UPS has used this formula successfully for more than a century to become the world’s largest ground and air package-delivery company. It’s a global enterprise with nearly 400,000 employees, 96,000 vehicles, and the world’s ninth largest airline. Today UPS delivers 16.3...
Analysis: This section should include the issue register as a bare minimum, but may include also...
Analysis: This section should include the issue register as a bare minimum, but may include also why-why diagrams, a Pareto chart, a waste table and/or value-added analysis table. Flow analysis or simulation of this case study might be possible but might require making a lot of assumptions given the provided data. The first part of the project: Introduction    Walmart has continued to retain the top position on the Fortune 500 list for a consecutive fifth year. The brand has...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the purchases and fixed assets business areas. Prepare a 12- to 16-slide presentation describing the purchases and fixed assets business areas. Be sure to incorporate speaker notes as well as appropriate visuals, graphics, fonts, etc. Include any associated risk in these areas. Describe specific internal controls that include authorization of transactions, segregation of duties, adequate records and documentation, security of assets, and independent checks and...
Please summarize the below article in approximately 100 words: Monumental function in British Neolithic burial practices...
Please summarize the below article in approximately 100 words: Monumental function in British Neolithic burial practices Ian Kinnes The high-risk rate of survival for the non-megalithic series of Neolithic funerary monuments, recently re-emphasized by Piggott (1973: 34), introduces a further variable into the deductive study of burial practices. In Britain and Europe the overall distribution of monumental forms present both lacunae and a marked preponderance of cairns over earthen mounds which are in ill accord with the known or predicted...
Asia’s e-commerce landscape has been booming in recent years. The swift adoption of smartphones and greater...
Asia’s e-commerce landscape has been booming in recent years. The swift adoption of smartphones and greater access to the internet has allowed consumers in the region to be a major force in the global digital economy. The expansion looks set to continue at a rapid pace. According to a November 2018 report by Fitch Solutions, e-commerce sales in the region are forecast to increase by 14.2% this year, with an estimated average annual increase of 14% over the medium term...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation....
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation. case:    W17400 APIGEE: PEOPLE MANAGEMENT PRACTICES AND THE CHALLENGE OF GROWTH Ranjeet Nambudiri, S. Ramnarayan, and Catherine Xavier wrote this case solely to provide material for class discussion. The authors do not intend to illustrate either effective or ineffective handling of a managerial situation. The authors may have disguised certain names and other identifying information to protect confidentiality. This publication may not be...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
After reading the following article, how would you summarize it? What conclusions can be made about...
After reading the following article, how would you summarize it? What conclusions can be made about Amazon? Case 12: Amazon.com Inc.: Retailing Giant to High-Tech Player? (Internet Companies) Overview Founded by Jeff Bezos, online giant Amazon.com, Inc. (Amazon), was incorporated in the state of Washington in July 1994, and sold its first book in July 1995. In May 1997, Amazon (AMZN) completed its initial public offering and its common stock was listed on the NASDAQ Global Select Market. Amazon quickly...