Articles on Trending Technologies

Technical articles with clear explanations and examples

Nested Routing in React.js

Shyam Hande
Shyam Hande
Updated on 04-Sep-2019 509 Views

We have an app.jsx componentimport React, { Component } from 'react'; import { Link, Route, Switch } from 'react-router-dom'; import Category from './Category'; class App extends Component {    render() {       return (                                                         Main Page                   Users                                           ...

Read More

Navigation in React.js Routing

Shyam Hande
Shyam Hande
Updated on 04-Sep-2019 6K+ Views

We have an index.js file as −import React from 'react' import ReactDOM from 'react-dom' import './index.css' import { Route, Link, BrowserRouter } from 'react-router-dom' import App from './App' import AboutUs from './ AboutUs’; import ContactUs from './ContactUs'; const routs = (    < BrowserRouter >                                            Home                                        Users                 ...

Read More

React.js memo function in functional component

Shyam Hande
Shyam Hande
Updated on 04-Sep-2019 378 Views

We have shouldComponentUpdate in class based component as lifecycle method. This method can be used to achieve the performance optimization by comparing props (previous and next) and executing render conditionally .We have React.PureComponent as well which can do shallow comparison of state and props. But in functional component we don’t have such methods.Now, React has provided a memo method which will do the same functionality for the functional components.const functionalComponent = React.memo(function functionalComponent(props) {    /* render using props */ });We have wrapped the component inside the memo method. Memo method will memorize the result till the props are same. ...

Read More

Adding bootstrap to React.js project

Shyam Hande
Shyam Hande
Updated on 04-Sep-2019 2K+ Views

There are multiple ways to add bootstrap in react project.Using bootstrap CDNInstalling bootstrap dependencyUsing react bootstrap packagesUsing bootstrap CDNThis is the simplest way to add bootstrap. Like other CDN, we can add bootstrap CDN in index.html of the react project.Below is one of the react CDN urlIf we need the JavaScript components of bootstrap then we should add the jquery, popper.js in the index.htmlWith this the complete index.html will look like − React App hello             Adding bootstrap dependencynpm install bootstrap ...

Read More

Print the nodes of binary tree as they become the leaf node in C++ Programming.

Sunidhi Bansal
Sunidhi Bansal
Updated on 04-Sep-2019 204 Views

Given a binary tree, we have to print its leaf nodes and then we have to remove those leaf nodes and then repeat till there are no nodes left in the tree.ExampleSo the output of the problem should be −6 7 9 13 14 3 4 2 1ApproachWe have adopted an approach where we are applying DFS.For applying a temporary value zero is assigned to every value and then assign all the nodes with the value maximum(value of both child)+1.AlgorithmSTART STEP 1-> DEFINE A struct Node    WITH DATA MEMBERS data, order, *left, *right STEP 2-> DEFINE A struct Node* ...

Read More

Print matrix in zag-zag fashion in C Programming.

Sunidhi Bansal
Sunidhi Bansal
Updated on 04-Sep-2019 1K+ Views

Given a matrix mat[row][col] we have to print the given matrix in zig-zag fashion like in the given image below −So the output should be like −Output: 10 20 40 70 50 30 60 80 90For the above problem, we have followed a simple approach where we have to iterate the matrix diagonally and change the value of iteration to change the direction after every previous match.AlgorithmSTART STEP 1-> DECALRE AND SET k = 3, l = 3 STEP 2-> DECLARE A MATRIX mat[][3] STEP 3-> DECLARE AND SET row = 0, col = 0, flag = false; STEP 4-> ...

Read More

Print path between any two nodes in a Binary Tree in C++ Programming.

Sunidhi Bansal
Sunidhi Bansal
Updated on 04-Sep-2019 526 Views

We are given with a binary tree of distinct nodes and two nodes of the binary tree whose path in the binary tree we want to print.For Example − We want to print the path between node 140 to 211 so its output should be like −Output: 140->3->10->211The idea is to find paths form root nodes to the two nodes and store them in two separate vectors or arrays say path1 and path2.Now, there arise two different cases −If the two nodes are in different subtrees of root nodes − When the two nodes are in different subtrees like one ...

Read More

Print the first shortest root to leaf path in a Binary Tree in C++ Programming.

Sunidhi Bansal
Sunidhi Bansal
Updated on 04-Sep-2019 277 Views

Given the binary tree the program must find out the shortest path from the root to leaf amongst many given paths.Since we traverse the tree from left to right, so if there are multiple shortest paths from the root to leaf than the program will print the first traversed the shortest path on the left side of a tree.We can use a queue that will traverse each level using Level order traversal and the path with the least number of levels will be printed as it will be the shortest path from the root to leafIn the above tree, multiple ...

Read More

Print root to leaf paths without using recursion in C++ Programming.

Sunidhi Bansal
Sunidhi Bansal
Updated on 04-Sep-2019 294 Views

Given the binary tree the program must find out the multiple paths from the root to a leaf which means all the paths should be printed but the challenge is to without using recursion.We will traverse the tree iteratively as the constraint is to do it without recursion. So to achieve this we can use an STL map that will store the root element and whenever the leaf node is identified through level order traversal it will print the path from root to leaf as there is a map pointer which is pointing to a root node.In the above tree, ...

Read More

Print the nodes at odd levels of a tree in C++ Programming.

Sunidhi Bansal
Sunidhi Bansal
Updated on 04-Sep-2019 197 Views

Given the binary tree, the program must print the nodes at odd levels of a tree and the levels of a binary tree start from 1 to n.As nothing is mentioned one of the two approaches can be implemented i.e. recursion or iteration.Since we are using a recursive approach, the program will make a recursive call to a function that will be fetching the nodes at odd levels and returning them.In the above binary tree −Nodes at level 1: 10 Nodes at level 2: 3 and 211 Nodes at level 3: 140, 162, 100 and 146So, the nodes at level ...

Read More
Showing 55091–55100 of 61,248 articles
Advertisements