You are on page 1of 9

1.

One and Two-Tailed Tests are ways to identify the relationship between the statistical
variables. For checking the relationship between variables in a single direction (Left or Right
direction), we use a one-tailed test. A two-tailed test is used to check whether the relations
between variables are in any direction or not.
One-Tailed Test
A one-tailed test is based on a uni-directional hypothesis where the area of rejection is on only
one side of the sampling distribution. It determines whether a particular population parameter
is larger or smaller than the predefined parameter. It uses one single critical value to test the
data.

Null Hypothesis (H0): where represents a parameter (e.g., population mean) and θ0 is a
specific value.
Alternative Hypothesis (H1):
 For a right-tailed test:
 For a left-tailed test:
Test Statistic: Depending on the type of test and the distribution, the test statistic is computed
(Z-score for normal distribution).
Decision Rule: If the test statistic falls in the critical region, reject the null hypothesis in favor
of the alternative hypothesis.
Example: Effect of participants of students in coding competition on their fear level.
 H0: There is no important effect of students in coding competition on their fear level.
The main intention is to check the decreased fear level when students participate in a coding
competition.

Two-Tailed Test
A two-tailed test is also called a nondirectional hypothesis. For checking whether the sample is
greater or less than a range of values, we use the two-tailed. It is used for null hypothesis
testing.
Null Hypothesis (H0): where represents a parameter (e.g., population mean) and θ0 is a
specific value.
Alternative Hypothesis (H1):
Test Statistic: Compute the test statistic as appropriate for the distribution (Z-score for normal
distribution).
Decision Rule: If the test statistic falls in either tail of the distribution’s critical region, reject
the null hypothesis in favor of the alternative hypothesis.
Example: Effect of new bill pass on the loan of farmers.
 H0: There is no significant effect of the new bill passed on loans of farmers.
New bill passes can affect in both ways either increase or decrease the loan of farmers.

Difference Between One and Two-Tailed Test:

One-Tailed Test Two-Tailed Test

A test of any statistical hypothesis, where


A test of a statistical hypothesis, where the
the alternative hypothesis is one-
alternative hypothesis is two-tailed.
tailed either right-tailed or left-tailed.

For one-tailed, we use either > or < sign for For two-tailed, we use ≠ sign for the
the alternative hypothesis. alternative hypothesis.

When the alternative hypothesis specifies a If no direction is given then we will use a
direction then we use a one-tailed test. two-tailed test.

Critical region lies entirely on either the Critical region is given by the portion of the
right side or left side of the sampling area lying in both the tails of the probability
distribution. curve of the test statistic.

Here, the Entire level of significance (α) i.e. It splits the level of significance (α) into
5% has either in the left tail or right tail. half.

Rejection region is either from the left side Rejection region is from both sides i.e. left
or right side of the sampling distribution. and right of the sampling distribution.
One-Tailed Test Two-Tailed Test

It checks the relation between the variable in It checks the relation between the variables
a singles direction. in any direction.

It is used to check whether the one mean is It is used to check whether the two mean
different from another mean or not. different from one another or not.

Euclidean algorithm
Formal description of the Euclidean algorithm
 Input Two positive integers, a and b.
 Output The greatest common divisor, g, of a and b.
 Internal computation
1. If a<b, exchange a and b.
2. Divide a by b and get the remainder, r. If r=0, report b as the GCD of a
and b.
3. Replace a by b and replace b by r. Return to the previous step.

The Euclidean algorithm, often known as Euclid's algorithm, is an effective way to determine the
greatest common divisor (GCD), or the biggest number that divides two integers (numbers)
evenly and without leaving a remainder. It was initially described in the 300 BC book The
Elements by the Greek mathematician Euclid, for whom it was called. One of the first algorithms
still in use, an algorithm is a step-by-step process for carrying out a computation in accordance
with predetermined principles. It is a component of several number-theoretic and cryptographic
calculations and may be used to simplify fractions. There are several theoretical and real-world
uses for the Euclidean algorithm. It is employed in conducting division in modular arithmetic as
well as simplifying fractions. This algorithm is employed in both strategies for cracking these
cryptosystems by factoring very big composite numbers as well as the cryptographic protocols
that safeguard internet communications.

The greatest common divisor of two positive integers can be discovered using the Euclidean
method. The greatest integer that divides two numbers evenly is called the GCD. Factorizing
both integers and multiplying common prime factors is an easy approach to find GCD.

GCD's fundamental Euclidean algorithm:

The following facts form the basis of the algorithm.

o GCD remains same if we lower a larger integer by subtracting a smaller one from it.
Therefore, if we continually deduct the greater of two, we arrive at GCD.
o Now, if we divide the smaller number rather of subtracting it, the process halts when we
reach the final result of 0.

A recursive function to calculate GCD using Euclid's approach is provided below:

// C++ program to demonstrate


// Basic Euclidean Algorithm
#include <bits/stdc++.h>
using namespace std;
// Function to return
// gcd of a and b
int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
// Driver Code
int main()
{
int a = 10, b = 15;

// Function call
cout << "GCD(" << a << ", " << b << ") = " << gcd(a, b)
<< endl;
a = 35, b = 10;
cout << "GCD(" << a << ", " << b << ") = " << gcd(a, b)
<< endl;
a = 31, b = 2;
cout << "GCD(" << a << ", " << b << ") = " << gcd(a, b)
<< endl;
return 0;
}

Output

GCD(10, 15) = 5
GCD(35, 10) = 5
GCD(31, 2) = 1
.................................
Process executed in 1.11 seconds
Press any key to continue.

Time Complexity: O (Log min(a, b))

Auxiliary Space: O (Log (min(a,b))

4.
A spanning tree of a connected undirected graph G is a tree that minimally includes all of the
vertices of G. A graph may have many spanning trees.

Example
Minimum Spanning Tree
A spanning tree with assigned weight less than or equal to the weight of every possible spanning
tree of a weighted, connected and undirected graph G, it is called minimum spanning tree (MST).
The weight of a spanning tree is the sum of all the weights assigned to each edge of the spanning
tree.

Example

Kruskal's Algorithm

Kruskal's algorithm is a greedy algorithm that finds a minimum spanning tree for a connected
weighted graph. It finds a tree of that graph which includes every vertex and the total weight of
all the edges in the tree is less than or equal to every possible spanning tree.

Algorithm

Step 1 − Arrange all the edges of the given graph G(V,E) in ascending order as per their edge
weight.
Step 2 − Choose the smallest weighted edge from the graph and check if it forms a cycle with
the spanning tree formed so far.
Step 3 − If there is no cycle, include this edge to the spanning tree else discard it.
Step 4 − Repeat Step 2 and Step 3 until (V−1) number of edges are left in the spanning tree.
Problem

Suppose we want to find minimum spanning tree for the following graph G using Kruskal’s
algorithm.

Solution

From the above graph we construct the following table −

Edge No. Vertex Pair Edge Weight

E1 (a, b) 20

E2 (a, c) 9

E3 (a, d) 13

E4 (b, c) 1

E5 (b, e) 4

E6 (b, f) 5

E7 (c, d) 2

E8 (d, e) 3

E9 (d, f) 14

Now we will rearrange the table in ascending order with respect to Edge weight −
Edge No. Vertex Pair Edge Weight

E4 (b, c) 1

E7 (c, d) 2

E8 (d, e) 3

E5 (b, e) 4

E6 (b, f) 5

E2 (a, c) 9

E3 (a, d) 13

E9 (d, f) 14

E1 (a, b) 20
Since we got all the 5 edges in the last figure, we stop the algorithm and this is the minimal
spanning tree and its total weight is (1+2+3+5+9)=20(1+2+3+5+9)=20.

You might also like