Found 7347 Articles for C++

C++ Program for the BogoSort or Permutation Sort?

sudhir sharma
Updated on 19-Aug-2019 12:51:50

672 Views

Bogosort simply shuffles a collection randomly until it is sorted. BogoSort is an ineffective algorithm based permutation and combination that's why it is known Permutation sort. BogoSort is very flop sorting technique which is also known as, shotgun sort, stupid sort, monkey sort, or slow sort. The algorithm successively generates permutations of its input until it finds one that is sorted.Input - 53421 Output - 12345ExplanationIn bogosort array will be consist of unsorted element checking if the array elements are in order, and if it is not, then change the position of array elements, by swapping the elements randomly, and ... Read More

acosh() function for complex number in C++

sudhir sharma
Updated on 19-Aug-2019 08:47:55

94 Views

The acosh() is the inverse hyperbolic cosine function that returns the inverse hyperbolic cosine of the element passed as parameter. this dysfunction can be out operate over complete. all the it are in radians.To use this method over complex numbers in C plus plus we need to define a template which redefines the function over complex numbers.Syntax for the function that is used to calculate the inverse hyperbolic cosine of a complex number and Returns the value −template complex acosh (const complex& z );Now this method will take complex number as an input and returns the Arc hyperbolic cosine of ... Read More

C++ STL asinh() function

sudhir sharma
Updated on 19-Aug-2019 08:45:48

78 Views

The asinh() function is a function of standard C++ library. The asinh(value) is an inverse hyperbolic sine that returns the value of sinh(x) where x is in radian.The function −asinh() ;Parameter to the function, inverse hyperbolic angle in radian . It can be negative, positive or zero. The parameter value can be double, float or long double.Return value − It returns the inverse hyperbolic sine value of the input value. The returned value is in radians.Lets see an example that shows the working of the function −Example#include using namespace std; int main() {    double insinh = 75.0;    double ... Read More

Bidirectional Search?

sudhir sharma
Updated on 19-Aug-2019 08:11:25

2K+ Views

A bidirectional search is a searching technique that runs two way. It works with two who searches that run simultaneously, first one from source too goal and the other one from goal to source in a backward direction. In in an optimal state, both the searches will meet in the middle off the data structure.The bidirectional search algorithm works on a directed graph to find the shortest path between the source(initial node) to the goal node. The two searches will start from their respective places and the algorithm stops when the two searches meet at a node.Importance of the bidirectional ... Read More

C++ Bidirectional Iterators

sudhir sharma
Updated on 19-Aug-2019 08:07:41

191 Views

The iterators that have the privilege to access the sequence of elements of a range from both the directions that are from the end and from the beginning are known as bidirectional iterators. iterators can work on data types like list map and sets.Bidirectional iterators have the same properties as forwarding iterators, with the only difference that they can also be decremented −propertyvalid expressionsIs default-constructible, copy-constructible, copy-assignable and destructibleX a;X b(a);b = a;Can be compared for equivalence using the equality/inequality operators (meaningful when both iterator values iterate over the same underlying sequence).a == ba != bCan be dereferenced as an ... Read More

Armstrong Numbers between two integers?

sudhir sharma
Updated on 19-Aug-2019 12:57:02

884 Views

An integer is called an Armstrong number of order n if it's every digit separate out and cubed and summed up then the sum will be same as the number i.e. abcd... = a3 + b3 + c3 + d3 + ...In case of an Armstrong number of 3 digits, the sum of cubes of each digit is equal to the number itself. For example:153 = 13 + 53 + 33 // 153 is an Armstrong number.Input: Enter two numbers(intervals):999 9999 Output: Armstrong numbers between 999 and 9999 are: 1634 8208 9474Explanation1634 = 13+63+33+43 = 1+216+27+64 = 1634The approach implemented ... Read More

C++ Program for QuickSort?

sudhir sharma
Updated on 19-Aug-2019 12:57:53

1K+ Views

Quicksort is a sorting technique which uses comparisons to sort an unsorted list( array ). Quicksort is also known as partition exchange sort.It is not a stable sort, Because the relative order of equal sort items is not preserved. Quicksort can operate on an array, requiring small additional amounts of memory to perform the sorting. It is very similar to selection sort, except that it does not always choose worst-case partition. So, so we can take it as a better formed of selection Sort.QuickSort is one of the most efficient sorting algorithms and is based on the splitting of an ... Read More

C++ Program for Pigeonhole Sort?

sudhir sharma
Updated on 19-Aug-2019 07:58:11

434 Views

Pigeonhole Sort is an example of the non-comparison sorting technique. It is used where the number of items and the range of possible key values is approximately the same.To perform this sort, we need to make some holes. The number of holes needed is decided by the range of numbers. In each hole, items are inserted. Finally deleted from the hole and stored into an array for sorted order.Pigeonhole sorting, also known as count sort, is a sorting algorithm that is suitable for sorting lists of elements where the number of elements (n) and the number of possible key values ... Read More

Advantages of vector over the array in C++?

sudhir sharma
Updated on 19-Aug-2019 07:53:16

3K+ Views

Vector is a template class and is C++ only construct whereas arrays are built-in language construct and present in both C and C++.Vector are implemented as dynamic arrays with list interface whereas arrays can be implemented as statically or dynamically with primitive data type interface.Differences between a Vector and an ArrayA vector is a dynamic array, whose size can be increased, whereas THE array size can not be changed.Reserve space can be given for vector, whereas for arrays you cannot give reserved space.A vector is a class whereas an array is a datatype.Vectors can store any type of objects, whereas ... Read More

C/C++ Program to Find the reminder of array multiplication divided by n?

sudhir sharma
Updated on 19-Aug-2019 12:58:56

111 Views

Array multiplication we will find the product of all elements of the given array. and then according to the problem, we will divide the product with the number n. let's take an example −Input: arr[] = { 12, 35, 69, 74, 165, 54};       N = 47 Output: 14ExplanationThe array is like {12, 35, 69, 74, 165, 54} so the multiplication will be (12 * 35 * 69 * 74 * 165 * 54) = 19107673200. Now if we want to get the remainder after dividing this by 47 it will be 14.First multiple all the number then ... Read More

Advertisements