Комментарии:
I'm not sure if inserting to a hashmap is, by definition, O(1). It really depends on your hashing function. Your worst case to deal with hashing collisions will be by using a height balanced binary tree as collision structure, so this becomes O((logn)/k). If you never deal with collisions, then yeah O(1) is correct, but you'll need a really big starting array.
ОтветитьStarted my journey of getting ready for tech interviews… I have been watching your vids every chance I get!!
ОтветитьCool.
ОтветитьQuestion: May be I am missing something ? But inserting or removing at the mid of linked list how it's O(1) unless we have a reference to the mid node, which in usual scenario we don't have that reference, in that case we have to loop to find the mid node and then insert or remove in this case it won't be constant.
ОтветитьRegarding Linked list how it's possible to insert or remove in middle of the linked list in O(1)? How you will get the node of middle in constant time without storing the index of the nodes of the linked list?
Ответить@NeetCode , One que, How time complexity of linked list for insert and delete will be O(1), first we need to traverse till that node right ?, which in worst case O(n). so O(n) + O(1) would be O(n) right ?
ОтветитьWhen inserting/deleting from a linked list, don't you have to get the nodes 6 and 8 before inserting 7? But if you do, insert can't be O(1), since reading from a linked list is O(n)
ОтветитьAs far as I know, inserting an element at any position to a linked list is O(N) because you have to traverse and update your pointer untill that element. In the video it says O(1). How is this possible?
ОтветитьFantastic video!
ОтветитьI think u need to iterate over the linked list to know the middle(as in the size) then iterate till you find the value in the linked list
ОтветитьIs trhere any situation, where an array is faster or more efficient than a hashmap?
ОтветитьThanks you, I wish I had a job I would’ve send you more!
ОтветитьRemoving a node at the end is not constant. Not in a single linked list
Ответитьwouldn't for linked list insert and remove middle still be O(n) because you need to spend time navigating to that element?
Ответитьliterally my uni course in 13min.
ОтветитьHi, I have two questions 1) how about disjoint set, is it important? 2) does an AI Engineer/ AI researcher need a lot of leetcode?
Ответитьwhy are hash maps said to have O(1) key search/access/insert time, when conflicts exist? Is there an implementation that works in O(1) in presence of conflicts?
I trust STL to be well implemented, and STL guarantees O(lg) for sorted and O(N) for unordered maps/sets.
There are concrete like arrays and linked lists and maybe even trees and abstract data structures like graphs and hashtables..
Ответить