Data Structures: Arrays vs Linked Lists

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 พ.ย. 2024

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

  • @ronalddaugherty
    @ronalddaugherty 7 ปีที่แล้ว +355

    finally someone explaining this information like their talking to beginners not seasoned engineers

    • @romir_07
      @romir_07 4 ปีที่แล้ว +1

      I have one doubt...why time complexity in adding an element at ith position in linked list is big-O(n)..it should be big-O(i)

    • @ujjwaldixit4244
      @ujjwaldixit4244 3 ปีที่แล้ว +7

      @@romir_07 in worst case ith position can be even nth position therefore we consider it as O(n)

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

      @@romir_07 we add an element at the end but to find which element is the end…we need to start from head and all the way to the end ad worst vase here is obviously o(n)

    • @sameerjain7193
      @sameerjain7193 ปีที่แล้ว

      @@romir_07 big o is used to denote the worst case, that is why n. which ever is the max!

  • @chloetzpiano6548
    @chloetzpiano6548 6 ปีที่แล้ว +58

    dude,you basically just saved me my whole semester studying with difficult lecture before,now all is ez

  • @renon3359
    @renon3359 6 ปีที่แล้ว +49

    The way you explain, I could listen to these videos for hours and not get bored. Absolutely mindblowing content man, keep doing the good work.

  • @leixun
    @leixun 4 ปีที่แล้ว +57

    *My takeaways:*
    *Computation cost: array vs linked list*
    1. Cost of accessing an element 1:10: array O(1) and linked list O(n)
    2. Memory usage 4:26
    3. Cost of inserting/deleting an element 8:30: array O(n) and linked list O(n)
    4. Easy to use 11:35: array is easier than linked list

    • @Dark._phoenix._
      @Dark._phoenix._ 11 หลายเดือนก่อน

      Are you Chinese?👀

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

    As a 9th grader I really appreciate how you are using pictures and analogies to explain what can be confusing concepts at first.

  • @mycodeschool
    @mycodeschool  11 ปีที่แล้ว +47

    Hi Prasanth,
    Thanks for your kind words.
    We will first complete some of the existing playlists and then we will move to OOP concepts. We are building a mechanism to track video requests on our website. Anyway, for now, your request is in queue.

    • @mcytc
      @mcytc 7 ปีที่แล้ว +1

      Time complexity is always the worst case scenario, which in this case is adding an element at the beginning of the array, requiring all elements to shift.

    • @gta6515
      @gta6515 4 ปีที่แล้ว +1

      where have you explained oops?

    • @romir_07
      @romir_07 4 ปีที่แล้ว

      I have one doubt...why time complexity in adding an element at ith position in linked list is big-O(n)..it should be big-O(i)

    • @drakolubez6592
      @drakolubez6592 3 ปีที่แล้ว +1

      @@romir_07 i is a constant, you need to shift (n-i) elements to right. This means the time complexity id O(n-1) , which is same as O(n)

    • @ahmed_raaphat
      @ahmed_raaphat 3 ปีที่แล้ว

      What a loss! :( :(

  • @alirezaghodsipoor2239
    @alirezaghodsipoor2239 5 ปีที่แล้ว +21

    I can watch your videos as a movie and not get bored :) Awesome!

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

    Best of the Developers who knew about these Legends already raise you hand pls. ✌🏻🙌🏻

  • @stephen6072
    @stephen6072 10 ปีที่แล้ว +12

    Good videos, makes more sense than what was taught in my data structures course here in the U.S.

  • @danielli8042
    @danielli8042 8 ปีที่แล้ว +74

    nice layout and subtitles. I really like the video. very professional. keep it up :)

  • @akshayarekhasubramaniyan9537
    @akshayarekhasubramaniyan9537 7 ปีที่แล้ว +8

    srsly, i don't know your name and who you are but for now you are a god to me. thank you so much. i longed so badly for learning this, now i understood this

  • @WillsonMock
    @WillsonMock 10 ปีที่แล้ว +10

    another really great video - i love the way you teach and how clearly you explain the concepts. i find this useful even when i'm not trying to implement in C / C++

  • @bhavincbarot
    @bhavincbarot 8 ปีที่แล้ว +1

    Excellent. Very simplified and easy to understand for first time learners as well.

  • @moha4998
    @moha4998 3 ปีที่แล้ว

    Learning DSA Now in 2021 and still so
    Helpful
    Harsha left a legacy behind. RIP

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

    It's so geat even now when there are lots of videos on this topic. Good job...

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

    Dynamic Array that adjusts the size by increasing when it got exhausted to its previous maximum length, is called ArrayList in Java

  • @md-ayaz
    @md-ayaz 8 ปีที่แล้ว +146

    The next "Khan Academy" but this time from India.

    • @adarshtodi1158
      @adarshtodi1158 5 ปีที่แล้ว

      really??

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

      unfortunately, he died before achieve such a thing

    • @mohammedfawaz289
      @mohammedfawaz289 5 ปีที่แล้ว +6

      @@danilo2735 He did't die, but a friend of him.

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

      @@mohammedfawaz289 go to they facebook and you'll see the post

    • @mohammedfawaz289
      @mohammedfawaz289 5 ปีที่แล้ว

      @@danilo2735 Yea I saw it years ago, but I think that was his friend, not the one who speak in the video.

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

    Excellent Way of Explaining Programming Concepts... Great Work Sir !!!

  • @shubhamsabale8613
    @shubhamsabale8613 4 ปีที่แล้ว

    nice online series of video of data structures i ever seen on u tube, mechanical engineer like me learn concepts clearly

  • @micromir4
    @micromir4 5 ปีที่แล้ว +1

    love your tutorials. Wish you guys continued no matter what.

  • @animeshnayan1
    @animeshnayan1 11 ปีที่แล้ว +1

    part 2.. contd...we often say that our machine is 32-bit or 64 bit. On a 32-bit machine, there are 32 bits on address bus that is used to transport address of a memory to processor. So, maximum number of addresses can be 2^32. On 64-bit architecture, maximum number of addresses can be 2^64. Pointers size depends upon whether we are compiling for 32 bit architecture or 64 bit architecture. Typically, we compile for 32 bit. So that's why its 4 bytes.

  • @radhiekanagpal6257
    @radhiekanagpal6257 7 ปีที่แล้ว

    Easy to understand and quite precise in flow of learning. Amazed.

  • @sundararajannarasiman5613
    @sundararajannarasiman5613 3 ปีที่แล้ว

    Superb explanation. Programming and software engineering made simple.

  • @rahilshah4098
    @rahilshah4098 10 ปีที่แล้ว

    For Link List, By keeping two pointers one for Head and another for Tail of the List, inserting Element at the End will also of O(1)....

  • @sourabhd99
    @sourabhd99 11 ปีที่แล้ว

    Best lectures I could have seen..
    Regretting if I had got such lessons in my engineering schools :(

  • @ramudu1
    @ramudu1 11 ปีที่แล้ว +4

    Wonderful series of tutorials ..! only 10% of the videos in youtube makes sense and this is one of them. Good job mycodeschool. It would be good if you could cover some of the OOPS and virtual functions.

  • @SumanChakrabarti
    @SumanChakrabarti 7 ปีที่แล้ว

    This is honestly better than watching the MIT presentations. Thank you!

  • @jaiderariza1292
    @jaiderariza1292 7 ปีที่แล้ว +1

    The cost of inserting an element at the end 10:24 could be a constant O(1) if you use doubly linked list :)

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

    Thank you, excellent explanation of cost and memory use.

  • @october3518
    @october3518 3 ปีที่แล้ว

    The thing is ....I get bored easily lol but he actually made me interested and ask why this like this.

  • @jyotinpankaj
    @jyotinpankaj 9 ปีที่แล้ว

    Thanks mycodeschool, no one ever explained concept like this.

  • @jery7082
    @jery7082 7 ปีที่แล้ว +15

    Inserting node at end of linked list would be constant time if we have tail pointer!

    • @nurilha
      @nurilha 5 ปีที่แล้ว

      But why is there no tail pointer?

    • @dilloncote7551
      @dilloncote7551 5 ปีที่แล้ว

      @@nurilha Tail pointers are optional and can be made the same way as a head pointer. He just didnt use it in the video.

  • @akhiljain1695
    @akhiljain1695 6 ปีที่แล้ว

    These videos are really helpful. You are doing a great job.!!!!! Please keep making more such videos.

  • @piyushhibare
    @piyushhibare 8 ปีที่แล้ว +6

    excellent explaining

  • @shubhamdey9922
    @shubhamdey9922 10 ปีที่แล้ว

    really awesome... knowing the things dosent matter much fr a teacher but explaning it does.. nd myschool did it...

  • @usama57926
    @usama57926 6 ปีที่แล้ว +1

    thank u sir for such an amazing playlist

  • @sierrabravo4432
    @sierrabravo4432 9 ปีที่แล้ว +17

    Wish you would make your videos in Java, nonetheless you are the best on TH-cam.

    • @decreer4567
      @decreer4567 6 ปีที่แล้ว

      Derrick Banas does this in Java

    • @patrasculucian2403
      @patrasculucian2403 6 ปีที่แล้ว +1

      True but his tutorials are not for beginners

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

      A beginner shouldn't be on data structures and algorithms anyway. They still have to learn basic syntax.

    • @patrasculucian2403
      @patrasculucian2403 6 ปีที่แล้ว

      The person who knows the syntax without knowing data structures is a beginner on data structures.
      That's what I meant. Derek's videos are much better to watch after you learn the basics from other who teaches slower.
      Then, Derek's videos are going to be awesome, you will refresh your memory, practice and master it at a hell of a fast pace.

    • @decreer4567
      @decreer4567 6 ปีที่แล้ว

      Are you sure because his videos are pretty slow? I normally turn it up to around 2X speed with how slow he goes sometimes

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

    When insetring an element at the end of a linked list why we will be needed to traverse whole memory.
    It can be done by changing the last pointer.

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

      first you need to figure out which one is last - for it you traverse from the start :)

    • @monishkumardurairaj3038
      @monishkumardurairaj3038 5 ปีที่แล้ว

      Hi @@mistersmith6752.can we not use a static variable inside the class of the linked list to store the last address..???????

    • @mistersmith6752
      @mistersmith6752 5 ปีที่แล้ว

      @@monishkumardurairaj3038 Im not really sure what you are asking but you must understand that linked list is already an established data structure and if you want to change something you can implement a new class that does whatever you want , most likely it will be ineffective , but if you are a great programmer maybe you will create something usefull :) If a particular data structure is not working in some case just use another.

    • @monishkumardurairaj3038
      @monishkumardurairaj3038 5 ปีที่แล้ว

      @@mistersmith6752 what i am asking is suppose if we have a struct named list inside which if you have two variables one for storing value and another one(pointer) for storing address.
      why cant we have a third variable or pointer which may be static to store the last address of the list.
      since it is static the pointer can only be created by one instance and can be used by all the instances.
      eg:
      struct node
      {
      int value;
      node* next;
      static node* last;
      }

    • @monishkumardurairaj3038
      @monishkumardurairaj3038 5 ปีที่แล้ว

      @@mistersmith6752 i understood what i have asked is not possible in c.since the static variable cannot be declared inside a struct.
      so this cannot be done...
      thanks for the help ..
      note:
      but in c++ what i have asked previously is possible i guess.

  • @anondoggo
    @anondoggo 5 ปีที่แล้ว +1

    So tremendously helpful. Thank you so much!

  • @tanmaykumar6856
    @tanmaykumar6856 5 ปีที่แล้ว

    he has the best playlist on linked list

  • @animeshnayan1
    @animeshnayan1 11 ปีที่แล้ว

    Pointers will always take same number of bytes. Pointers store the address of a particular byte in memory. Address of data is the address of starting byte. We look at rest of the bytes in the data using arithmetic. Size of pointer depends upon total addressable bytes in memory and not upon what data we are pointing to. With 32 bits, we can have 2^32 possible addresses. contd ...

  • @rajankit749
    @rajankit749 10 ปีที่แล้ว

    Awesome !! What a way of EXPLAINING THINGS .... +LEGIT

  • @VS-ey2lf
    @VS-ey2lf 7 ปีที่แล้ว +2

    mycodeschool you're the best

  • @abhishekdhyade7500
    @abhishekdhyade7500 3 ปีที่แล้ว

    Made ppt using your content xD. Thank you

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

    this is so informative omg , thanks alot

  • @asdfghjkl1770
    @asdfghjkl1770 5 ปีที่แล้ว +1

    amazing, i am preparing for googles kickstart.
    btw im 15 and python programmer ,web developer.

  • @nitintomar7534
    @nitintomar7534 5 ปีที่แล้ว

    You are champ man ! Nicely explained

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

    Adding element to the end of a Linked List doesn't need to be O(N) if you store and control the position of the last element, like you do with your head element, and like you do on the array
    It could be O(1)

    • @stopthecap8810
      @stopthecap8810 ปีที่แล้ว

      you mean if you stored the position of the last node as another pointer variable in the struct definition? that could work but feels complicated

  • @onurucar1112
    @onurucar1112 4 ปีที่แล้ว

    not all heroes wear capes! tysm

  • @ashwinkarthikeyan1829
    @ashwinkarthikeyan1829 6 ปีที่แล้ว

    All these videos on data structures are very useful. Thanks a lot. But can you upload videos of OOP using JAVA too please.

  • @TravisFont
    @TravisFont 3 ปีที่แล้ว

    It's all about allocation. Huge data set or small data set.

  • @minaraouf1051
    @minaraouf1051 4 ปีที่แล้ว

    Really very good explanation. But there is a small mistake in this video and the video previous videos
    U mentioned that inserting an element in the array will have a cost of O(n), that's quite not right. Because it's Big-Theta(n) NOT Big_Oh(n). This is because you may insert an element in index and do the shifting staff for number of iterations less than the total length of the array. Let me show an example:
    Assume that u have array of 10 Elements, U only use the first 3 elements. Then you need to add an element in the first index, so you will shift the elements three times only (NOT 10 times).
    If you like to use the Big-Oh lower bound, then it will be O(m), & (m

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

      We talk about worst case right???

  • @abdelghanidraoui781
    @abdelghanidraoui781 5 ปีที่แล้ว

    Awesome course thanks for sharing !

  • @muhammedhussein928
    @muhammedhussein928 9 ปีที่แล้ว +1

    why the time complexity for inserting an element at the end of linked list is O(n)
    i think it should be o(1) because we just make the Null to the inserted element then we add the address of the element of last element to the previous element !!
    and Thanks for these Awesome Videos

    • @plemyk
      @plemyk 9 ปีที่แล้ว +7

      Muhammed Hussein Because you need to start from the address of the head node to arrive subsequently to the exit node.We have no knowledge of the last node address,without first having been directed by the head.What you suggest is like trying to arrive to any destination on a map,but having no awareness of where you are.How can you arrive to your destination,if you have no point of reference.

    • @muhammedhussein928
      @muhammedhussein928 9 ปีที่แล้ว +1

      thanks for this awesome explanation :)
      plemyk

  • @Alpha777beta
    @Alpha777beta 7 ปีที่แล้ว

    awesome explanation

  • @varunkamani2528
    @varunkamani2528 7 ปีที่แล้ว

    your channel is great..keep it up!

  • @Raksh6
    @Raksh6 8 ปีที่แล้ว

    Great videos! Keep up the good work and Thank you!

  • @sohelurrahman6565
    @sohelurrahman6565 7 ปีที่แล้ว

    best lecture.... thankas

  • @EchoVids2u
    @EchoVids2u 5 ปีที่แล้ว +1

    Correction: time complexity for inserting at the end of a linked list is O(1) if you have a tail pointer pointing to the last node of the list.
    Example (in Python):
    class Node:
    def __init__(self, d):
    self.data = d
    self.next = None
    class LinkedList:
    def __init__(self, d):
    self.head = Node(d) # Head stays the same
    self.tail = self.head # Tail points to ending Node
    def append(self, d):
    self.tail.next = Node(d) # NEW NODE
    self.tail = self.tail.next

    • @yerotuavinash1162
      @yerotuavinash1162 4 ปีที่แล้ว

      i think that your concept works on Double linked list

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

    Nice lecture

  • @mightguy167
    @mightguy167 4 ปีที่แล้ว +1

    crystal clear!

  • @dhaneshpt8641
    @dhaneshpt8641 4 ปีที่แล้ว

    Thank you sir.

  • @dhruvgarg722
    @dhruvgarg722 6 ปีที่แล้ว +1

    awesome!! really well explained, but what about dynamic array or vector in c++

  • @azkamobin
    @azkamobin 3 ปีที่แล้ว

    really great video!!!

  • @ahmedzahid8354
    @ahmedzahid8354 5 ปีที่แล้ว

    Thanks sir well done job

  • @vundigalarohit8654
    @vundigalarohit8654 4 ปีที่แล้ว

    Your explanation is awesome man !
    Why did u stopped posting videos ?

  • @aaronbalthaser
    @aaronbalthaser 5 ปีที่แล้ว +1

    Why is adding a node to the end of the list O(n)? If you maintain a tail you can add nodes to the list in constant time no different than added to the head. I have seen many implementations with both head and tail. Is a linked list with a tail not a valid implementation?

  • @pawannegi1135
    @pawannegi1135 8 ปีที่แล้ว

    good explanation ...

  • @ronaldabellano5643
    @ronaldabellano5643 6 ปีที่แล้ว +8

    I dont get the Memory requirements part. How does Linked List consume lot less memory if it uses more memory because of its pointer?

    • @amarbhardwaj7963
      @amarbhardwaj7963 5 ปีที่แล้ว +3

      Because there is no unused memory in linked list.

  • @nic0lasc
    @nic0lasc 10 ปีที่แล้ว

    thank you very much! perfectly described!

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

    The way you are teaching is superb and do you have pdf version or any other format notes for quick revise.thanks...;

  • @LawStation24
    @LawStation24 5 ปีที่แล้ว +1

    Can someone tell me that these videos are helpful for the gate (for data structure) preparation or not?

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

    Hey this was a great video! Since I use Python, which uses dynamic arrays(arrayLists) by default, could you explain how exactly these work and the time/space complexity for these? Thanks

  • @msKuchifai
    @msKuchifai 11 ปีที่แล้ว

    Thanks, that makes a lot of sense...also thanks for the prompt response!
    :)

  • @sltest5622
    @sltest5622 5 ปีที่แล้ว

    Thank you very much for all the videos!!
    I have a question, in the linked list, inserting an element at the end and at ith position should be O(1), isn't it? Because only pointers need to be changed..? Only access to elements at the end and at ith position would be O(n)?

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

    i did not understand that part that a link list will take less memory as compared to that of an array..
    please explain!!

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

      In the case of complex high size data, the fact that you will use exactly as many memory blocks as you need in the linked list than in case of the array is dominating over the fact that each memory block in the linked list contains an extra variable (of type node*) of size 4 bytes(which is pretty less in comparison to size of complex data part).

  • @ruprajroy628
    @ruprajroy628 5 ปีที่แล้ว +1

    Instead of dynamically memory allocation why arrays are of fixed size

  • @msKuchifai
    @msKuchifai 11 ปีที่แล้ว +1

    Your videos are awesome! I learnt a lot from them...
    I have a question. At 6:54 min at your video, the memory requirement section...
    shouldn't data and pointer variable be the same number of bytes? in your example, the data is 16 bytes but the pointer variable only 4bytes. Please clarify, thanks.

    • @manavmohata1240
      @manavmohata1240 4 ปีที่แล้ว

      size of pointer variable will always be same for all data types. the data type that we specify for pointers denote the data type of the variable whose address will be stored in the pointer variable.

  • @VenkataraghavanRamasubbu
    @VenkataraghavanRamasubbu 7 ปีที่แล้ว

    Thank you for the great explanation!! I'd a doubt on linked list, when we insert a data at the end of linked list or in between linked list the time consumption is proportional to O(n). I thought however we're going to add it and just have to change the address of last one O(1). but we've to iterate from the first to find the tail node address so it comes to O(n) am I right?

  • @AdityaVermaopenheartedme
    @AdityaVermaopenheartedme 6 ปีที่แล้ว

    hi what about self referential pointers in a structure what amount of memory would they take?

  • @siddhantmodi7085
    @siddhantmodi7085 3 ปีที่แล้ว

    Do pointers of Linked list needs extra memory to store them?

  • @sonalipurohit6362
    @sonalipurohit6362 7 ปีที่แล้ว

    Can you make a video on how to calculate address of 3-d array?

  • @LarissaFord
    @LarissaFord 7 ปีที่แล้ว

    I thought arrays had O(n) and not O(1)? because isn't big-O concerned with worst case scenarios where we may have to iterate through the entire array before finding our element, and would thus need n-time for an array of size n? I thought this because I understood hash tables to be special because they had a faster run-time than arrays, having a general case of O(1) run-time. Am I mistaken somewhere in there? Thanks for the amazing lecture!

    • @LarissaFord
      @LarissaFord 7 ปีที่แล้ว +4

      oh wait, it would be constant time if we knew ahead of time where in the array (which index) an element is found. I think my question is still valid in terms of finding an element, but is that not what big-O is concerned with? is big-O concerned only with look up for a particular known element?
      *EDIT* gosh, I missed the part that said "Cost of accessing an element". this all makes sense now.

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

    I now know why google hires bunches of Indian CS engineers...

  • @nikhilgaikwad3014
    @nikhilgaikwad3014 7 ปีที่แล้ว

    Nice explains

  • @monishkumardurairaj3038
    @monishkumardurairaj3038 5 ปีที่แล้ว

    Kindly any one clarify my doubts..
    in linked list why to traverse the entire list inorder to add the new node at the end.
    Instead just maintain a static variable inside the linked list class that will always hold the end address of the list.
    inadditon why to have the head variable to store the starting address can we not just access the starting address of the list which is gonna be the same.
    eventhough if you want to add the node at the beginning of the list you just have to change the address of the list to the new node created at the beginning .
    why waste 4 byte variable head for storing starting address?????????????

  • @elimarpineda6496
    @elimarpineda6496 7 ปีที่แล้ว

    thank you so much for you greattttttt work!!!!!

  • @akshupatel3092
    @akshupatel3092 4 ปีที่แล้ว

    If you have a tail reference on the LinkedList would insertion at the end be O(1) ??

    • @NitishKumarTutorials
      @NitishKumarTutorials 4 ปีที่แล้ว

      yes, right :)
      Data Structure Best Tutorial
      Check here for free
      th-cam.com/play/PLbRk-vKGcVtbyctZWP9SUYewwUfx75CpZ.html

  • @shermanjoke
    @shermanjoke 8 ปีที่แล้ว +3

    shouldn't linked lists consume more memory than arrays? in each node, there will be memory allocated for data AND the link, whereas in arrays, there will only be memory allocated for data.

    • @Mrsarchanaharish
      @Mrsarchanaharish 8 ปีที่แล้ว +9

      +Sherman Hung
      Rightly said - he compares 7 elements on an array vs 4 elements on a linked list.

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

      - In an array you will always have empty unallocated memory
      - Let's assume that, in an array, we store big data of 16 bytes / element
      - if we have 10 empty elements in the array
      - 16*10 = 160 unallocated bytes in memory
      - In linked lists this will not be the case
      - We will have 20 bytes / element
      - the address of the next element is stored in an integer of 4 bytes
      - thus 16 bytes + 4 bytes
      - But we will never have unallocated memory. So it's an overall win for Linked Lists

    • @_robo
      @_robo 6 ปีที่แล้ว

      Yeah but why would you ever have empty elements in a dynamic array.

  • @kondurubharath8279
    @kondurubharath8279 5 ปีที่แล้ว

    does a pointer variable require 4 bytes here..?? I heard from some sources that any pointer variable irrespective of the data type consumes 8 bytes..isnt this correct..???

  • @kuba1366
    @kuba1366 5 ปีที่แล้ว

    i think deleting at the end of array is O(1), not O(n) so deleting times are not the same

  • @blazefrostrider
    @blazefrostrider 5 ปีที่แล้ว

    Isn’t deleting the last element in the array always constant time O(1)? We never have to resize the array or shift any elements

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

      yes, I think it is O(1)

  • @siayush
    @siayush 7 ปีที่แล้ว

    well explained

  • @nicholasgonzalez
    @nicholasgonzalez 11 ปีที่แล้ว

    Thanks very good video!

  • @Mercio2
    @Mercio2 8 ปีที่แล้ว

    Very nice!

  • @may21136
    @may21136 5 ปีที่แล้ว

    one doubt. If we store the start and end nodes in separate pointers, then adding a new element at the end should take O(1), shouldn't it?

    • @HansNiemann762
      @HansNiemann762 5 ปีที่แล้ว

      to Reach the end node in Linked List you have to start from head and reach till tail (Traverse across the list ) , so the time complexity is O(n)

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

    Please comeback and add more

  • @AshishMehrotra
    @AshishMehrotra 9 ปีที่แล้ว

    can you please post lssons on heaps and multiway trees..?

  • @suprijasirikonda2065
    @suprijasirikonda2065 7 ปีที่แล้ว

    Y is d complexity O(n) for deleting d element at d end of an array (when it is full) ?

  • @romir_07
    @romir_07 4 ปีที่แล้ว

    I have one doubt...why time complexity in adding an element at ith position in linked list is big-O(n)..it should be big-O(i)

    • @mrboon8856
      @mrboon8856 3 ปีที่แล้ว

      We are taking worst case