Found 7346 Articles for C++

Applications, Advantages and Disadvantages of Graph

Ayush Singh
Updated on 02-Aug-2023 15:48:03

3K+ Views

Graphs are used in different disciplines. They are utilised in biology to represent gene interactions, in transportation for route optimisation, and in social networks for user connection analysis. The visual representation of intricate relationships and the capacity to see patterns and trends are two benefits of graphs. However, dealing with large datasets can make graphs bulky and difficult to understand. Additionally, creating graphs can take time and necessitate knowledge. Despite these drawbacks, graphs continue to be an effective tool for data analysis and decision−making across a range of disciplines. Methods Used Set Representation Linked Representation Sequential Representaion Set ... Read More

Applications, Advantages and Disadvantages of Directed Graph

Ayush Singh
Updated on 02-Aug-2023 15:49:33

538 Views

Diverse domains, including CS, social networks, and logistics, use directed graphs, also known as digraphs. Arrows indicating the direction of links serve to depict the interconnections between the various components. They have the ability to represent intricate connections, handle data quickly, and facilitate pathfinding algorithms. Their drawbacks, however, include the potential for analysis complexity, the challenge of visualising vast graphs, and the requirement for cautious treatment of cyclic structures. Despite these drawbacks, directed graphs continue to be fundamental tools for comprehending, evaluating, and enhancing interconnected systems in a variety of real−world contexts. Methods Used Topological Sorting Strongly Connected Components ... Read More

Count of Nodes Accessible from all Other Nodes of Graph

Ayush Singh
Updated on 02-Aug-2023 15:43:25

299 Views

The number of nodes that may be reached from any particular node in a graph is called as the count of nodes accessible from all other nodes in the graph. It shows the degree of reachability and connectivity inside the graph. We start at each node and investigate all accessible routes to other nodes in order to get this count.The nodes we can access are recorded as we move across the graph. The count of reachable nodes in the graph includes all nodes that can be reached. This is vital for understanding network relationships and information flow efficiency. Methods Used ... Read More

Size of all Connected Non-Empty Cells of a Matrix

Shubham Vora
Updated on 02-Aug-2023 15:59:44

73 Views

In this problem, we will find the size of sets of all non−empty connected cells. We will learn two different approaches for finding the size of all non−empty connected cells of a matrix. In the first approach, we will use the breadth−first search algorithm, and in the second approach, we will use the depth−first search algorithm to traverse the matrix and find the size of all non-empty connected cells. Problem statement − We have given matrix[][] 2D array containing only 0 and 1. Here, 0 represents the empty cell, and 1 represents the non−empty cells. We need to find the ... Read More

Restore a Shuffled Queue as Per given Conditions

Shubham Vora
Updated on 02-Aug-2023 13:55:29

61 Views

In this problem, we have given the persona names and the number of taller people standing in front of that people. We can sort the position of the people according to the number of taller people standing in front of any person. After that, we update the position of each person according to the nums[] array value to get the original queue. Problem statement − We have given an array persons[] and nums[]. The persons[] array contains the person's name, and the nums[] array contains the number of taller people standing in front of each person. This queue is shuffled, ... Read More

Minimum Nodes to be Colored in a Graph such that every Node has a Colored Neighbour

Shubham Vora
Updated on 02-Aug-2023 13:53:47

62 Views

In this problem, we will color the minimum nodes of the graph such that each node of the graph has a colored node at the maximum distance 1. The simple logic to minimize the count of the colored node is that either color the nodes which are at an odd distance or color the nodes at an even distance. So, we can color the alternative node, and for each node, we can have a colored node at most distance 1. Problem statement − We have given a graph containing N nodes and E edges. It is given that we can ... Read More

Minimum Distance from a given Cell to all other Cells of a Matrix

Shubham Vora
Updated on 02-Aug-2023 13:51:23

122 Views

In this problem, we need to find the distance of each cell from the given cell of the matrix. We will use the Breadth−first search traversal to visit each cell of the matrix from the given cell and find the minimum distance for each cell. Problem statement − We have given rows, cols, a, and b positive integers. Here, rows and cols represent the matrix's total number of rows and columns. The a and b is the cell of the matrix. We need to find the minimum distance of each cell of the matrix from the (a, b) cell. ... Read More

Minimum Cost using Dijkstra by Modifying Cost of an Edge

Shubham Vora
Updated on 02-Aug-2023 13:49:54

213 Views

In this problem, we need to find the minimum path from 1 to N using Dijakstra’s algorithm, and we can update the cost of any single edge to cost/2. Here, we will find each node's distance from the source node to the destination node. After that, we will take the shortest distance of node u from the source and node v from the destination and add them with the cost/2 of the u −> v edge. In this way, we will find the minimum cost of path 1 to N. Problem statement − We have given an undirected graph ... Read More

Maximum Possible Array Sum after Performing given Operations

Shubham Vora
Updated on 02-Aug-2023 13:47:10

399 Views

In this problem, we will perform the given operations on the array elements and find the maximum sum at last. Here, in each operation, we can select at most X[p] elements from the array and replace them with the Y[p] elements to maximize the sum. In the naïve approach, we will find X[p] array elements, which are smaller than the Y[p] elements, and replace them with Y[p]. In the efficient approach, we will use the priority queue to get the maximum sum. Problem statement − We have given nums[] array containing the N numbers. Also, we have given ... Read More

Maximum Absolute difference between any two Level Sum in a Binary Tree

Shubham Vora
Updated on 02-Aug-2023 13:44:36

103 Views

In this problem, we will find the maximum absolute difference between the sum of all nodes of any two levels. We can use the queue data structure to traverse through each binary tree level. While traversing each level, we can keep track of the maximum and minimum sum and return the absolute difference at last. Problem statement − We have given a binary tree containing the positive and negative integer values. We need to find the maximum absolute difference of the sum of all nodes of any two levels. Sample examples Input ... Read More

Advertisements