coding-interview|May 16, 2019|2 min read

Coding Interview - Useful Terms Cheatsheet

TL;DR

Big-O measures worst-case growth rate. O(1) < O(log n) < O(n) < O(n log n) < O(n^2). Always clarify time vs space, and know the difference between stable and unstable sort.

Coding Interview - Useful Terms Cheatsheet

Big-O notation

In simpler terms, its kind of a unit to measure how efficient an algorithm is, with respect to the size of input, often refered to as ‘n’. There are two kind of units in algorithms:

  1. Time Complexity It defines how much time an algorithm is taking w.r.t. ‘n’
  2. Space Complexity It defines much space an algorithm is taking w.r.t. ‘n’

In interviews, mostly people are interested in Time complexities, but you should be familiar with space complexitity as well.

For example, Bubble Sort’s time complexity is O(n^2) What it means, if the number of input is: 10. This algorithm requires an average of 10^2=100 operations or CPU cycles to finish working.

Where as, Merge Sort takes O(n log n). Which is clearly lesser than O(n^2). So, lesser the complixity, more efficient the algorithm, i.e. more quickly it can be finished.

Note: here log n means log (base 2) of n

Divide and Conquer Algorithms

These algorithms are very useful and recursive in nature. These algorithms break the given input set or given problem in smaller sets or smaller subproblems. Then, solve the subproblems recursively, and finally combine these solutions to have a final solution for original problem.

To be more precise:

Divide

Divide the problem into smaller sub-problems. Its like big problem is now converted into smaller problems. And it is relatively easy to solve a smaller problem rather than bigger problem.

Conquer

Conquer the subproblems by solving them recursively.

Combine

Combine the solution of smaller sub-problems which becomes solution to original bigger problem.

Merge sort, Quick sort are best example of this approach. Once you learn the basic concept behind this, rest of the problems become very easy for you.

Stable Sort

In sorting, the numbers with the same value appear in the output array in the same order as they do in the input array. For same value numbers/objects, the order among them will remain same.

Related Posts

What FAANG companies expect in their interview from candidates

What FAANG companies expect in their interview from candidates

Its every software engineer’s dream to work with the big FAANG companies…

Magical usage of Bitwise operators - Get optimized solutions for many arithmatic problems

Magical usage of Bitwise operators - Get optimized solutions for many arithmatic problems

Introduction I will list some of the interesting usage of bitwise operators…

How to prepare for your next Coding Interview

How to prepare for your next Coding Interview

Here are some tips while preparing for your coding interviews. 1. Do study or…

How to nail your Coding Interview

How to nail your Coding Interview

Here are some tips while giving your coding interviews. 1. Never try to jump to…

List of Sorting Algorithms

List of Sorting Algorithms

This topic is one of the most common studied. When somebody started preparation…

Coding Interview Cheatsheet

Coding Interview Cheatsheet

Latest Posts

Software Security in the AI Era: How to Write Secure Code When AI Writes Code Too

Software Security in the AI Era: How to Write Secure Code When AI Writes Code Too

In 2025, 72% of professional developers used AI-assisted coding tools daily. By…

SQL Injection: The Complete Guide to Understanding, Preventing, and Detecting SQLi Attacks

SQL Injection: The Complete Guide to Understanding, Preventing, and Detecting SQLi Attacks

SQL injection has been on the OWASP Top 10 since the list was created in 200…

Building a Vulnerability Detection System That Developers Actually Use

Building a Vulnerability Detection System That Developers Actually Use

Here’s a stat that should concern every security team: 73% of developers say…

How to Be a Full-Time Freelancer: Resources, Finding Clients, and Building a Sustainable Business

How to Be a Full-Time Freelancer: Resources, Finding Clients, and Building a Sustainable Business

Making the leap from full-time employment to freelancing is one of the most…

Deep Dive on Elasticsearch: A System Design Interview Perspective

Deep Dive on Elasticsearch: A System Design Interview Perspective

“If you’re searching, filtering, or aggregating over large volumes of semi…

Deep Dive on Apache Kafka: A System Design Interview Perspective

Deep Dive on Apache Kafka: A System Design Interview Perspective

“Kafka is not a message queue. It’s a distributed commit log that happens to be…