In C++, binding is the process of connecting names such as variables and functions to their actual memory locations. When you intend to call a function, the program must identify the proper function definition for the execution. So, binding is the process of making this connection. This happens either at compile time (early binding) or at runtime (late binding). Early Binding This is compile time polymorphism and decides which function to call before it runs, making execution faster and direct. Example In this example, we demonstrate the early binding, where the base class function runs instead of the derived class ... Read More
In C++, the standard library does not provide any proper built-in date type. Instead of that we use structures and functions to inherit from the C language for the manipulation. To access this date and time related functions and structures, we need to include header file to the C++ program. There are four time-related types: clock_t, time_t, size_t, and tm. The types: clock_t, size_t and time_t are capable of representing the system time and date as some sort of integer. time_t: It is used to store calendar time (like the number of seconds since ... Read More
Both malloc() and free() are used to manage memory at runtime. The malloc() is very useful because it allocates memory based on the program needs, while free() releases the memory. But the free() can lead to memory leakage, which is one of its disadvantages. What is malloc()? The function malloc() is used to allocate the requested size of bytes and it returns a pointer to the first byte of allocated memory. It returns null pointer, if it fails. Syntax Following is the basic syntax of malloc(): pointer_name = (cast-type*) malloc(size); Here, pointer_name : Any ... Read More
In this article, we will learn how to check for a balanced parentheses using stack data structure in C++ program. First of all let's understand what is balanced parentheses. A string of parentheses is said to be balanced parentheses, If Every opening bracket has corresponding closing bracket of same type. The brackets are closed in correct order. For an example, we can say that the expression [{} () {()}] it is balanced. But {[}] is not balanced eventhough it contains opening and closing brackets of same type. ... Read More
An adjacency list of graph is a collection of unordered lists, that represents a finite graph data structure using linked lists. Each list in the collection represents one of the vertex of the graph and it will store the adjacent vertices of that vertex. In this article we will learn how to implement adjacency list for a graph using C++ program. First of all, let's see an example of adjacency list. Example of Adjacency List To understand what is an adjacency list is, first we need to take a graph data structure for reference. The image below represent a ... Read More
The adjacency matrix of a graph is a square matrix of size V x V, that represent a finite graph data structure using a 2D array, where V is number of edges of the graph. The each non zero elements in the matrix represent an edges of the graph. For example, if the graph has some edges from i to j vertices, then in the adjacency matrix at i th row and j th column it will be 1 (or some non-zero value for weighted graph), otherwise that value will be 0. In this article, we will learn how to ... Read More
The quick sort technique is based on partitioning of array of data into smaller arrays. Initially, a pivot element is chosen by the partitioning algorithm. The left part of the pivot holds smaller values than the pivot, and the right part holds the larger value. In this case, we are choosing the pivot element randomly. After choosing the pivot, we do the partitioning and then sort the array recursively. In this article, we have an array having 100 elements. Our task is to implement quick sort on this array using randomization in C++. Here is an example of a quick ... Read More
The calculation of the angle between the hour and minute hands of a clock is a common problem in Logical Reasoning and programming. This calculation is used in various applications, such as analog clock simulations, scheduling software, and time-based animations In this article, we are going to discuss how we can calculate the angle between the hour and minute hands of a clock in C# using different approaches: What is the Angle Between the Hour and Minute Hands? The angle between the hour and minute hands is determined based on the positions of both hands on the clock ... Read More
In this article, we have a positive integer 'n'. Our task is to generate all possible unique ways to represent 'n' as the sum of positive integers in C++. Each partition should give a sum equal to the given 'n'. Here is an example: Input: n = 4 Output: 4 3 1 2 2 2 1 1 1 1 1 1 Steps to Perform Unique Partition of Integer We start with the current partition i.e. with an initial value of n. Then we print the current partition. ... Read More
In C/C++, an input buffer is a temporary storage area where the program processes the input. Suppose, you are an user and you type some characters using a keyboard but those characters are not passed to the program directly because it involves several layers of handling such as keyboard firmware, OS input queues, and event processing. So, they first proceed with the collection of an input buffer. Next, when the program is ready, it reads from the buffer. How Input Buffer Affects a Program? The input buffer affected to the program when we are using the functions like scanf() or ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP