 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 1321 of 2650
 
 
			
			275 Views
In this tutorial, we are going to learn how to find the density of the binary tree in a single traversal.The density of the binary tree is obtained by dividing the size of the tree by the height of the tree.The size of the binary tree is the total number of nodes present in the given binary tree.The height of the binary tree is the max depth of the leaf node from the root node.Let's see the steps to solve the problem.Initialize the binary tree dummy data.Find the size and height of the tree.Recursively count the height of the tree.Return ... Read More
 
 
			
			256 Views
In this tutorial, we are going to write a program that finds the total number of pairs (01 or 10) to free the binary string from the pairs (01 and 10). Let's see an example.Input − 101010001Output − 4In the above example, we have to delete a total of 4 pairs to free the binary string from the pairs (01 and 10).The resultant string after deleting all the pairs is 0.We have to delete all the 01 and 10 pairs from the binary string. So, the total number of pairs to be deleted is the minimum of count(1) and count(0).Let's ... Read More
 
 
			
			6K+ Views
In this tutorial, we are going to learn how to delete a node in a binary tree.The nodes in a binary tree don't follow any order like binary search trees. So, how to arrange the nodes after deleting a node in a binary tree?Well, we will replace the deepest node of the tree with the deleting node. And then we will delete the deepest node from the node.Let's see the steps to solve the problem.Initialize the tree with binary node struct.Write a function (preorder, in order, and postorder) to print the nodes of the tree.Write a function to delete the ... Read More
 
 
			
			2K+ Views
In this tutorial, we are going to learn how to delete a binary tree using the delete keyword.We are going to use a destructor member function to delete the binary. The destructor member function is invoked automatically when the object goes out of the scope or it is destroyed by calling delete.The destructor member function has the name as a class with tilde (~) before it.Let's see the steps to solve the problem.Write a class called Node.Write a constructor function that accepts data for the node.Write a destructor function.Delete the left node.Delete the right node.Print the current node data.Initialize the ... Read More
 
 
			
			866 Views
In this tutorial, we are going to learn how to delete N nodes after M nodes in a linked list.Let's see the steps to solve the problem.Write a struct Node for the linked list node.Initialize the linked list with the dummy data.Write a function to delete N nodes after M nodes.Initialize a pointer with the head pointer.Iterate till the end of the linked list.Move the pointer to the next node until M nodes.Delete the N nodesMove the pointer to the next nodePrint the linked listExampleLet's see the code. Live Demo#include using namespace std; struct Node { int data; ... Read More
 
 
			
			3K+ Views
In this tutorial, we are going to learn how to delete the middle node in a linked list.The solution to the problem is straightforward. We will have two pointers one moves one node at a time and the other one moves two nodes at a time. By the time the second pointer reaches the final node, the first will be in the middle of the linked list.Let's see the steps to solve the problem.Write a struct Node for the linked list node.Initialize the linked list with the dummy data.Write a function to delete the linked list.Initialize two-pointers (slow and fast) ... Read More
 
 
			
			126 Views
In this tutorial, we are going to learn how to delete the leaf nodes from a tree with the given value.Let's see the steps to solve the problem.Write a struct Node for a binary tree.Write a function to traverse (inorder, preorder, postorder) through the tree and print all data.Initialize the tree by creating nodes with the struct.Initialize the x value.Write a function to delete the leaf nodes with the given value. It accepts two arguments root node and k value.If the root is a null return.Replace the left node of the root with a new root after deletion.Same with the ... Read More
 
 
			
			1K+ Views
In this tutorial, we are going to learn how to delete the leaf nodes from a tree with the given value.Let's see the steps to solve the problem.Write a struct Node for a binary tree.Write a function to traverse (inorder, preorder, postorder) through the tree and print all data.Initialize the tree by creating nodes with the struct.Initialize the x value.Write a function to delete the leaf nodes with the given value. It accepts two arguments root node and x value.If the root is a null return.Replace the left node of the root with a new root after deletion.Same with the ... Read More
 
 
			
			21K+ Views
In this tutorial, we are going to learn how to delete elements from the given range. Let's see the steps to solve the problem.Initialize the array and range to delete the elements from.Initialize a new index variable.Iterate over the array.If the current index is not in the given range, then update the element in the array with a new index variableIncrement the new index.Return the new index.ExampleLet's see the code. Live Demo#include using namespace std; int deleteElementsInRange(int arr[], int n, int l, int r) { int i, newIndex = 0; for (i = 0; i < n; i++) ... Read More
 
 
			
			422 Views
In this tutorial, we are going to learn how to delete an element with two loops and on loop. We don't need to delete the element. We will just replace the deleting element with the next elements.Two TraversalsLet's see the steps to delete an element from the array using two loops.Initialize the array and delete the element.Write a function to delete the element.Iterate over the array and search for the element.If the element found, break the loop.If the element is found, decrease the size of the array.Move all the elements to their previous index.Return the new size of the array.ExampleLet's ... Read More