Find N-th Node of Inorder Traversal in C++

sudhir sharma
Updated on 13-Mar-2021 12:12:17

396 Views

In this problem, we are given a binary tree and an integer N. The task is to find the n-th node in inorder traversal of a Binary Tree.A binary tree has a special condition that each node can have a maximum of two children.Traversal is a process to visit all the nodes of a tree and may print their values too.Let’s take an example to understand the problem, InputN = 6Output3Explanationinorder traversal of tree : 4, 2, 5, 1, 6, 3, 7Solution ApproachThe idea is to use the in-order traversal of the binary tree which is done by using recursive ... Read More

Find N-th Node in Preorder Traversal of a Binary Tree in C++

sudhir sharma
Updated on 13-Mar-2021 12:08:15

284 Views

In this problem, we are given a binary tree and an integer N. The task is to find the n-th node in Preorder traversal of a Binary Tree.A binary tree has a special condition that each node can have a maximum of two children.Traversal is a process to visit all the nodes of a tree and may print their values too.Let’s take an example to understand the problem, InputN = 6Output6ExplanationPre order traversal of tree : 1, 2, 4, 5, 3, 6, 7Solution ApproachThe idea is to use the pre-order traversal of the binary tree which is done by using ... Read More

Crop Images in CSS with object-fit and object-position

AmitDiwan
Updated on 13-Mar-2021 12:02:00

395 Views

CSS object-fit and object-position property helps us crop images and specify how it is displayed in an element.The syntax of CSS object-fit property is as follows −Selector {    object-fit: /*value*/    object-position:/*value*/ }ExampleThe following examples illustrate CSS object-fit property. Live Demo img {    object-fit: cover; } img:last-of-type {    object-fit: contain; } cover contain OutputThis will produce the following result −Example Live Demo div {    border: 1px solid blue;    width:100%;    height:300px; } img {    float:left;    width:50%;    height:100%;    object-fit:cover;    object-position: 20px -10px; } OutputThis will produce the following result −Effect of resizing

Verify If Numbers Are Abundant or Friendly in C

Bhanu Priya
Updated on 13-Mar-2021 11:56:06

854 Views

In this program, we are trying to check whether the two given numbers by the user through console, are friendly pair or not?ExampleIf sum of all divisors of number1 is equal to number1 and sum of all divisors of number2 is equal to number2, then we can say, those two numbers are abundant numbers.The logic that we used to find friendly pairs is as follows −For the sum of all divisors of number 1.for(i=1;i

Explain Squeeze Function in C Language

Bhanu Priya
Updated on 13-Mar-2021 11:54:47

2K+ Views

Squeeze(s1, s2) or squeeze(char[], char[]) is a user defined function which is used to delete the common characters or equal characters in two strings.ProblemHow to delete the common characters in two strings using squeeze function in C programming language?SolutionIn this program, the user enters two strings in the console and write a code to display first string excluding the common characters present in second string.ExampleThe C program which demonstrates the functioning of squeeze function is as follows − Live Demo#include void squeeze(char string1[], char string2[]);//prototype declaration int main(){    char string1[50];    char string2[30];    printf("enter the string1:");    scanf("%s", string1);// ... Read More

Display All Data Types Ranges in Tabular Form using C

Bhanu Priya
Updated on 13-Mar-2021 11:53:34

1K+ Views

The different data types that we use in C programming are integer, short int, Signed and un signed char etc.Data TypesData type specifies the set of values and the type of data that can be stored in a variable. They allow the programmer to select the type appropriate to the needs of application.The data types are as follows −Primary data typesDerived data typesLet us understand primary data types.Primary data types‘C’ compilers support four fundamental data types. They are mentioned below −integercharacterFloating – pointDouble precision floating pointIntegral data typeIntegral data types are used to store whole numbers and characters. It is ... Read More

Limitations of Arrays in C Language

Bhanu Priya
Updated on 13-Mar-2021 11:49:17

12K+ Views

Arrays are a kind of data structure that can store a fixed-size sequential collection of elements of the same type.An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.LimitationsThe limitations of an array are explained below −An array which is formed will be homogeneous. That is, in an integer array only integer values can be stored, while in a float array only floating value and character array can have only characters. Thus, no array can have values of two data ... Read More

Communication Among Functions in C Language

Bhanu Priya
Updated on 13-Mar-2021 11:45:24

811 Views

Functions communicate among themselves with the help of arguments and return value.Farm of ‘C’ function is as follows −return-datatype function name (argument list){    local variable declarations;    executable statements(s);    return (expression); }For example, void mul (int x, int y){    int p;    p=x*y;    printf("product = %d”, p); }Return values and their typesA function may or may not send back a value to the calling function.It will be done by using the return statementThe return types are void, int, float, char and double.If a function is not returning any value, then its return type is ‘void’.Function nameA ... Read More

Top-Down Design and Structure Chart of Function in C Language

Bhanu Priya
Updated on 13-Mar-2021 11:43:10

3K+ Views

A function is a self-contained block that carries out a specific well defined task.Advantages of functions in C language include −Reusability.The length of the program can be reduced.It is easy to locate and find any faulty function.It facilitates top-down modular programming.Top down design and structure chartsIt is a problem solving method in which a complex problem is solved by splitting into sub problems.Structure chart is a documentation tool that shows the relationships among the sub problems of a problem.The splitting of a problem into its related sub problems is the process of refining an algorithm. For example, performing arithmetic operations ... Read More

How Floats Are Stored in C Compiler

Bhanu Priya
Updated on 13-Mar-2021 11:41:56

917 Views

In C programming language, float is a short term for floating point.Floating point numbers are generally represented in the form of Institute of Electrical and Electronics Engineers (IEEE) format.The IEEE format uses a sign bit, a mantissa and an exponent for representing the power of 2.The sign bit denotes the sign of the number: a 0 represents a positive value and a 1 denotes a negative value.The mantissa represented in binary after converting into its normalized form. After normalization mantissa, the most significant digit is always 1.The exponent is an integer stored in unsigned binary format after adding a positive ... Read More

Advertisements