Found 1862 Articles for Data Structure

Check if any valid sequence is divisible by M

Divya Sahni
Updated on 25-Jul-2023 12:20:14

77 Views

A sequence is a collection of objects, and in our case, it is a collection of integers. The task is to find if a sequence with the usage of the addition and subtraction operator within the elements is divisible by M or not. Problem Statement Given an integer M and an array of integers. Using only addition and subtraction between elements check if there is a valid sequence whose solution is divisible by M. Sample Example 1 Input: M = 2, arr = {1, 2, 5} Output: TRUE Explanation − For the given array a valid sequence {1 ... Read More

XNOR of two numbers

Divya Sahni
Updated on 25-Jul-2023 12:16:12

371 Views

XNOR(Exclusive-NOR) gate is a digital logic gate that takes two inputs and gives one output. Its function is the logical complement of the Exclusive-OR (XOR) gate. The output is TRUE if both inputs are the same and FALSE if the inputs are different. The truth table of the XNOR gate is given below. A B Output 1 1 1 1 0 0 0 1 0 0 0 1 Problem Statement Given two numbers x and y. Find the XNOR of the two numbers. Sample Example 1 Input: x ... Read More

QuickSort using Random Pivoting

Divya Sahni
Updated on 04-Sep-2023 09:37:30

1K+ Views

Quick Sort is a Divide and Conquer algorithm. In this algorithm, we elect a pivot element and then partition the array around the pivot element. The two partitions are such that one part contains elements all lower than the pivot element and the other part contains elements all higher than the pivot element. Similarly, each part is further partitioned around a pivot selected in each part and this process is executed until one single element is reached. Choosing a Pivot A pivot can be chosen in an array as follows − A random pivot. Rightmost or leftmost element as ... Read More

Max occurring divisor in an interval

Divya Sahni
Updated on 25-Jul-2023 12:06:49

114 Views

Let x and y be two numbers. In this case, x is said to be a divisor of y if when y is divided by x it returns zero remainder. The maximum occurring divisor in an interval is the number that is a divisor of the maximum number of elements of that interval. Problem Statement Given an interval [a, b]. Find the maximum occurring divisor in the range including both a and b, except ‘1’. In case all divisors have equal occurrence, return 1. Sample Example 1 Input [2, 5] Output 2 Explanation − Divisors of 2 = ... Read More

Ramanujan–Nagell Conjecture

Divya Sahni
Updated on 25-Jul-2023 11:38:12

109 Views

Ramanujan-Nagell Equation is an example of the exponential Diophantine equation. The diophantine equation is a polynomial equation with integer coefficients of two or more unknowns. Only integral solutions are required for the Diophantine equation. Ramanujan-Nagell Equation is an equation between a square number and a number that is seven less than the power of 2, where the power of 2 can only be a natural number. Ramanujan conjectured that the diophantine equation 2y - 7 = x2 has positive integral solutions and was later proved by Nagell. $$\mathrm{2y−7=x^2\:has\:x\epsilon\:Z_+:x=1, 3, 5, 11, 181}$$ Triangular Number − It counts objects arranged in ... Read More

On Disk Data Structures

Way2Class
Updated on 20-Jul-2023 15:15:35

704 Views

Data is stored persistently on hard drives or other storage media using on-disk data structures, enabling access and modification even after a system restart or power loss. The retrieval, storage, and manipulation of data on the disc, which normally has longer access times and less bandwidth than memory, are all optimized by these data structures. The types of on-disk data structures, storage formats, data compression methods, indexing methods, sorting algorithms, performance concerns, and applications will all be covered in this article. What are On Disk Data Structures? On-disk data structures describe how data is kept on a tangible storage medium, ... Read More

Print the node with the maximum degree in the prufer sequence

Ayush Singh
Updated on 19-Jul-2023 12:02:01

79 Views

The node with the greatest degree within the Prufer grouping is the one that appears most often within the grouping. To discover it, we emphasise it through grouping and keep track of the frequencies of each hub. Once we have the frequencies, we select the hub with the most noteworthy recurrence as the hub with the maximum degree. This hub speaks to the leaf within the labelled tree. The Prufer grouping may be a one-of-a-kind representation of a labelled tree, where the maximum degree hub compares to the leaf that's included final amid the development preparation. By distinguishing this hub, ... Read More

Print the degree of every node from the given Prufer sequence

Ayush Singh
Updated on 19-Jul-2023 12:01:31

38 Views

To print the degree of each hub from a given Prufer arrangement, ready to emphasise through the arrangement and tally the events of each node. By following the recurrence of each node, we will determine the degree of that hub within the corresponding labelled tree. This data gives insights into the network and structure of the tree. By printing the degree of each hub, you are ready to analyse the conveyance and distinguish imperative hubs. This examination makes a difference in understanding the properties and characteristics of the initial tree based on the Prufer arrangement representation. Methods Used Frequency ... Read More

Number of trees whose sum of degrees of all the vertices is L

Ayush Singh
Updated on 19-Jul-2023 12:00:51

59 Views

The number of trees with a given whole number of degrees, L, can be decided by an equation based on the chart hypothesis. To begin with, we note that the whole number of degrees in a tree with N vertices is continuously 2N-2. Utilising this, we are able to calculate the number of clears out within the tree, which is L minus 2. Another way is to determine the number of inner vertices by subtracting the number of takeoffs from the overall number of vertices. At long last, we were able to discover the number of ways to disseminate the ... Read More

Maximum number of nodes which can be reached from each node in a graph

Ayush Singh
Updated on 19-Jul-2023 12:00:13

94 Views

In a graph, the most extreme number of hubs that can be reached from each hub depends on the structure and network of the chart. This value is determined by the number of active edges on each hub. In an undirected chart, each hub can reach all the hubs associated with it specifically, with the most extreme number of reachable hubs rising to the number of adjoining hubs. In a coordinated chart, the most extreme number of reachable hubs may shift for each hub, depending on the outdegree of each hub. The most noteworthy conceivable number of reachable hubs from ... Read More

Advertisements