Found 1862 Articles for Data Structure

Find two disjoint good sets of vertices in a given graph

Ayush Singh
Updated on 19-Jul-2023 11:59:25

91 Views

This article explains the perplexing process of finding two totally partitioned sets of vertices inside a given chart using a convoluted calculation. The substance of the calculation lies within the idea of chart colouring, wherein colours are efficiently relegated to vertices, guaranteeing that no adjoining vertices share the same colour. By taking this overly complex approach, the calculation shrewdly builds two dissimilar sets of vertices, each comprising vertices bearing particular colours. The paramount objective is to set up a clear boundary between these sets, rendering them void of any interconnection edges. The technique utilised encompasses a combination of strenuous methods, ... Read More

Find K vertices in the graph which are connected to at least one of remaining vertices

Ayush Singh
Updated on 19-Jul-2023 11:58:39

63 Views

Finding K vertices in the network that are connected to at least one of the remaining vertices may be done using DFS (Depth-First Search). Your beginning point should be one of the remaining vertices, and you should then perform a DFS on that vertex. Each vertex you come across while conducting the search will be noted, and it will be added to the group of similar vertices. Once K vertices have been located or all remaining vertices have been searched, keep repeating this. DFS aids in completing the assignment by carefully exploring the graph to find the K vertices that ... Read More

Count the nodes of the tree which make a pangram when concatenated with the sub-tree nodes

Ayush Singh
Updated on 19-Jul-2023 11:57:37

49 Views

To number the nodes of a tree that, when concatenated with their sub-tree hubs, shape a pangram, follow these steps: Begin at the root hub and navigate the tree in a depth-first way. At each hub, concatenate its value with the values of its sub-tree hubs. Check in case the coming string may be a pangram (contains all the letters of the letter set). On the off chance that it is, increase the tally. Recursively investigate the sub-tree hubs. At long last, return the number of hubs that fulfil the pangram condition. This approach guarantees that each hub within the ... Read More

Count the nodes of the given tree whose weight string is a palindrome

Ayush Singh
Updated on 19-Jul-2023 11:56:41

83 Views

We had to explore the tree and assess the weight of each hub in order to identify the nodes in a particular tree whose weighted string may be a palindrome. In this scenario, a hub's weight is seen as a string. The weight string is checked to see if it is a palindrome using the palindrome checking theory. We traverse the tree recursively, starting at the root, and evaluate the weight of each node. We raise the counter if the weight string is a palindrome. We can accurately examine the hubs that satisfy the requirement of having a weighted string ... Read More

Count the nodes of the given tree whose weight has X as a factor

Ayush Singh
Updated on 19-Jul-2023 11:55:31

55 Views

The assignment is to check the number of hubs in a given tree where the weight of each hub is detachable by a given number, X. To achieve this, we navigate the tree in a precise way, analysing each hub and its weight. In case the weight of a hub is distinct by X, we increase a counter. We proceed with this process for all hubs within the tree. Finally, the value of the counter speaks to the overall number of hubs within the tree, whose weight may be a figure of X. This approach guarantees that we recognise and ... Read More

Count the nodes of a tree whose weighted string is an anagram of the given string

Ayush Singh
Updated on 19-Jul-2023 11:54:23

56 Views

To check the nodes of a tree whose weighted string is a rearranged word of the given string, perform a depth-first search (DFS) on the tree. Beginning from the root, navigate each hub and calculate the weighted string by relegating a weight to each character within the node's esteem. Compare this weighted string with the given string to check for a rearranged word coordinate. In the event that they are rearranged words, increase the check. Recursively investigate the children of each node. At last, return the overall count of hubs fulfilling the condition. This approach guarantees each hub within the ... Read More

Count the nodes of a tree whose weighted string does not contain any duplicate characters

Ayush Singh
Updated on 19-Jul-2023 11:29:01

41 Views

To identify the hubs of a tree in preparation for a depth-first look (DFS) traversal and whose weighted string does not include any copy characters. We travel through each hub, starting at the root hub, keeping track of the characters we've already encountered in the weighted string. We stop providing navigational support down that path if we run upon a character who is already present in the collection. For each hub we pass throughout the traverse, we raise a check variable. The count variable will indicate the number of hubs in the tree whose weighted string does not include any ... Read More

Check if it is possible to assign values such that all the given relations are satisfied

Ayush Singh
Updated on 19-Jul-2023 11:27:01

29 Views

To check in the event that it is conceivable to dole out values such that all the given relations are fulfilled, we have to analyse the relations and decide on the off chance that they can be satisfied at the same time. This will be drawn closer by utilising limitation fulfilment methods. We look at each connection and its corresponding values. By methodically assessing the imperatives and endeavouring to dole out values that fulfil them, ready to decide in the event that a substantial task exists. In the event that we experience clashing limitations amid the method, showing an incomprehensible ... Read More

Build original array from the given sub-sequences

Ayush Singh
Updated on 19-Jul-2023 10:49:21

93 Views

The assignment is to recreate the initial cluster from a set of given sub-sequences. This includes finding the order in which the components showed up within the unique cluster based on the given subsequences. By analysing the designs and connections between the components within the subsequences, the calculation decides the right arrangement of the components and recreates the first cluster. The remade cluster speaks to the introductory grouping from which the subsequences were inferred. This preparation permits us to recuperate the first cluster structure and data, empowering the investigation or control of the information. Methods Used DFS Topological sorting ... Read More

Sum of numbers formed by consecutive digits present in a given string

Shubham Vora
Updated on 18-Jul-2023 17:31:33

216 Views

Problem Statement We have given a string str containing the numeric and alphabetical characters. We need to find the sum of all numbers represented by a continuous sequence of digits available in the given string. Sample Examples Input str = “12were43” Output 55 Explanation The sum of 12 and 43 is equal to 55. Input str = “1a2c3d” Output 6 Explanation The sum of 1, 2, and 3 is 6. Input str = “werderfrewsf” Output 0 Explanation It gives 0 in the output as the string contains no digit. Our logic to solve the ... Read More

Advertisements