MakeMyTrip Interview Questions
Practice with real MakeMyTrip interview questions
01
A Software Engineer was asked
Asked in 2024
Q. What is recursion in algorithms, and how would you implement a function to calculate Fibonacci numbers using recursion?
Ans. Recursion is a programming technique where a function calls itself in order to solve a problem. It is often used for problems that can be broken down into smaller, similar sub-problems. The Fibonacci sequence is a classic example where each number is the sum of the two preceding ones.
Here’s how you can implement a recursive function to calculate Fibonacci numbers:
In this implementation, the base cases handle the scenarios for
n = 0 and n = 1. The recursive case calls the fibonacci function twice, leading to an exponential time complexity. It is important to note that this naive implementation can be inefficient for larger values of n due to repeated calculations. For improvement, memoization or an iterative approach can be utilized.Software EngineerCore Concept
02
A Backend Developer was asked
Asked in 2024
Q. How do you create a simple REST API using Node.js? Provide a code example.
Ans. To create a simple REST API using Node.js, you can use the Express framework, which simplifies the process of handling HTTP requests. Below is an example of a basic REST API that manages a list of books.
In this example, we set up a REST API with three endpoints: one for retrieving all books, one for adding a new book, and one for retrieving a specific book by its ID. The API responds with JSON data and handles basic errors such as a missing book.
Backend DeveloperCore Concept
