LinuxHint's Latest C++ Tutorials

-
Heap Sort C++
As we know that the C++ language has a lot of sorting algorithms for sorting array-like structures. One of those sorting techniques is the Heap sort. It is quite popular among C++ developers because it is considered to be the most efficient when it comes to its working. It is a little different from other sorting techniques because it requires the information of data structure trees along with the concept of arrays. If you have heard and learned about binary trees, then learning Heap sort will be no more a problem for you.
Within heap sort, two types of heaps can be generated, i.e., min-heap and max-heap. The max-heap will sort the binary tree in descending order, while the min-heap will sort the binary tree in ascending order. In other words, the heap will be “max” when the parent node of a child is greater in value and vice versa. So, we have decided to write this article for all those naïve users of C++ who have no prior knowledge about sorting, especially the heap sort.
Let’s start our today’s tutorial with the Ubuntu 20.04 login to get access to the Linux system. After the login, make use of the shortcut “Ctrl+Alt+T” or the activity area to open its console application named “Terminal.” We have to utilize the console for making a file for implementation. The command for the creation is a simple one-word “touch” instruction following the new name for a file to be created. We have been naming our c++ file as “heap.cc”. After the file creation, you need to start implementing the codes in it. For that, you have to open it first through some Linux editors. There are three built-in editors of Linux that can be used for this purpose, i.e., nano, vim, and text. We are using the “Gnu Nano” editor.
-
Binary Search Tree C++
BST is a data structure that maintains the data in a sorted list. It is known as a binary search tree because, in the tree, every node has a two children maximum that cannot be increased further. This is known as a search tree because it is used to search or find any item present. We will implement this phenomenon in the C++ language.
-
Difftime function in C++
While calculating or performing any operation, we might need any function to calculate the total time that has passed until now or provide the difference of time in seconds between two points. In C++, there can be different ways to perform this task inappropriately. But we will discuss the built-in function of C++, that is difftime() function, As the name indicates that it calculates the difference in time. This function is defined in the library . So whenever we are willing to calculate time, we will need this library in the source code.
-
Char array to string C++
Both Character arrays and strings, in C++, are used to store characters and letters. But there is a difference in them; this can be related by describing them as follows:
-
How to Use the C++ Memcpy Function
In programming languages, while creating some logical modules for our programs, we need to copy our content from one array of any data type to another array. This duplication may be of the whole array or can be customized by providing a specified size up to which we need to copy the content of the array. This phenomenon can be done through different approaches. Among them is a function in the C++ programming language “memcpy”. This is used to copy the memory in the form of blocks.
-
C++ Convert Int to String
The conversion of data into two data types is a common phenomenon in the C++ programming language. Similarly, the conversion of integer-type data into the string is described in this guide. Both data types can be converted in several ways.
The integer data type is a simple type of variable that stores the data only in the form of variables. There are no specified functions that are applied only to the integers. Whereas the string is a data type that has several functions by default that are applied to them. Strings store data in the form of inverted commas. We have converted integer and float values in the string by using one of its built-in functions. For strings, it is mandatory to use a string library.
-
Bucket sort C++
This is the type of sorting that divides data into more buckets to ease the process of sorting as a whole. The bucket sorting is also known as a scatter-gather approach. Let us start with a simple algorithm to demonstrate the working of bucket sort.
-
Implementing Hash Table in C++
If you have ever worked in a python environment, then you must have known about the usage of the object “dictionary” that contains a key-value pair within it. Just like dictionaries, C++ came up with the concept of key-value pair. This pair will be stored in the data structure hash table of C++. The data structure hash table will be using the hash function to calculate the array index to insert values into the table using indexes and search them as well.
Within this guide, we will discuss the use of methods to create, add, delete, search values from the hash tables using some of its functions.Let’s start with the login from Linux. Try making a C++ file using the “touch” instruction in the shell and make use of any available built-in editor from your Linux system to open it (i.e. Gnu Nano).
-
C++ Cmath Library
C++ programming language supports many mathematical functions. Instead of focusing on the implementation of large source codes, these built-in functions are used directly to avoid space and time consumption, hence simplifying the code and program. C++ has a large set of categories of these default functions. These functions are present in the header file of mathematics that must be included while using any C++ math operation.
-
Check for palindrome C++
We usually use strings in our programs by applying different operations to them. Sometimes such a situation occurs when there is a need to get the resultant value in the reverse order. The same letters in the string with the reverse order are known as a ‘palindrome’. In C++, there are several ways to check if the string or numeric values are palindromes. In this guide, we have used three different approaches to check the status of the string.
-
Fmod( ) Function C++
In general, to calculate a remainder from two values, we simply divide them manually or often use a calculator to make it. But if we talk about the calculations in the programming languages, some built-in functions are responsible for calculating remainders, fractional values. C++ programming language also contains default functions regarding time, dates, and other mathematical operations. Fmod() function is one of the mathematical operations performed by having two values of the same or different data types. This tutorial will cover the description of the fmod() function and examples of implementation.
-

- Login or register to post comments
Printer-friendly version- 1206 reads
PDF version
More in Tux Machines
- Highlights
- Front Page
- Latest Headlines
- Archive
- Recent comments
- All-Time Popular Stories
- Hot Topics
- New Members
digiKam 7.7.0 is released
After three months of active maintenance and another bug triage, the digiKam team is proud to present version 7.7.0 of its open source digital photo manager. See below the list of most important features coming with this release.
|
Dilution and Misuse of the "Linux" Brand
|
Samsung, Red Hat to Work on Linux Drivers for Future Tech
The metaverse is expected to uproot system design as we know it, and Samsung is one of many hardware vendors re-imagining data center infrastructure in preparation for a parallel 3D world.
Samsung is working on new memory technologies that provide faster bandwidth inside hardware for data to travel between CPUs, storage and other computing resources. The company also announced it was partnering with Red Hat to ensure these technologies have Linux compatibility.
|
today's howtos
|








.svg_.png)
Content (where original) is available under CC-BY-SA, copyrighted by original author/s.

Recent comments
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago
1 year 11 weeks ago