Linked Lists Introduction

  Рет қаралды 63,995

WilliamFiset

WilliamFiset

Күн бұрын

Пікірлер: 18
@Mydad-et1el
@Mydad-et1el 4 жыл бұрын
At 13:00, I would like to point out that for Singly Linked List, insertion at tail only takes O(1) if we have a pointer to the tail. Otherwise, it is O(n) to insert at the end, since we need to traverse from head to tail to insert at the end.
@zss123456789
@zss123456789 4 жыл бұрын
good point!
@cyberknight9874
@cyberknight9874 4 жыл бұрын
I know this. But it's still a good point to mention here.
@AkshatSinghania
@AkshatSinghania 3 жыл бұрын
he said that "we have a refrence to the tail so we can remove it in constant time" in the video
@JIHYELEE-h2m
@JIHYELEE-h2m 6 ай бұрын
Note that Singly Linked List also can have Head and Tail Node, But only one pointer to next node. When remove at tail in Singly, We can remove last Node using Tail Node. But Tail Node doesn't know what is previous Node only know next is NULL. So we have to throw away Tail node after removing that.
@BlueSky-ho6dy
@BlueSky-ho6dy Жыл бұрын
14:00 complexity
@musthafajm
@musthafajm 6 жыл бұрын
Very nice sir.
@danimanabat5791
@danimanabat5791 4 жыл бұрын
Thank you!
@anupampandey3758
@anupampandey3758 5 жыл бұрын
if an n-1th element needs to be deleted in case of deletion from the middle in a doubly linked list, why can't we use the tail pointer and prevent the O(n) traversal? I think time complexity is O(n/2) since we must have to traverse in case the middle element in the list has to be deleted.
@kroypatcha
@kroypatcha 4 жыл бұрын
O(n/2) = O(n)
@IvanRandomDude
@IvanRandomDude 4 жыл бұрын
@@kroypatcha Yes but keep in mind that jdk actually does check if element is closer to head or tail. If you take a look at jdk you will see that they check if index of element you want to remove is closer to tail or head. If it's closer to tail they start traversal from tail and vice versa.
@IvanRandomDude
@IvanRandomDude 4 жыл бұрын
@@kroypatcha Here it is: hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/util/LinkedList.java On the line 566 in node function (used to locate node with specific index) you can see they check if index is smaller than size/2 or bigger than size/2. (Bit shifting by two is faster way of dividing by 2)
@IvanRandomDude
@IvanRandomDude 4 жыл бұрын
So yes, in algo analysis theory O(n/2) is the same as O(n). But in real world that doesn't mean we won't optimize the code to run twice as faster. If my program can run in 5 sec instead of 10 sec I'm doing it, I won't be like "muh 10/2 is the same as 10"
@kroypatcha
@kroypatcha 4 жыл бұрын
@@IvanRandomDude BigO notation is intended to find the scalability of the code (It can't always tell which is better algorithm). When two algorithms have same BigO then we chose the one with less time (such as n/2 or whatever). There is no notation for that part.
@amirsaeed7759
@amirsaeed7759 5 жыл бұрын
Well done!!!
@sanskarsoni2912
@sanskarsoni2912 3 жыл бұрын
Do you have a video on floyd's cycle detection algorithm? If not will you please do one.
@marlonstevenson4923
@marlonstevenson4923 Жыл бұрын
I'm 1:27 into this vid and I've already seen 2 advertisements. Truly ruining my experience. edit: 5:27 and the 3rd ad. KZbin is commiting suicide. Got to get off this platform.
@WilliamFiset-videos
@WilliamFiset-videos Жыл бұрын
That's not okay, removing mid roll ads.
Doubly Linked List Code
9:36
WilliamFiset
Рет қаралды 47 М.
Stack Introduction
11:39
WilliamFiset
Рет қаралды 41 М.
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Learn Linked Lists in 13 minutes 🔗
13:24
Bro Code
Рет қаралды 372 М.
Hash table hash function
17:21
WilliamFiset
Рет қаралды 44 М.
Winning Google Kickstart Round A 2020 + Facecam
17:10
William Lin (tmwilliamlin168)
Рет қаралды 10 МЛН
LinkedList vs ArrayList in Java Tutorial - Which Should You Use?
11:43
Coding with John
Рет қаралды 615 М.
15 Sorting Algorithms in 6 Minutes
5:50
Timo Bingmann
Рет қаралды 25 МЛН
Algorithms Explained for Beginners - How I Wish I Was Taught
17:38
Internet Made Coder
Рет қаралды 378 М.
Dynamic Array Code
6:46
WilliamFiset
Рет қаралды 65 М.
Priority Queue Inserting Elements
9:59
WilliamFiset
Рет қаралды 70 М.