Ankith Reddy has Published 996 Articles

How we can translate Python dictionary into C++?

Ankith Reddy

Ankith Reddy

Updated on 17-Jun-2020 11:01:41

1K+ Views

A python dictionary is a Hashmap. You can use the map data structure in C++ to mimic the behavior of a python dict. You can use map in C++ as follows:#include #include using namespace std; int main(void) {    /* Initializer_list constructor */    map m1 = { ... Read More

Print Matrix in spiral way

Ankith Reddy

Ankith Reddy

Updated on 17-Jun-2020 10:14:06

1K+ Views

This algorithm is used to print the array elements in a spiral way. At first starting from the first row, print the whole content and then follow the last column to print, then the last row and so on, thus it prints the elements in spiral fashion. The time complexity of ... Read More

Amortized Analysis

Ankith Reddy

Ankith Reddy

Updated on 17-Jun-2020 10:07:00

20K+ Views

Amortize AnalysisThis analysis is used when the occasional operation is very slow, but most of the operations which are executing very frequently are faster. Data structures we need amortized analysis for Hash Tables, Disjoint Sets etc.In the Hash-table, the most of the time the searching time complexity is O(1), but ... Read More

Lock & Key problem using Hash-map

Ankith Reddy

Ankith Reddy

Updated on 17-Jun-2020 09:57:57

912 Views

A list of different locks and another list of keys are given. Our task is to find the correct match of lock and key from the given list, and assign that key with the lock when it is correct.In this approach we will traverse all of the locks and create ... Read More

Even Number With Prime Sum

Ankith Reddy

Ankith Reddy

Updated on 17-Jun-2020 09:27:18

1K+ Views

All even numbers from 4, can be expressed as a sum of two prime numbers. Sometimes a number can have more than one sum of the prime number combination.For an example the number 10 = (5 + 5) and (7 + 3)This algorithm will find all of the combinations of ... Read More

Check Perfect Square or Not

Ankith Reddy

Ankith Reddy

Updated on 17-Jun-2020 09:17:02

3K+ Views

A number is said to be a perfect square number if the square root of that number is an integer. In other words, when a square root is a whole number, then the number is called a perfect square number.We can check perfect square by finding the square root of ... Read More

Check whether a given point lies inside a Triangle

Ankith Reddy

Ankith Reddy

Updated on 17-Jun-2020 09:12:37

3K+ Views

Three points of a triangle are given; another point P is also given to check whether the point P is inside the triangle or not.To solve the problem, let consider the points of the triangle are A, B, and C. When the area of triangle Δ𝐴𝐵𝐶 = Δ𝐴𝐵𝑃 + Δ𝑃𝐵𝐶 ... Read More

Lagrange Interpolation

Ankith Reddy

Ankith Reddy

Updated on 17-Jun-2020 08:34:36

1K+ Views

For constructing new data points within a range of a discrete set of given data point, the interpolation technique is used. Lagrange interpolation technique is one of them. When the given data points are not evenly distributed, we can use this interpolation method to find the solution. For the Lagrange ... Read More

Weighted Job Scheduling

Ankith Reddy

Ankith Reddy

Updated on 17-Jun-2020 07:53:36

995 Views

A list of different jobs is given, with the starting time, the ending time and profit of that job are also provided for those jobs. Our task is to find a subset of jobs, where the profit is maximum and no jobs are overlapping each other.In this algorithm, we use ... Read More

Minimum number of squares whose sum equals to given number n

Ankith Reddy

Ankith Reddy

Updated on 17-Jun-2020 07:42:14

607 Views

Any numbers can be represented by the sum of some perfect square numbers. In this problem, we need to find that how many minimum numbers of perfect square terms are needed to represent the given value.let the value is 94, so 95 = 92 + 32 + 22 + 12. ... Read More

Advertisements