Sudhir sharma has Published 1149 Articles

C/C++ Program for nth Catalan Number?

sudhir sharma

sudhir sharma

Updated on 13-Aug-2019 06:45:25

595 Views

Catalan numbers are a sequence of numbers. Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects.Cn is the number of Dyck words of length 2n. A Dyck word is a string consisting of n X's and n Y's such that no ... Read More

Add minimum number to an array so that the sum becomes even in C programming

sudhir sharma

sudhir sharma

Updated on 09-Aug-2019 13:22:25

224 Views

Given an array, add the minimum number (which should be greater than 0) to the array so that the sum of array becomes even.Input - 1 2 3 4, Output - 2Explanation - Sum of array is 10, so we add minimum number 2 to make the sum even.Method 1: calculate the sum ... Read More

Arithmetic Mean in C programming

sudhir sharma

sudhir sharma

Updated on 09-Aug-2019 13:15:22

3K+ Views

Arithmetic mean is the sum of a collection of numbers divided by the number of numbers in the collection.Basic properties of Arithmetic MeanThe mean of n numbers x1, x2, . . ., xn is x. If each observation is increased by p, the mean of the new observations is (x ... Read More

C++ Program for Dijkstra’s shortest path algorithm?

sudhir sharma

sudhir sharma

Updated on 09-Aug-2019 13:08:53

16K+ Views

Dijkstra's algorithm (or Dijkstra's Shortest Path First algorithm, SPF algorithm) is an algorithm for finding the shortest paths between nodes in a graph, which may represent, for example, road networks. The algorithm creates a tree of shortest paths from the starting vertex, the source, to all other points in the ... Read More

C Program to Check if all digits of a number divide it

sudhir sharma

sudhir sharma

Updated on 09-Aug-2019 12:33:53

751 Views

For a number n given, we need to find whether all digits of n divide it or not i.e. if a number is ‘xy’ then both x and y should divide it.SampleInput - 24 Output - Yes Explanation  - 24 % 2 == 0, 24 % 4 == 0Using conditional statements checking if ... Read More

C Program to Check if a Given String is a Palindrome?

sudhir sharma

sudhir sharma

Updated on 09-Aug-2019 12:29:30

10K+ Views

A palindrome is a word, number, phrase, or other sequences of characters which reads the same backward as forward. Words such as madam or racecar or the number 10801 are a palindrome.For a given string if reversing the string gives the same string then we can say that the given ... Read More

Concatenate a string given number of times in C++ programming

sudhir sharma

sudhir sharma

Updated on 09-Aug-2019 12:24:08

789 Views

A program to concatenate a string a given number of times will run the string concatenate method n number of times based on the value of n.The result would be string repeated a number of times.Examplegiven string: “ I love Tutorials point” n = 5OutputI love Tutorials pointI love Tutorials ... Read More

Bitset all() function in C++ STL

sudhir sharma

sudhir sharma

Updated on 09-Aug-2019 12:21:03

175 Views

The bitset all() function an inbuilt function of the C++ STL( Standard Template Library). This function returns a Boolean value. The returned value is true if all the bits of the calling bitset are 1 else it will return false.The function does not accept any parameter and returns a Boolean ... Read More

bitset::flip() in C++ STL

sudhir sharma

sudhir sharma

Updated on 09-Aug-2019 12:18:27

585 Views

The bitset flip() method is an inbuilt method of C++ STL( Standard Template Library). It flips the bits of the calling bitset. This method flips all 0’s to 1’s and all 1’s to 0’s, which means it reverse each and every bit of the calling bitset when no parameter is ... Read More

Write a program to Delete a Tree in C programming

sudhir sharma

sudhir sharma

Updated on 09-Aug-2019 12:11:42

1K+ Views

To delete a tree we need to traverse each node of the tree and then delete each of them. this one by one delete every node of the tree and makes it empty. For this, we need to use a method that traverses the tree from bottom to up so ... Read More

Advertisements