1 / 4

Rearranging Trains

Engine. Train cars. Track. B. A. D. C. Sorted order. D. C. B. A. Stub or lead. B. A. D. C. B. A. D. C. Stub or lead. Stub or lead. C. A. B. D. C. A. B. D. Siding. Rearranging Trains. Stack or LIFO data structure in CE.

finn-bowman
Télécharger la présentation

Rearranging Trains

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Engine Train cars Track B A D C Sorted order D C B A Stub or lead B A D C B A D C Stub or lead Stub or lead C A B D C A B D Siding Rearranging Trains Stack or LIFO data structure in CE Question: Is there an ordering that cannot be sorted using a stub? Devising a sorting algorithm Queue or FIFO Sorting Networks

  2. 2 C B A D 3 1 Delivering Train Cars in a Specific Order Cars in the train below have been sorted according to their delivery points. However, it is still nontrivial to deposit car A in stub 1, car B in stub 2, and car C in siding 3. Cars can be pulled or pushed by the engine. 2 3 1 2 3 1 Is there a better initial ordering of the cars for the deliveries in this puzzle? Sorting Networks

  3. B A 1 2 Train Passing Puzzle The trains below must pass each other using a siding that can hold only one car or one engine. Show how this can be done. Sorting Networks

  4. 5 10 8 12 5 8 10 12 2 5 6 7 0 1 2 3 2 6 7 14 8 10 12 14 6 14 2 7 4 5 6 7 4 15 9 1 1 4 9 15 0 1 3 4 8 9 10 11 9 11 13 15 0 3 11 13 11 13 3 0 12 13 14 15 4-sorter tests (4, 4)-merger tests (8, 8)-merger tests A 16-Input Sorting Network Use 4-input sorters, follow by (4, 4)-mergers, and end with an (8, 8)-merger Using the 0-1 principle, we can validate this network via 16 + 25 + 81 tests Sorting Networks

More Related