Arjun Thakur has Published 1025 Articles

Can you please explain Python dictionary memory usage?

Arjun Thakur

Arjun Thakur

Updated on 17-Jun-2020 11:40:07

734 Views

The dictionary consists of a number of buckets. Each of these buckets containsthe hash code of the object currently stored (that is not predictable from the position of the bucket due to the collision resolution strategy used)a pointer to the key objecta pointer to the value objectThis sums up to ... Read More

How to Pretty print Python dictionary from command line?

Arjun Thakur

Arjun Thakur

Updated on 17-Jun-2020 11:14:32

1K+ Views

You can pretty print a dict in python using the pprint library. The pprint module provides a capability to “pretty-print” arbitrary Python data structures in a form which can be used as input to the interpreter. You can use it as followsExamplea = {    'bar': 22,    'foo': 45 ... Read More

Jarvis March Algorithm

Arjun Thakur

Arjun Thakur

Updated on 17-Jun-2020 09:59:36

4K+ Views

Jarvis March algorithm is used to detect the corner points of a convex hull from a given set of data points.Starting from a leftmost point of the data set, we keep the points in the convex hull by anti-clockwise rotation. From a current point, we can choose the next point ... Read More

Print all permutations of a given string

Arjun Thakur

Arjun Thakur

Updated on 17-Jun-2020 09:55:28

2K+ Views

Printing all permutations of a given string is an example of backtracking problem. We will reduce the size of the substring to solve the sub-problems, then again backtrack to get another permutation from that section.For an example, if the string is ABC, the all permutations will be ABC, ACB, BAC, ... Read More

Connect n ropes with minimum cost

Arjun Thakur

Arjun Thakur

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

934 Views

There are N ropes of given lengths. We have to connect with them. The cost of connecting one rope with other is the sum of their lengths. Our goal is to connect the N ropes with minimum cost.This problem can be solved using a heap tree. We will create min ... Read More

Check if a given point lies inside a Polygon

Arjun Thakur

Arjun Thakur

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

3K+ Views

In this problem, one polygon is given, and a point P is also given. We need to check whether the point is inside the polygon or outside the polygon.For solving it we will draw a straight line from the point P. It extends to the infinity. The line is horizontal, ... Read More

Minimum number of coins that make a given value

Arjun Thakur

Arjun Thakur

Updated on 17-Jun-2020 07:44:20

2K+ Views

There is a list of coin C(c1, c2, ……Cn) is given and a value V is also given. Now the problem is to use the minimum number of coins to make the chance V.Note: Assume there is the infinite number of coins C.In this problem, we will consider a set ... Read More

Mobile Numeric Keypad Problem

Arjun Thakur

Arjun Thakur

Updated on 17-Jun-2020 07:31:04

1K+ Views

In this problem, a Numeric mobile keypad is given. We can only press top, bottom, right and left buttons of the current button, diagonal keys are not Allowed. We also cannot press the * and # buttons in the keypad.A digit is given, we have to find the number of ... Read More

Collect maximum points in a grid using two traversals

Arjun Thakur

Arjun Thakur

Updated on 16-Jun-2020 15:18:04

369 Views

There is a matrix with points in each cell, how to get maximum points from that grid using two traversals.There is some condition to satisfy −The first traversal starts from the top left cell in the grid and should go to the bottom left corner.      And in the ... Read More

Count possible ways to construct buildings

Arjun Thakur

Arjun Thakur

Updated on 16-Jun-2020 14:50:22

630 Views

Here n number of sections are given, in each section, there are two sides on the road to constructing buildings. If there is one empty space between two houses are needed, then how many possible ways to construct buildings in the plot.There are four possibilities to construct buildings One side of ... Read More

Advertisements