A binary tree T has n leaf nodes, the number of nodes of degree 2 in T is:
In an "m-ary" tree. the number of total nodes (N) is given by
N=mi + 1 ----(1)
Where,
i: Number of internal nodes
Also, in a tree, N=i + L ----(2)
Where,
L=number of leaf nodes
Here m=2
From equation (1) and equation (2);
N = 2i + 1
2i + 1 = i + L
L = i + 1
The number of leaves are 1 plus the number of internal nodes in binary tree.
Here, given L=n, substitute above and we will get,
i = L - 1
Concept –
Option_1: A valid declaration in C.
char *str is a single value which is a pointer to a character. When used as a string in C, it is implied that subsequent characters of the string are stored in subsequent memory addresses, until the end of the string which is marked with a NULL.
Option_2: A valid declaration in C.
Char str[20] is an array of maximum 20 characters. It is similar to char *str except that there is no requirement that the last character in the array be null.
Option_3 – A valid declaration in C.
char str[40] is an array of maximum 40 characters. It is similar to char *str except that there is no requirement that the last character in the array be null.
Option_4: Not a valid declaration in C.
char[] str is a declaration in Java, but not in C.Declaration syntax: For structure in C and C++
struct tag_name
{
Datatype variable_name;
struct tag_name *pointer_variable;
};
Option 2:
struct node
{
int data;
struct node*link;
}
The correct answer is main().
Key Points
Additional Information
Answer: Option 4
Explanation:
Consider the following example
#include <stdio.h>
int main()
{
int arr[10] = {1, 2, 3, 4, 5, 6, 7};
arr++;
return 0;
}
Here arr++; mean that
arr = arr + 1 ;
which is wrong we can not change the base address of an array and it will generate an error.
another way to do that is by using pointers.
#include <stdio.h>
int main()
{
int arr[10] = {1, 2, 3, 4, 5, 6, 7};
int *p = arr;
p++;
return 0;
}
Here int *p = arr; new pointer variable will be created which will start pointing to the first element of the array.
and p++; will cause the pointer to start pointing to the next element of the array.
Answer: Option 4
Concept:
Full Binary Tree:
A full binary tree is a binary tree in which each node has exactly two or 0 children.
Complete Binary Tree:
A complete binary tree is a binary tree in which
Perfect Binary Tree:
A perfect binary tree is a binary tree in which
Balanced Binary Tree:
A Balanced Binary tree is a binary tree in which at any node height of the left sub tree and right sub tree do not differ by more than 1.
Total MCQS : 128
gradeTotal MCQS : 37
gradeTotal MCQS : 133
gradeTotal MCQS : 166
gradeTotal MCQS : 165
gradeTotal MCQS : 61
gradeTotal MCQS : 133
gradeTotal MCQS : 120
gradeTotal MCQS : 7
gradeTotal MCQS : 36
gradeTotal MCQS : 7
gradeTotal MCQS : 175
gradeTotal MCQS : 2533
gradeTotal MCQS : 9
gradeTotal MCQS : 11
grade191 Points
54 Points
53 Points
52 Points
49 Points