C++ Articles - Page 544 of 586

exit() vs _Exit() function in C and C++

George John
Updated on 30-Jul-2019 22:30:25

499 Views

In this section we will see what are the differences between exit() and _Exit() in C and C++. In C the exit() terminates the calling process without executing the remaining code which is present after exit() function.In C++11, one new function is present called _Exit(). So what is the feature of this function? The exit() function performs some cleaning before terminating the program. It clears the connection termination, buffer flushes etc. This _Exit() function does not clean anything. If we test using atexit() method, it will not work.Let us see two examples where at first we are using exit() function, ... Read More

2D vector in C++ with user defined size

Aman Kumar
Updated on 24-Jul-2025 15:33:39

3K+ Views

In this article, we will see how we create and use 2D vectors with user-defined sizes. What is 2D Vector? In C++, a vector is a dynamic array used to store elements. The 2D vector is a vector of vectors and are used to create a dynamic two-dimensional array where the number of rows and the number of columns in each row can vary. Just like a 2D array, a 2D vector is used to store data in a tabular form such as matrices, grids, or tables. Structure of a 2D Vector A 2D vector is declared as: vector v; ... Read More

C++ Program to Find Lowest Common Ancestor in a Binary Search Tree

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

580 Views

A binary tree which has at most two children, specified as left child and right child. This is a C++ Program to find the lowest common ancestor in a Binary Tree.AlgorithmBegin Create a structure n to declare data d, a left child pointer l and a right child pointer r.    Create a function to create newnode. Call a function LCA() to Find lowest common ancestor in a binary tree:    Assume node n1 and n2 present in the tree.    If root is null, then return.       If root is not null there are two cases.   ... Read More

C++ Program to Find Deepest Left Leaf in a Binary Tree

Samual Sam
Updated on 30-Jul-2019 22:30:25

245 Views

A binary tree which has at most two children, specified as left child and right child. This is a C++ Program to Find Deepest Left Leaf in a Binary TreeAlgorithmBegin.    function deepestLLeafutil() find the deepest left leaf in a given    binary tree:         lvel is level of current node.       maxlvel is pointer to the deepest left leaf node found so far         isLeft Indicates that this node is left child of its parent         resPtr is Pointer to the result         If root is equal to Null ... Read More

C++ Program to Construct an Expression Tree for a Postfix Expression

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

3K+ Views

An expression tree is basically a binary tree which is used to represent expressions. In expression tree, nodes correspond to the operator and each leaf node corresponds to the operand. This is a C++ program to construct an expression tree for a postfix Expression in inorder, preorder and postorder traversals.AlgorithmBegin    Function r() has a character variable as parameter.       If the characters are + or - or * or / then          Return will be -1       If the characters are from A to Z then          Return will ... Read More

C++ Program to Check Whether an Input Binary Tree is the Sub Tree of the Binary Tree

Samual Sam
Updated on 30-Jul-2019 22:30:25

276 Views

A binary tree is a tree data structure in which each node has at most two children, which are defined as left child and right child.AlgorithmBegin    function identical():        Take two nodes r1 and r2 as parameter.       If r1 and r2 is NULL then          Return true.       If r1 or r2 is NULL then          Return false.       Return (r1->d is equal to r2->d and          Call function Identical(r1->l, r2->l) and          Call functions Identical(r1->r, r2->r) ); ... Read More

Early binding and Late binding in C++

George John
Updated on 28-Apr-2025 18:35:32

17K+ Views

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

Zombie and Orphan Processes in Linux

Revathi Satya Kondra
Updated on 06-May-2025 18:51:16

9K+ Views

Every program runs as a process in Linux operating system. When a process ends or gets disconnected from its parent, special types of processes can be created. These processes are known as zombie and orphan processes. Details about the zombie and orphan processes are given as follows: Zombie Processes A zombie process is a process whose execution is completed but it still has an entry in the process table. Zombie processes usually occur for child processes, as the parent process still needs to read its child's exit status. Once this is done using the wait system call, the zombie process ... Read More

Strand sort in C++

Revathi Satya Kondra
Updated on 21-Apr-2025 18:17:18

502 Views

In C++, the strand sort is a recursive sorting algorithm. It is used to extract increasing subsequences repeatedly (called strands) from the input list and merge them into a sorted list. There are multiple libraries that can be used for different purposes. This sorting is one of them. This sorting technique is particularly good for sorting linked lists, but can be used with arrays too. The following is a list of approaches for strand sorting in C++: These approaches is to extract sorted strands (in increasing/descending order) from the unsorted list and merge them one by one into a final ... Read More

Sorting in C++

George John
Updated on 30-Jul-2019 22:30:25

2K+ Views

In this section we will see how to perform sorting algorithm in C++. A sorted array is an array in which each of the elements are sorted in some order such as numerical, alphabetical etc. There are many algorithms to sort a numerical array such as bubble sort, insertion sort, selection sort, merge sort, quick sort, heap sort etc. More details about sorting the array using selection sort are given below.The selection sort is a sorting method that yields a sorted array. It does so by repeatedly finding the smallest element in the array and interchanging it with the element ... Read More

Advertisements