Essential Data structures for Coding Interviews
- DeTech Theory
- Jul 19, 2022
- 2 min read
If you’re preparing for a coding interview, knowing different data structures and their Big(O) times are essential. Here’s Part 1 of the most important data structures for coding interviews!
Array/ArrayLists - A list contains a sequence of items or values placed adjacently in memory. Accessing an element is very easy as you simply call it by index number - O(1)
Access: O(1)
Search — O(n)
Insert/Delete — O(n):
Linked Lists - Linked List elements (or nodes) contain the value and a pointer to the next element in the list - they are not stored adjacent in memory. Worst case scenario of accessing them is O(n) as you have to traverse them all sequentially.
Access — O(n):
Search — O(n)
Insert/Delete — O(1):
Hash Tables - Hash tables try to map elements of a certain data type to another data type, in a unique memory address to access each pair in constant time O(1)
Search — O(1)
Insert/Delete — O(1):
Queues - Queues keep data in order, but follow a FIFO (First in First Out) order i.e the first element to be inserted in the stack will always be the first element to be removed. You can imagine this as a real-world queue.
Access — O(n)
Search — O(n)
Insert/Delete — O(1)
Stacks - Stacks keep data in order, but follow a LIFO (Last in First Out) order i.e the last element to be inserted in the stack will always be the first element to be removed.
Access — O(n)
Search — O(n)
Insert/Delete — O(1)
Check out our Instagram reel for more! Simply follow the link in our bio.
Reel Cover image: Coccagerman - MediumData structures. In computer science, a data structure… | by Coccagerman | Medium
Best,
Vasundhara
Comments