Segregate a Given Linked List in C++

Dev Prakash Sharma
Updated on 23-Feb-2021 05:22:40

247 Views

A Linked List is a linear data structure in which each node has two blocks such that one block contains the value or data of the node and the other block contains the address of the next field.Let us assume that we have a linked list such that each node contains the data and a pointer which is pointing to the next node of the linked list. The task is to segregate the given Linked List. Segregating the linked list means we have to separate the odd indexed nodes and even index nodes in the list.Approach to Solve this ProblemTo ... Read More

Check If a Tree is Isomorphic or Not in C++

Dev Prakash Sharma
Updated on 23-Feb-2021 04:50:26

387 Views

In a binary tree, each node contains two children, i.e., left child and right child. Let us suppose we have two binary trees and the task is to check if one of the tree can be obtained by flipping another tree by left of it or not.A Tree is Isomorphic if it can be obtained by flipping the other tree in its left side.For ExampleInput-1Output: IsomorphicExplanation: The given Tree-2 can be obtained by flipping the Tree-1 in the left side, thus the Tree is isomorphic.Approach to Solve this ProblemA recursive approach to solve this particular problem is that a Boolean function will ... Read More

Breadth First Search on Matrix in C++

Dev Prakash Sharma
Updated on 23-Feb-2021 04:49:36

1K+ Views

In a given matrix, there are four objects to analyze the element position: left, right, bottom and top.Breadth First Search is nothing but finding the shortest distance between the two elements of a given 2-D Matrix. Thus in each cell, there are four operations we can perform which can be expressed in four numerals such as, '2' describes that the cell in the matrix is Source.'3' describes that the cell in the matrix is Destination.'1' describes that the cell can be moved further in a direction.'0' describes that the cell in the matrix can not be moved in any direction.On ... Read More

Binary Tree Tilt in C++

Dev Prakash Sharma
Updated on 23-Feb-2021 04:47:44

344 Views

Let us consider that we have the root node of a binary tree; the task is to find and return the sum of tilt of every node.The tilt of a binary tree is nothing but constructing the binary tree by finding the absolute difference of child nodes in the left subtree and the right subtree in each level. At some particular level, the nodes which don't have any child nodes, we simply tilt by replacing that node with zero.ExampleInputOutput: 15Explanation: Finding the tilt at every level of the given binary tree, The tilt of node 3 = 0The tilt of node ... Read More

Take Screenshot of a DIV with JavaScript

AmitDiwan
Updated on 22-Feb-2021 14:01:44

2K+ Views

We are required to capture (convert into image) part(s) of our markup that lays out our website and save that captured image or do something with it. So, we are required to devise a way using which we can achieve this described behaviour.As our problem includes capturing any markup element and not just canvas, it’s a bit complex and especially if we plan to do it from scratch. Therefore, for our ease we will use a third party library, htmltocanvas that does exactly what the name suggests, converting the desired markup to canvas, after which we can simply download the canvas ... Read More

Directed Acyclic Graph (DAG)

Moumita
Updated on 22-Feb-2021 11:57:05

15K+ Views

DefinitionIn computer science and mathematics, a directed acyclic graph (DAG) refers to a directed graph which has no directed cycles.ExplanationIn graph theory, a graph refers to a set of vertices which are connected by lines called edges. In a directed graph or a digraph, each edge is associated with a direction from a start vertex to an end vertex. If we traverse along the direction of the edges and we find that no closed loops are formed along any path, we say that there are no directed cycles. The graph formed is a directed acyclic graph.A DAG is always topologically ... Read More

Dijkstra's Algorithm to Compute the Shortest Path Through a Graph

Moumita
Updated on 22-Feb-2021 11:38:19

21K+ Views

DefinitionThe Dijkstra’s algorithm finds the shortest path from a particular node, called the source node to every other node in a connected graph. It produces a shortest path tree with the source node as the root. It is profoundly used in computer networks to generate optimal routes with the aim of minimizing routing costs.Dijkstra’s AlgorithmInput − A graph representing the network; and a source node, sOutput − A shortest path tree, spt[], with s as the root node.Initializations −An array of distances dist[] of size |V| (number of nodes), where dist[s] = 0 and dist[u] = ∞ (infinite), where u ... Read More

Flooding vs Fixed Routing Algorithms

Moumita
Updated on 22-Feb-2021 11:25:54

2K+ Views

Flooding and fixed routing are methods to transmit data packets from the source to the destination through a number of intermediate routers connected by transmission lines.Flooding is a non-adaptive routing technique following this simple method − when a data packet arrives at a router, it is sent to all the outgoing links except the one it has arrived on.Fixed routing algorithm is a procedure that lays down a fixed route or path to transfer data packets from source to the destination. The route is a mathematically computed best path, i.e. “least–cost path” that the packet can be routed through. The ... Read More

Use TensorFlow with Estimators for Feature Engineering

AmitDiwan
Updated on 22-Feb-2021 10:52:20

215 Views

Tensorflow can be used with estimators for feature engineering by first defining the columns and iterating through the categorical columns. The unique names of features are obtained, and is appended to an empty list.Read More: What is TensorFlow and how Keras work with TensorFlow to create Neural Networks?We will use the Keras Sequential API, which is helpful in building a sequential model that is used to work with a plain stack of layers, where every layer has exactly one input tensor and one output tensor.A neural network that contains at least one layer is known as a convolutional layer. We ... Read More

Use TensorFlow with Estimators to Visualize Titanic Data

AmitDiwan
Updated on 22-Feb-2021 10:49:51

116 Views

The titanic dataset can be visualized using the ‘hist’ method which visualizes a histogram. A horizontal bar graph can be generated by specifying the type of graph as ‘barh’. Read More: What is TensorFlow and how Keras work with TensorFlow to create Neural Networks?We will use the Keras Sequential API, which is helpful in building a sequential model that is used to work with a plain stack of layers, where every layer has exactly one input tensor and one output tensor.TensorFlow Text contains collection of text related classes and ops that can be used with TensorFlow 2.0. The TensorFlow Text can ... Read More

Advertisements