Found 7401 Articles for C++

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

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

109 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

exp() function C++

Chandu yadav
Updated on 30-Jul-2019 22:30:25

579 Views

The C / C++ library function double exp(double x) returns the value of e raised to the xth power. Following is the declaration for exp() function.double exp(double x)The parameter is a floating point value. And this function returns the exponential value of x.Example Live Demo#include #include using namespace std; int main () {    double x = 0;    cout

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

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

2K+ 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

Multithreading in C++

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

604 Views

Multithreading is a specialized form of multitasking and a multitasking is the feature that allows your computer to run two or more programs concurrently. In general, there are two types of multitasking: process-based and thread-based.Process-based multitasking handles the concurrent execution of programs. Threadbased multitasking deals with the concurrent execution of pieces of the same program.A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution.C++ does not contain any built-in support for multithreaded applications. Instead, it relies entirely upon the ... 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

147 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

Print system time in C++

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

435 Views

The C++ standard library does not provide a proper date type. C++ inherits the structs and functions for date and time manipulation from C. To access date and time related functions and structures, you would need to include header file in your 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.The structure type tm holds the date and time in the form of a C structure having the following elements -struct tm {    int tm_sec; ... Read More

C++ Program to Check Whether a Given Tree is Binary Search Tree

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

215 Views

Binary Search Tree is a binary tree data structure in which we have 3 propertiesThe left subtree of a binary search tree of a node contains only nodes with keys lesser than the node’s key.The right subtree of a binary search tree node contains only nodes with keys greater than the node’s key.The left and right trees of a subtree each must also be a binary search tree.AlgorithmBegin    function BSTUtill()       If node is equals to NULL then          Returns 1.       If data of node is less than minimum or greater ... Read More

Early binding and Late binding in C++

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

13K+ Views

In this section we will see what is early binding and what is late binding in C++. The binding means the process of converting identifiers into addresses. For each variables and functions this binding is done. For functions it is matching the call with the right function definition by the compiler. The binding is done either at compile time or at runtime.Early BindingThis is compile time polymorphism. Here it directly associates an address to the function call. For function overloading it is an example of early binding.Example Live Demo#include using namespace std; class Base {    public:    void display() { ... Read More

C++ Program to Check if a Binary Tree is a BST

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

726 Views

Binary Search Tree is a binary tree data structure in which we have 3 properties −The left subtree of a binary search tree of a node contains only nodes with keys lesser than the node’s key.The right subtree of a binary search tree node contains only nodes with keys greater than the node’s key.The left and right of a subtree each must also be a binary search tree.AlgorithmBegin    function BSTUtill()       If node is equals to NULL then          Return 1.       If data of node is less than minimum or greater ... Read More

fabs() in C++

Chandu yadav
Updated on 30-Jul-2019 22:30:25

475 Views

The C or C++ library function double fabs(double x) returns the absolute value of x. x − This is the floating point value. This function returns the absolute value of x. Following is the declaration for fabs() function.double fabs(double x)The following example shows the usage of fabs() function.Example Live Demo#include #include using namespace std; int main () {    int a, b;    a = 1234;    b = -344;    cout

Advertisements