Convert String to Hold Only Distinct Characters in C++

Ayush Gupta
Updated on 16-Jan-2020 07:36:25

259 Views

In this tutorial, we will be discussing a program to convert given string so that it holds only distinct characters.For this we will be provided with a string. Our task is to traverse through the string and replace all the recurring characters with any random characters that are not already present into the string.Example Live Demo#include using namespace std; //collecting the distinct characters //in the string int calculate_zero(int i, int occurrences[]){    while (i < 26) {       //if it is present only once       if (occurrences[i] == 0)          return i;     ... Read More

Best Skylines of the World

Samual Sam
Updated on 16-Jan-2020 07:31:28

811 Views

Pick up a dictionary and a skyline is defined as the outline of a group of buildings seen against the sky. In the last century, cities from around the world have not only grown to cover enormous swaths of land spaces horizontally but have grown upwards as if to touch the sky , in a human effort to make stairways to heaven.These high-rises are the business centers of modern cities and appear to keep a watchful eye on the city life below, all round the clock. In this article we bring you the best sky grazing skylines from across the ... Read More

Convert Array to Arithmetic Progression by Adding an Element in C++

Ayush Gupta
Updated on 16-Jan-2020 07:29:56

230 Views

In this tutorial, we will be discussing a program to convert given array to arithmetic progression by adding an element.For this we will be provided with an array. Our task is to convert the given array into an arithmetic progression by adding a single element to it and return the added element. If it is not possible, return -1.Example Live Demo#include using namespace std; //returning the number to be added int print_number(int arr[], int n){    sort(arr, arr+n);    int d = arr[1] - arr[0];    int numToAdd = -1;    bool numAdded = false;    for (int i = 2; ... Read More

Get Base 2 Logarithm of E in JavaScript

Sravani S
Updated on 16-Jan-2020 07:29:51

320 Views

To get base 2 logarithms of E, use the Math LOG2E property. It returns base 2 logarithm of E which is approximately 1.442.ExampleYou can try to run the following code to get base 2 logarithms of E in JavaScript:           JavaScript Math LOG2E Property                        var property_value = Math.LOG2E          document.write("Property Value is : " + property_value);          

Convert from Any Base to Decimal and Vice Versa in C++

Ayush Gupta
Updated on 16-Jan-2020 07:26:39

1K+ Views

In this tutorial, we will be discussing a program to convert from any base to a decimal and vice versa.For this we will be provided with an integer and its base. Our task is to convert the number to its decimal equivalent. Further we will also be performing the reverse of this procedure as well.Example Live Demo#include #include //returning values of a character int val(char c) {    if (c >= '0' && c = 0; i--) {       if (val(str[i]) >= base) {          printf("Invalid Number");          return -1;   ... Read More

Convert Decimal Fraction to Binary Number in C++

Ayush Gupta
Updated on 16-Jan-2020 07:21:31

603 Views

In this tutorial, we will be discussing a program to convert decimal fraction to a binary number.For this we will be provided with a decimal fraction and integer ‘k’. Our task is to convert the given decimal fraction into its binary equivalent upto the given ‘k’ digits of decimal precision.Example Live Demo#include using namespace std; //converting decimal to binary number string convert_tobinary(double num, int k_prec) {    string binary = "";    //getting the integer part    int Integral = num;    //getting the fractional part    double fractional = num - Integral;    //converting integer to binary    while (Integral) ... Read More

Top 10 Technologies Related to Artificial Intelligence

Samual Sam
Updated on 16-Jan-2020 07:13:49

348 Views

One of the most captivating branches of Computer Science – the Artificial Intelligence (AI) – has been thriving on technological fronts. AI is currently used in the programming of computer games, understanding of natural human languages (Apple’s Siri and Microsoft Cortana), neural networks and robotics (eg. Sophia – the most advanced human-like robot).Companies are investing in AI and the percentage is increasing year on year – 38% in 2016 to 62% in 2018, with an expected increase in market growth from $8 billion in 2016 to $47 billion in 2020 as per Forbes recent publication.Here the hottest technologies that ride ... Read More

Convert BST to Min Heap in C++

Ayush Gupta
Updated on 16-Jan-2020 07:12:06

367 Views

In this tutorial, we will be discussing a program to convert a binary search tree to a min heap.For this we will be provided with a binary search tree. Our task is to convert the given binary search tree into a min heap such that following the condition of the binary search tree when elements are compared with themselves.Example Live Demo#include using namespace std; //node structure of BST struct Node {    int data;    Node *left, *right; }; //node creation struct Node* getNode(int data) {    struct Node *newNode = new Node;    newNode->data = data;    newNode->left = ... Read More

Convert BST to Max Heap in C++

Ayush Gupta
Updated on 16-Jan-2020 07:08:43

570 Views

In this tutorial, we will be discussing a program to convert a binary search tree to a max heap.For this we will be provided with a binary search tree. Our task is to convert the given binary search tree into a max heap such that following the condition of the binary search tree when elements are compared with themselves.Example Live Demo#include using namespace std; //node structure of BST struct Node {    int data;    Node *left, *right; }; //node creation struct Node* getNode(int data) {    struct Node* newNode = new Node;    newNode->data = data;    newNode->left = ... Read More

Ancient Technology You Never Heard Of

Samual Sam
Updated on 16-Jan-2020 07:05:58

206 Views

We live in a new world where our lives largely depend on technology. Technology is all pervasive and seeps into each and every part of our personal and professional life. And here, I bring to you a list of items, which would both surprise you and ignite a newfound appreciation for technology of a bygone eraAn Ancient Earthquake DetectorWe still cannot measure earthquakes accurately, but you will be surprised that Zhang (‘Chang’) Heng, a Chinese astronomer, engineer, mathematician, and inventor invented the first seismoscope in 132 AD. The device was noticeably precise in detecting earthquakes. Secondly, this device was capable ... Read More

Advertisements