Skip to main content

Big O Notation - Time and Space complexity

Big O - In simple words, this describes how long an algorithm takes to run and how much space it takes. It expresses how the runtime quickly grows with respect to the input.
This is how we compare different algorithms's efficiency.

Some quick notes - 
- N could be the actual input or the size of the input
- We always talk about the worst-case here
- We drop constants and less significant terms since as input grow infinitely large constants and less significant terms do not make much difference

Space complexity talks about memory or space. This measures, how memory grows as the input size increases. Usually, when we talk about space complexity, we're talking about additional space

The link I referred - https://www.interviewcake.com/article/java/big-o-notation-time-and-space-complexity

Interview tips - Always talk about time and space complexity at the end. This will earn you bonus points!
FAANG companies expect this even if they don't ask explicitly. 

Some useful graphs - 




Comments

Popular posts from this blog

Coding solutions - Amazon card, Data structure, Search and Sort

  Amazon card, Data structure, search and sort Hashmap # HASH MAP implementation in python class Node :     def __init__ (self, key, value) :         self.key = key         self.value = value         self.next = None class HashMap :     def __init__ (self) :         self.store = [ None for _ in range( 16 )]     def get (self, key) :         index = hash(key) & 15         if self.store[index] is None :             return None         n = self.store[index]         while True :             if n.key == key:                 return n.value             else :                 if n.next:         ...

Debugging round interview questions

Debugging round interview questions with answers. These are real questions asked in real interviews.  1. When you come in the morning, SLA has increased for the job searching portal (website). It was fine till today morning. How are you going to debug it? There is a matrix that shows service and it’s SLA. What are the steps you are going to take to debug this problem? Answer : If the SLA has gone up suddenly it's definitely a critical issue. I will first report this problem to all stakeholders. I will check listed points to debug the problem - 1. Check what went in the latest release if that is one  2. Check for nodes that are down. If there is an unusual number of nodes that are not reachable then report it to the infrastructure team. 3. Check for database repair which can cause slowness 4. Check its client-side delay or server-side delay to narrow down the issue 5. Check the geolocation of where the website is slow in order to narrow down 6. Check network bandwidth in the da...

Types of Software Testing

Different types of Software Testing: Functional Testing types: Unit Testing: Individual units or components of the software are tested. A unit is the smallest testable part of the software. This is usually not manual and mostly done by developers as they write code. Integration Testing: Testing of all integrated modules of the software to make sure modules once combines works as expected or not. The best example would be FE and BE integration testing. System Testing:  The entire system is tested as per the defined requirements. Black box testing performed by QA. End to End Testing: Same as System testing but mimics more real-world use cases and interactions with network, databases and real users. Most companies combine system testing and end-to-end testing as there is a very thin line between both. Sanity Testing: Sanity testing is performed by the QA team to determine SW which is released is ready to do a full round of testing or not. This is usually quick and covers basic func...