Dear Loren Shure, many thanks for your great jobs! I'm a matlaber from China, could I share your excellent videos to my wechat chanel for educational purpose?
There are K cars which are going into a tunnel. You only know the order that they enter the tunnel and exit the tunnel. Try to find out how many cars (at least) violate the traffic law that to overtake in tunnel is forbidden. For example, Car 1, 2, 3, and 4 are entering and the order they exit is 2, 1, 3, and 4. Car 2 overtakes some car for sure. (maybe car 4 overtakes car 3 and then car 3 passes 4, which is not considered in this problem ) You should present your idea clearly. And draw a algorithm flow chart. Test a few examples with your matlab codes. (A report need to made including these three parts in a word documment). The complextiy analysis of this algorithm should be presented as well. (Hint: The problem can be sloved by a O(n) programme.