DAT Deque (dakle ended Quese) A Dept is set List ADT with the restriction that elements can be inverted or removed at ei
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
DAT Deque (dakle ended Quese) A Dept is set List ADT with the restriction that elements can be inverted or removed at ei
366 17 311 ERARRASK 20 21 32 24 11 32 15 M Al 41 det deque to pythonlist (deque, target): Pops contents of deque into target. At the end, deque is empty. Front element of the deque is at the beginning of target, Rear element of deque is at end of target. use: dequeue to pythonlist (deque, target) Parameters: deque deque object (Deque) target a Python 11st (list) Returnst Mone def test Deque (source): Tests Deque implementation.. The methods of Deque are tested for both empty and non-pty deques using the data in source- Use: test Deque(source) Parameters List of data (List of 2) Returns Rope TOREK PENTIortant: TRIMIT
7. Design and implest ADT ed Deque (double-ended Quese) A Deqoe is similar to a List ADT with de etiction that eleonats cabe cated or ved at the end of the List (out or sex so the elements or be inserted or removed in the middle of the List. If you think about it, you will find out that a Deque provides the fictionalities of both Queed Stack ADTs. Here are the method of Deq ADT Frement inserts die dits cleather of De internet inserts the dets element at the De Proves the data element from the foot of Deque desit End the data elements the ro 20 wan the Deque wi peekEnd the dats element at the use of the Deque without regi Implement the methods so that they all take O(1) time. The methods are described in Deque_array.py module Test the methods from test_peque_array.py. To test the ADT. implement the following factions which are similar to the equivalent fiction for other ADTs and add them to the utilities py andle pythonlist to peque(deque, source) Deque to pythonlist (deque, target test Deque source) 1def pythoolist to deque (deque, source) Pushes contents of source oeto deques. At finish, source is empty. First element in source is at the end of eques, Last element in the source is in front of the dequest. the pythollit to dequeue(deque, source) Parameters deque deque object (Deque) source Python list (list) Returns nome 18 11 12 11 14 15 16 U
10 19 def deque to pythonlist(deque, target): www 20 Pops contents of deque into target. At the end, deque is empty. Front element of the deque is at the beginning of target, Rear element of deque is at end of target. Use: dequeue to pythonlist (deque, target) Parameters: deque deque object (Deque) target a Python list (list) Returns: None def test Deque (source): WAN Tests Deque implementation, The methods of Deque are tested for both espty and non-empty deques using the data in source Use: test Deque (source) Parameters: source list of data (list of ?) Returns: Mone 21 22 23 24 26 272 201 29 31 32 D M 35 37 23 80 41 42 43 M 45 46