python deque (useful interview datastructures) (intermediate) anthony explains

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ก.พ. 2025

ความคิดเห็น • 10

  • @a_maxed_out_handle_of_30_chars
    @a_maxed_out_handle_of_30_chars 2 ปีที่แล้ว +2

    1:46, how is deque's popleft method O(1)? deque like list is index traversed right? so it too needs to shift the elements in case I need to print deque(3) after the popleft method?

  • @sadhlife
    @sadhlife 4 ปีที่แล้ว +3

    a double ended queue is just a singly linked list with references to the head and tail right?
    also someone might want to use deque for stack instead of list to have worst case o(1) append time, where in list it can be o(n)

    • @anthonywritescode
      @anthonywritescode  4 ปีที่แล้ว +5

      it has to be doubly-linked I believe, otherwise you can't add/remove from both ends. I believe cpython's deque is implemented as doubly-linked chunks of buffers instead of individually linked items

  • @Puja2005
    @Puja2005 2 ปีที่แล้ว +1

    Can I please get a program of is empty like a complete program before 14

    • @anthonywritescode
      @anthonywritescode  2 ปีที่แล้ว +1

      all of the code samples are on github -- github.com/anthonywritescode/explains

    • @Puja2005
      @Puja2005 2 ปีที่แล้ว

      @@anthonywritescode thank you so much for these programs it means alot i was looking forward to it for my exams 💜💜

  • @nononnomonohjghdgdshrsrhsjgd
    @nononnomonohjghdgdshrsrhsjgd 2 ปีที่แล้ว

    why is i better to use deque? And when should I use it in real projects?

    • @anthonywritescode
      @anthonywritescode  2 ปีที่แล้ว

      as covered in the video -- it has different performance characteristics than a standard list and is useful for implementing things where random access is unimportant but access at ends is (queues are a big example, lru another)