queues thequeuea
play

Queues TheQueueA collection of " that " container A - PowerPoint PPT Presentation

Queues TheQueueA collection of " that " container A stores a insertion and removal in with items " first - in - first - out " order . push pop 49 Stack : -1% Queue : & : : : degueae engaeae Basic


  1. Queues

  2. TheQueueA collection of " that " container A stores a insertion and removal in with items " first - in - first - out " order . push pop 49 Stack : -1% Queue : & • : : : degueae ④ engaeae Basic operations : back of to the an item add : en queue list the an item from the remove degueue : of the list . front

  3. Example : Palindrome Checking . aab aba ✓ × : IT an array In j si i i stack with and queue : a { I. read symbols , storing each in a queue and stack a . em % :* : . element from the + deqve queue . an palindrome . . if different → not a • palindrome z

  4. I Queuejhinkedhisttmplemewtatim-ba.ie , node to the : add Enquire new a ' front ' element : remove the Degueue → FIFTEEN front ° back D- fit Engue f- t.tt#-oFHYeTy.-HdTd*-ij D if ¥ ⇒ ¥ht4 →④ b. htretap

  5. : forget } pointers to Variables nodes . in the queue elements : # size . NodeTypg has variables data 4 next

  6. engueuelx ){ n ← newnodecoutamg£ list dd it to the back ← back ⇒ nT = street In size i. ID1-1TI } ' Drops front . C) { ×✓ . . D-fdegue.ae back temp a- front ③ ← front ⇒ data e- front -onext -• front temp delete - - I site sites - - return ral }

  7. I % ④→ rew_ v. as ' .

  8. Queue.ArrayImplemeutation.FI

  9. ← empty queue FP9R is : Ip queue enaoueue a c. die engweeeebf.ph#enqueoeep-j IT KID Any rtft a f¥¥ degueeb.ae enqueue 1-1 . engage # engulf degueue I 1¥11 * r f- 4 degree ft tr degree £-1 engined by ft Pr f 't H

  10. Array-tmplemeutationofQuaue.FI#E back front % IeIts =p .ba#p)3dfgaeues-Tenguueuej front ¥¥t¥ benguela back -

  11. Longman K -77 " front . " Jack I trwtopk.cn#nextenqueve to : goes back II. front

  12. IT { degree twice fb ¥¥t¥ op:ar . € ¥Et

  13. size capacity A ← array of : array Variables front ← o back ← 0 . size ← o ← ? capacity - A [ back % capacity I*X enqoueue (e) { Site t= 1 A [ back ] ← × back = back the - = size t I site % capacity e ( back t 1) back . } degueve.DE temp ← Affront ] t 1) % capacity ← front front - I site ← site . return temp }

  14. F- rid

Recommend


More recommend