Advantages and Disadvantages of MongoDB

MongoDB is one of the popular NoSQL database, is an open-source document-oriented database. The term ‘NoSQL’ means ‘not only SQL or non-relational’. It provides an altogether different mechanism for storage and retrieval of data, uses BSON storage format (similar to JSON format) and it is not based on relational database structure. Advantages and Disadvantages of MongoDB: Advantages- Flexibilty-… Read More »

Database Transaction Models and the CAP Theorem

According to Brewer’s theorem (also called CAP theorem), any distributed data store (like a database) can only provide two of the following three guarantees: Consistency Availability Partition tolerance Now when it comes to pain tolerance, like a network partition failure, one of the following decisions need to be made: Cancel the operation => decrease the availability but ensure… Read More »

Find GCD of two numbers

Given two numbers A and B, the task is to calculate GCD of A and B. Examples: Input : A = 4, B = 6 Output : 2 Input : A = 5, B = 10 Output : 5 GCD (Greatest Common Divisor) of two number is the largest number that divides both of them. A simple solution… Read More »

Find the Nth Fibonacci Number

Given a number N, the task is to find Nth Fibonacci number. The Fibonacci numbers are the numbers in the following integer series. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……. In this series, each number is the sum of the two preceding ones starting from 0 and 1. Examples: Input :… Read More »

Easy Multi-Layered Calculation

Count the number of even/odd results after performing a series of calculation on a range of numbers. Given that: Each layer of calculation have two numbers (say a and b) associated with it. For each input x, y = ax + b is calculated. The result of layer i, i.e y, becomes input for layer i+1. The range… Read More »

What is Overriding in C++

Write a program in C++ to depict the concept of overriding or Dynamic polymorphism. Overriding is a type of polymorphism. Polymorphism in OOP languages means to take more than one form. Virtual functions in C++ are functions that do not have an actual implementation, these are written in the base class to be overridden in derived class. When… Read More »

Program to print next palindromic Time

For the given hour and minute let say “hh” and “mm” print the next sooner palindromic time. Example: Input: hh = 02 mm = 03 Output: 02:20 Explaination:For the hour 02 and minute 03 the next sooner palindromic time is 02:20 Input hh = 04 mm = 45 Output: 05:50 Explaination:For the hour 04 and minute 45 the… Read More »