Category: Technical Scripter 2020

Tutorial on Binary Tree

The tree is a hierarchical Data Structure. A binary tree is a tree that has at most two children. The node which is on the left of the Binary Tree is called “Left-Child” and the node which is the right is called “Right-Child”. Also, the smaller tree or the subtree in the left of the […]

Continue Reading

Construct a Tree whose sum of nodes of any path is not divisible by the count of nodes in that path

   #include using namespace std;    void assignValues(int Edges[][2], int n) {          vector tree[n + 1];             for (int i = 0; i < n - 1; i++) {            int u = Edges[i][0];         int v = Edges[i][1];         tree[u].push_back(v);         tree[v].push_back(u);     }                  vector visited(n + 1, false);             vector answer(n […]

Continue Reading

Check if a given pattern exists in a given string or not

import java.io.*; class GFG {                    static boolean isMatch(String text,                            String pattern)     {                  if (text == null || pattern == null) {             return false;         }                  int N = text.length();                  int M = pattern.length();                           boolean[][] dp = new boolean[N + 1][M + 1];                  dp[0][0] = true;                   […]

Continue Reading

Modulo Operations in Programming With Negative Results

In programming, the modulo operation gives the remainder or signed remainder of a division, after one integer is divided by another integer. It is one of the most used operators in programming. This article discusses when and why the modulo operation yields a negative result. Examples: In C, 3 % 2 returns 1. However, -3 […]

Continue Reading

Path from a given source to a given destination having Kth largest weight in a Graph

   import java.io.*; import java.util.*;    class Edge {             int src;             int nbr;             int wt;             Edge(int src, int nbr, int wt)     {         this.src = src;         this.nbr = nbr;         this.wt = wt;     } }    class Pair implements Comparable {             int wsf;             String psf; […]

Continue Reading

Minimum removals required such that given string consists only of a pair of alternating characters

Minimum removals required such that given string consists only of a pair of alternating characters Given a string S, the task is to find the minimum removal of characters required such that the string S consists only of two alternating characters. Examples: Input: S = “adebbeeaebd”Output: 7Explanation: Removing all occurrences of ‘b’ and ‘e’ modifies […]

Continue Reading

10 Tips to Improve Logic Building Skills in Programming

“In some ways, programming is like a painting. You start with a blank canvas and certain basic raw materials. You use a combination of science, art, and craft to determine what to do with them.” — Andrew Hunt Yes, programming in itself is a very beautiful art. Sometimes we may face some problems while trying […]

Continue Reading