- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7346 Articles for C++
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
536 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
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
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
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
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
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
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
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
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