top of page
Search

Essential Data structures for Coding Interviews

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!

  1. 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)

    1. Access: O(1)

    2. Search — O(n)

    3. Insert/Delete — O(n):


  1. 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.

    1. Access — O(n):

    2. Search — O(n)

    3. Insert/Delete — O(1):


  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)

    1. Search — O(1)

    2. Insert/Delete — O(1):

  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.

    1. Access — O(n)

    2. Search — O(n)

    3. Insert/Delete — O(1)


  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.

    1. Access — O(n)

    2. Search — O(n)

    3. Insert/Delete — O(1)




Check out our Instagram reel for more! Simply follow the link in our bio.




Best,

Vasundhara


 
 
 

Recent Posts

See All
Java Switch Case

Ever needed to write a million if-else statements to the point where your brain is breaking and you're about an inch away from throwing...

 
 
 

Comments


bottom of page