Postorder Tree Traversal in Data Structures

Arnab Chakraborty
Updated on 21-Jan-2020 12:17:37

462 Views

In this section we will see the post-order traversal technique (recursive) for binary search tree.Suppose we have one tree like this −The traversal sequence will be like: 8, 5, 15, 23, 20, 16, 10AlgorithmpostorderTraverse(root): Begin    if root is not empty, then       postorderTraversal(left of root)       postorderTraversal(right of root)       print the value of root    end if EndExample Live Demo#include using namespace std; class node{    public:       int h_left, h_right, bf, value;       node *left, *right; }; class tree{    private:       node *get_node(int key);   ... Read More

Wildcards in Generics in Java

Maruthi Krishna
Updated on 21-Jan-2020 12:16:39

2K+ Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class as generic you are making it type-safe i.e. it can act up on any datatype.To define a generic class you need to specify the type parameter you are using in the angle brackets “” after the class name and you can treat this as datatype of the instance variable an ... Read More

Helpful Insights to Control Project Costs

karthikeya Boyini
Updated on 21-Jan-2020 12:12:19

133 Views

Managing a project is not everybody’s cup of tea. There are many aspects of the projects which we need to plan and manage perfectly to achieve the desired success, whether it is the scope, schedule, cost or quality. It is also seen that many times, the project runs into trouble only because the Project Manager fails to monitor and control the project cost.So it is important to manage the project cost throughout the project with proper planning and controlling the project budget. To manage the project cost effectively, there are certain activities which we need to perform initially.Planning the Cost: ... Read More

Maximum Size Subset with Given Sum in C++

Narendra Kumar
Updated on 21-Jan-2020 11:30:13

784 Views

Problem statementGiven an array of N elements and sum. We need to find size of maximum size subset whose sum is equal to given sumExampleIf input array is arr = { 2, 3, 5, 10 } and sum = 20 then output will be 4 as −2 + 3 + 5 + 10 = 20 which is equal to given sumAlgorithmWe can use dynamic programming to solve this problem.To count the maximal subset, we use another DP array (called as ‘count array’) where count[i][j] is maximal of.count[i][j-1]. Here current element is not considered.scount[i- X][j-1] + 1. Here X is value ... Read More

Maximum Profit from Sale of Wines in C++

Narendra Kumar
Updated on 21-Jan-2020 11:17:53

219 Views

Problem statementGiven n wines in a row, with integers denoting the cost of each wine respectively. Each year you can sale the first or the last wine in the row. The price of wines increases over time. Let the initial profits from the wines be P1, P2, P3…Pn. On the Yth year, the profit from the ith wine will be Y*Pi. For each year, your task is to print start or end denoting whether first or last wine should be sold. Also, calculate the maximum profit from all the wines.ExampleIf wine prices are {2, 4, 6, 2, 5} then output ... Read More

Maximum Prefix Sum for a Given Range in C++

Narendra Kumar
Updated on 21-Jan-2020 11:10:19

737 Views

Problem statementGiven an array of n integers and q queries, each query having a range from l to r. Find the maximum prefix-sum for the range l – r.ExampleIf input array is arr[] = {-1, 2, 3, -5} and queries = 2 and ranges are: l = 0, r = 3 l = 1, r = 3 then output will be 4 and 5.The range (0, 3) in the 1st query has [-1, 2, 3, -5], since it is prefix, we have to start from -1. Hence, the max prefix sum will be -1 + 2 + 3 = 4The ... Read More

Find List of Daemon Processes and Zombie Processes in Linux

karthikeya Boyini
Updated on 21-Jan-2020 11:08:44

6K+ Views

This article will guide you to understand the Zombie process and Daemons, and also help us to find the process which is running in the background.What is Zombie Process?When a process ends the execution, then it will have an exit status to report to its master process. Because of that little bit of information, the process will remain in the OS process table as a zombie process, which indicates that it is not to be scheduled for future, but this process cannot be completely removed or the process ID will not be used until the exit has been determined and ... Read More

Maximum Perimeter Triangle from Array in C++

Narendra Kumar
Updated on 21-Jan-2020 10:58:36

321 Views

Problem statementGiven an Array of non-negative integers. Find out three elements from the array which form a triangle of maximum perimeterExampleIf input array is {5, 1, 3, 5, 7, 4} then maximum perimeter is (7 + 5 + 5) = 17AlgorithmSort the array in non-increasing order. So, the first element will be maximum and the last will be minimumIf the first 3 elements of this sorted array forms a triangle, then it will be the maximum perimeter triangleExample Live Demo#include using namespace std; int getMaxPerimeter(int *arr, int n) {    sort(arr, arr + n, greater());    int maxPerimeter = 0; ... Read More

Enable or Add Swap Space on Ubuntu 16.04

karthikeya Boyini
Updated on 21-Jan-2020 10:48:13

523 Views

In this article, we will learn how to enable or add the swap partition on Ubuntu 16.04, actually, the swap will increase the chance of responsiveness of the servers by guarding the out of memory errors for the applications, by default Ubuntu will not enable the swap space. We will learn how to add or enable the swap file for Ubuntu 16.04 servers.Swap is the location or the file which can handle the temporary data which is not required immediately by RAM but will be used to increase the amount of information that the server can handle for its working ... Read More

Enable and Install Third-Party Packages Using EPEL Repository on CentOS/RHEL

Sharon Christine
Updated on 21-Jan-2020 10:42:03

1K+ Views

In this article we shall try to learn, how to add EPEL Repository for Linux. EPEL (Extra Package for Enterprise Linux) is an open source and free community based repository from the Fedora community team which provides high quality and good add-on software’s for Linux distributions. It has Red Hat Enter Linux, CentOS, Scientific Linux and most of the repositories which are maintained by the Fedora team only.Why we use EPEL Repositories for PackagesProvides a lot of open source packages which are installed using yum.EPEL repositories are open source and they are 100% free to use.There will not be any ... Read More

Advertisements