Data Structure Articles

Page 73 of 164

Add and Remove Vertex in Adjacency Matrix Representation of Graph

Ayush Singh
Ayush Singh
Updated on 13-Jul-2023 985 Views

Including a vertex within the contagiousness network representation of a chart means expanding the measure of the network by one push and one column. The unused push and column speak to the associations of the recently included vertex with the existing vertices. Additionally, expelling a vertex requires evacuating its comparing push and column from the contagiousness lattice, subsequently altering the measure of the network in like manner. Including a vertex includes adding a push and column with beginning values of 0, whereas evacuating a vertex includes erasing the comparing push and column, viably decreasing the measure of the lattice. Methods ...

Read More

Add and Remove Edge in Adjacency List Representation of Graph

Ayush Singh
Ayush Singh
Updated on 13-Jul-2023 1K+ Views

Adjacency lists effectively store graph relationships. Graph algorithms and operations use it. Adding and deleting edges can dynamically change the connections between vertices. Graph modification, connection analysis, and evolution need this procedure.Adding and deleting edges link and detach vertices, respectively. The adjacency list representation commonly performs these actions by altering the vertices' adjacency lists. Using a vector of vectors, sets, or maps of sets may change the implementation.New edges create pathways and linkages in the graph. However, removing edges breaks connections, changing graph structure and dynamics. These procedures are essential for graph adjacency list integrity and evolution. Methods Used ...

Read More

Difference between Classification and Clustering

Kiran Kumar Panigrahi
Kiran Kumar Panigrahi
Updated on 12-Jul-2023 4K+ Views

The most basic difference between classification and clustering is that classification is used with supervised learning technique, whereas clustering is used with unsupervised learning technique. In classification, the computer is given a label to use in classifying new observations. For the label verification in this case, the machine requires thorough testing and training. Classification is therefore a more intricate procedure than clustering. In contrast, clustering is an unsupervised learning method that groups data based on similarities. Here, there is no need for training because the machine learns from the already−existing data. In this article, we will discuss the important ...

Read More

Convert a Binary String to Another by Flipping Prefixes a Minimum Number of Times

Prabhdeep Singh
Prabhdeep Singh
Updated on 11-Jul-2023 368 Views

Prefixes are the substrings that start from the zeroth index and could be of any size from 1 to the length of the given string. We are given two binary string which means both strings contain only two different types of characters and we have to make the first string equal to the second one by flipping the prefix a minimum number of times. Also, it is given that the length of both of the given strings is equal. Input 1 string str1 = "01100" string str2 = "10101" Output 3 Explanation Only operation that we can perform ...

Read More

Largest Roman Numeral Possible by Rearranging Characters of a Given String

Prabhdeep Singh
Prabhdeep Singh
Updated on 11-Jul-2023 300 Views

The characters represent Roman numbers: 'I', 'V', 'X', 'L', 'C', 'D', and 'M'. We will be given a string that may contain another character also (all the characters will be uppercase English alphabets) and we have to find the largest Roman numerical number possible by altering the position of the characters of the given string, also if it is not possible to get one, then we will return invalid as the answer. Input 1 string str = “VICML” Output MCLVI Explanation In the given string we have M have the greater value followed by the C, and then all ...

Read More

Java Program to Check if all Rows of a Matrix are Circular Rotations of Each Other

Prabhdeep Singh
Prabhdeep Singh
Updated on 11-Jul-2023 297 Views

Matrix consists of rows and columns to form a rectangular array. And circular rotations mean rotating the array's elements so that one rotation places the last element in the first position and the rest of the elements to the right. In this problem, we have given a matrix of n * n, and our task is to check if all rows of a matrix are circular rotations of each other then print “YES” otherwise print “NO”. Let's see examples with explanations below to understand the problem in a better way. Input 1 mat = [ [ 1, 5, 6], ...

Read More

Sort a string without altering the position of vowels

Prabhdeep Singh
Prabhdeep Singh
Updated on 11-Jul-2023 649 Views

Sorting a string means we have to arrange a given string either in an ascending or descending order or any given order. In this problem given a string 'str' of size n. Our aim is to sort the given string without altering means without changing the position of vowels present in the string. Let's see examples with explanations below to understand the problem in a better way. Sample Examples Input 1 str = “abdecokfee” Output 1 abcedofkee Explanation Constant present in the string = bdckf Sort the constant string = bcdfk Merge the given string with the sorted instant string ...

Read More

Maximum Number of 0s Placed Consecutively at the Start and End in any Rotation of a Binary String

Prabhdeep Singh
Prabhdeep Singh
Updated on 11-Jul-2023 235 Views

Binary string means the string contains only two types of char either 1 or 0. It is known as base 2. In this problem, we have given a binary string str and also the size of the string 'n'. Our task is to find the maximum number of zeros places consecutively at the start and end of any rotation of a binary string. Let's see examples with explanations below to understand the problem in a better way. Sample Example Input 1 str = “101001, n = 6 Output 1 2 Explanation The string can be rotated in any of the ...

Read More

C++ Program for Left Rotation and Right Rotation of a String

Prabhdeep Singh
Prabhdeep Singh
Updated on 11-Jul-2023 1K+ Views

Rotation means we have to shift each character forward or backward direction. In the case of forward, the last character is forwarded to the index 0 also known as right rotation. In the case of backward first character at index 0 is backward to the last index also known as left rotation. In this problem, we have given a string of characters and integer d. Our task is to print the left rotated string or right rotated string by d integer. Only the permutation of the current string changes, not the length or frequency of the characters in the ...

Read More

Java Program for Left Rotation and Right Rotation of a String

Prabhdeep Singh
Prabhdeep Singh
Updated on 11-Jul-2023 3K+ Views

Rotation means we have to shift each character either in a forward direction or backward direction. Forward direction means right rotation (Or anticlockwise) and backward direction means left rotation (Or clockwise). In this problem, we have given a string of characters of size n and integer d. Here d is less than n. Our task is to print the left rotated string or right rotated string by d integer. Only the permutation of the current string changes, not the length or frequency of the characters in the given string. Input 1 str = “apple”, d = 2 Output 1 Left ...

Read More
Showing 721–730 of 1,635 articles
« Prev 1 71 72 73 74 75 164 Next »
Advertisements