Ayush Gupta

Ayush Gupta

433 Articles Published

Articles by Ayush Gupta

Page 44 of 44

Program to print nodes in the Top View of Binary Tree using C++

Ayush Gupta
Ayush Gupta
Updated on 01-Nov-2019 297 Views

In this tutorial, we will be discussing a program to print all the nodes that appear in the top view of a given binary tree.For a particular binary tree, a node appears in its top view if it is the very first node at its horizontal distance. Horizontal distance for the left node of a node x is x-1 and for the right node of node x is x+1.To solve this, we will do the level order traversal so that we get the topmost node for a particular level before the other nodes present at that level. Further, we will ...

Read More

Program to print nodes between two given level numbers of a binary tree using C++

Ayush Gupta
Ayush Gupta
Updated on 01-Nov-2019 212 Views

In this tutorial, we will be discussing a program to print nodes between the two given level numbers of a binary tree.In this, we will be given a low level and a high level for a particular binary tree and we have to print all the elements between the given levels.To solve this we can use queue-based level traversal. While moving through inorder traversal we can have a marking node at the end of each level. Then we can go to each level and print its nodes if the marking node exists between the given levels.Example#include #include using ...

Read More

C++ program to find cabs nearby using Great Circle Distance formula

Ayush Gupta
Ayush Gupta
Updated on 03-Oct-2019 688 Views

In this article, we will be discussing a program to find the cabs near about (less than 50km) using the Great Circle Distance formula.Let us suppose we have been given a JSON file which contains the name and coordinates of the people who need a cab and also the coordinates of the all the cabs available.To solve this, we would convert the GPS coordinates into double. From the double form, we would finally convert them in degrees to radians. Then we can ultimately apply the Great Circle Distance formula to find the cabs available in 50km from the user’s position.Note ...

Read More
Showing 431–433 of 433 articles
« Prev 1 40 41 42 43 44 Next »
Advertisements