In this article, we will see how to generate the assembler output from C or C++ code using GCC. What is GCC The GCC, which stands for GNU Compiler Collection, is a set of compilers and development tools available for various operating systems such as Linux, Windows, and a wide variety of other OSs (operating systems). It supports mostly C and C++, but also Objective-C, Ada, Go, Fortran, and D. The Free Software Foundation (FSF) created GCC and distributed it as totally free (as in libre) software. How to Get Assembler Output The GCC has a great feature that allows ... Read More
What is Cycle Sort? Cycle sort is an in-place, unstable sorting algorithm. It is a comparison sort that is theoretically optimal in terms of the total number of writes to the original array, unlike any other in-place sorting algorithm. A sorting algorithm is in-place sorting in which the sorted items occupy the same place as the original one. Key Points of Cycle Sort Following are the key points: It is optimal in terms of number of memory writes. It minimize the number of memory write to sort (Each value is either written zero times, if ... Read More
In this article, we will implement a C++ program to find whether a number is a power of two. So, you are given a positive integer n; the task is to find if the given number is a power of 2 or not. Let's see some of the numbers that represent the power of two. 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 ... Example Scenario Let's see the following example scenario: Input: 4 Output: yes Explanation: 22 = 4 Input: 16 Output: yes Explanation: 24 = 16 Input: 5 Output: no Explanation: ... Read More
What is Linear Search? Linear search is a sequential searching technique in which we start at one end of the list or array and look at each element until the target element is found. It is the simplest searching algorithm, with O(n) time complexity. Example Scenario let's see the following example scenario: Input: arr = {5, 4, 3, 8, 10}, K = 3; Output: 3 found at index 2; Input: arr = {1, 2, 3, 4, 5}, K = 7; Output: Not Found; How Linear Search Work? Following are the steps to search an element in array or ... Read More
In this article, We implement a C++ program to print sum of series like 13 + 23 + 33 + 43 + .......+ n3 till the nth term. Given an integer n, calculate the sum of the cubes of the first n natural integers. So, we have to cube of 'n' natural integers and sum the results. Example Scenario Let's understand the following example scenario: Input: n = 4 Output: 100 Explanation: 13 + 23 + 23 + 43 Another example scenario: Input: n = 5 Output: 225 Explanation: 13 + 23 + 23 + 43 + 43 ... Read More
In C++, a Binary tree is a generalization of the Binary Search Tree (BST). A B-tree can have more than two children. It is also known as a balanced tree data structure that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time. It is optimized for a system that reads and writes large blocks of data. Properties of B-tree As we discussed in the introduction B-tree is self-balanced tree where a node can have multiple children. It maintains the balance by making sure that all leaf nodes are at the same level. Following is the properties ... Read More
The mutable keyword in C++ is a storage class specifier. It enables non-static, non-const, and non-reference data members (i.e., mutable data member) of a class to be changed even when the object containing them is declared constant. Mutable data members are those members whose values can be changed in runtime even if the object is of constant type. It is just the opposite of a constant. What is Need of Mutable? Sometimes, it is necessary to modify one or more data members of a class/struct through the constant function, even if you do not want the function to update another ... Read More
In C++, calling a virtual function inside a constructor or destructor is dangerous and should generally be avoided. Following are the reasons to avoid calling: When a constructor (or destructor) is running, the object is not fully built (or fully destroyed). At that time, the virtual function table (vtable) points to the version of the class currently being constructed or destructed, not the most derived version. What Happens When You Call a Virtual Function in a Constructor? If you call the virtual function inside a constructor: ... Read More
In this article, we will learn about the ConcurrentHashMap and HashTable in Java. First, we will know about ConcurrentHashMap, the syntax of ConcurrentHashMap, and an example after that will learn about HashTable, the syntax of HashTable, and an example. At the end, we will see a table showing the difference between ConcurrentHashMap and HashTable. What is ConcurrentHashMap in Java? ConcurrentHashMap is a class that was introduced in JDK 1.5. The ConcurrentHashMap is threadsafe as it allows multiple threads to read and write the data without locking the entire map. ConcurrentHashMap applies locks only at the bucket level, called a fragment, while ... Read More
The Collection is a framework that provides architecture to store and manipulate a group of objects. Java Collections can achieve all the operations that you perform on data, such as searching, sorting, insertion, manipulation, and deletion. In this article, we will understand how to convert a collection into an array in Java. Following are the ways to convert a collection into an array in Java: Using Iteration Using toArray() Method Using Streams Collection to Array using Iteration The naive way to convert a collection into an array is by traversing the collection and adding each element in the ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP