## Matrix Representation of Graphs

In this post, you will learn how to represent a graph in matrix form. By using this concept we can easily create implementation of adjacency matrix.

If there is an edge between two vertices then we will represent it with 1 and if there is no edge then with 0.

## Adjacency Matrix Representation of Graphs

For Undirected Graph:

 1 2 3 4 5 1 0 1 0 0 1 2 1 0 1 0 0 3 0 1 0 1 0 4 0 0 1 0 1 5 1 0 0 1 0

Directed Graphs:

 1 2 3 4 5 1 0 0 0 0 1 2 1 0 0 0 0 3 0 1 0 0 0 4 0 0 1 0 0 5 0 0 0 1 0

## Input And Output In Python

In C language we use scanf and printf for input and output but what about in python? Let's us find out in this post, So hello guys I hope you are doing well, let's discuss about it.

## Input Function In Python

``Syntax: variable_name = input('text to be displayed')``

Code

``name = input("Enter your name: ")``

Output

``````Enter your name: Praveen
``````

Input Function For Numbers

To take number as a input you can use int or float outside the paranthesis.

``name = int(input("Enter your age: "))``

Output

``````Enter your age: 21
``````

## Print Function In Python

Unlike in java where you have to type system.out.println, python has made this built-in function name very simple. Just type print() and inside bracket put the variable, constant or string.

``````print("Hello World")
``````

Output

``````Hello World
``````

## Variables In Python

A variable is the name of the location in the memory. It has three attributes:

1. Name

3. Value

## How To Use Variable In Python

Variable name = value

Unlike C where you have to declare data type, you don't need to specify the data type of variable in python. This is called as dynamically typed language. You can use the same variable for different data types.

Also you can't just declare a variable in python you need to initialize some value.

## Multiple Assignments of Variable

``````a, b, c = 1, 2, 3
print(a,b,c)
``````

We will look in detail about print and input function in next post.

Input And Output In Python

## Tokens In Python

A token is the smallest individual unit in a python program. Python have following tokens

• 1. Keywords - These are reserved words which have special meaning for the interpreter.
• 2. Identifiers - These are the names given to the different parts of the program.
• 3. Literals - These are tokens which have fixed value.
• 4. Operators - These are symbols which when put between two operands performs some operation.
• 5. Punctuators - These are symbols used to organize statements, or structures in a program.

## Keywords

In Python 3.0.7, there are 33 keywords.

 False await else import pass None break except in raise True class finally is return and continue for lambda try as def from nonlocal while assert del global not with async elif if or yield

## Identifiers

Some rules you need to keep in mind while creating Identifiers.

• The first character should be letter, or +underscore. No numbers should be the first letter.
• It should not be a keyword.
• Identifers are case-sensitve.
• Except _underscore no symbol is allowed.

Some valid Identifers are:

Hello _Crackexams99

Some invalid Identifers are:

8Hello True

## Literals

There are different types of literals:

• String literals - Letters enclosed in quotes ''/"" are called string literals.
• Numeric literals - There are generally three types which are int, float, and complex.
• Boolean literals - It is True or False.
• None - It indicates nothing.

## Operators

There are different types of operators:

• Unary Operators - Requires only one operand.
• Binary Operators - Requires two operand.

• -Arithmetic Operators

OperatorFunctionSyntax
+Add two operands or unary plusx + y
-Subtract right operand from the left or unary minusx - y
*Multiply two operandsx * y
/Divide left operand by the right one (always results into float)x / y
%Modulus - remainder of the division of left operand by the rightx % y
//Floor division - division that results into whole number adjusted to the left in the number linex // y
**Exponent - left operand raised to the power of rightx**y

-Bitwise Operators

OperatorMeaningSyntax
&Bitwise ANDx & y
|Bitwise ORx | y
~Bitwise NOT~x
^Bitwise XORx ^ y
>>Bitwise right shiftx >> 2
<<Bitwise left shiftx << 2

-Membership Operators

OperatorFunctionSyntax
inTrue if value/variable is found in the sequence5 in x
not inTrue if value/variable is not found in the sequence5 not in x

-Identity Operators

OperatorFunctionSyntax
isTrue if the operands are identicalx is True
is notTrue if the operands are not identicalx is not True

-Logical Operators

OperatorFunctionSyntax
andTrue if both the operands are truex and y
orTrue if either of the operands is truex or y
notTrue if operand is falsenot x

-Relational Operators

OperatorFunctionSyntax
>Greater thanx > y
<Less thanx < y
==Equal tox == y
!=Not equal tox != y
>=Greater than or equal tox >= y
<=Less than or equal tox <= y

-Assignment Operators

OperatorUseSyntax
=x = 1x = 1
+=x += 1x = x + 1
-=x -= 1x = x - 1
*=x *= 1x = x * 1
/=x /= 1x = x / 1
%=x %= 1x = x % 1
//=x //= 1x = x // 1
**=x **= 1x = x ** 1
&=x &= 1x = x & 1
|=x |= 1x = x | 1
^=x ^= 1x = x ^ 1
>>=x >>= 1x = x >> 1
<<=x <<= 1x = x << 1

## Punctuators

These are symbols used to organize statements, or structures in a program. Examples are ' " \ # @ , : = ( ) [ ] { }

## Introduction to Python

Python is a high language programming language, developed by Guido Van Rossum in 1991. It is easy to learn and object oriented language.

## Features of Python Language

1. Easy To Use
2. Cross-platform language
3. Open Source
4. Expressive Language

1. Slower
2. Not Easily Convertible

## Why You Should Learn Python?

Python is widely used in these areas, so if you are looking to choose one of these profession then you should definetly learn it.

1. Data Science
2. Artificial Intelligence
3. Hardware/Sensor/Robots
4. Desktop Applications

## Introduction to Graph Data Structure

Graph is a non linear data structure, it is very useful for navigational purpose in real life.

Undirected Graph - It is a set of nodes and a set of links between the nodes. Each node is called a vertex, each link is called an edge, and each edge connects two vertices.

Vertices are {1, 2, 3, 4, 5}

Edges are {(1,2), (2,3), (3,4), (4,5), (5,1), (2,1), (3,2), (4,3), (5,4), (1,5)}

Directed Graph - It is a set of vertices and a collection of directed edges that each connects an ordered pair of vertices. In this one vertix points to other and so on.

Vertices are {1, 2, 3, 4, 5}

Edges are {(2,1), (3,2), (4,3), (5,4), (1,5)}

Vertex In-Degree Out-Degree
1 1 1
2 1 1
3 1 1
4 1 1
5 1 1

Indegree of vertex is the number of edges which are coming into the vertex, While out-degree is the number of edges are going out of the vertex.

## Delete A Node In Binary Search Tree

In this post, you will learn how to delete a node in a binary search tree using recursion.

To learn deletion of a node in BST first you need to learn about recursion, which is a function calling itself.

``````#include<stdio.h>
#include<stdlib.h>

struct node{
int key;
struct node *left;
struct node *right;
};

int Min(struct node *root)
{
struct node *temp = root;
while(temp->left != NULL){
temp = temp->left;
}
return temp->key;
}

struct node *delete(struct node *root, int val)
{
if(root == NULL)
return NULL;
if(root->key<val)
root->right = delete(root->right, val);
else if(root->key>val)
root->left = delete(root->left, val);
else{
if(root->left==NULL && root->right==NULL){
free(root);
return NULL;
}
else if(root->left==NULL){
struct node *temp = root->right;
free(root);
return temp;
}
else if(root->right==NULL){
struct node *temp = root->left;
free(root);
return temp;
}
else{
int rightMin = Min(root->right);
root->key = rightMin;
root->right = delete(root->right, rightMin);
}
}
return root;
}

struct node *newnode(int val){

struct node *new = malloc(sizeof(struct node));
new->key   = val;
new->left  = NULL;
new->right = NULL;
return new;

}

struct node *insert(struct node *root, int val){
if(root==NULL)
return newnode(val);
if(root->key<val)
root->right = insert(root->right,val);
else if(root->key>val)
root->left = insert(root->left, val);
return root;
}

void inorder(struct node *root)
{
if(root == NULL)
return;
inorder(root->left);
printf("%d ",root->key);
inorder(root->right);
}

int main(){
struct node *root = NULL;
root = insert(root,50);
root = insert(root,30);
root = insert(root,20);
root = insert(root,40);
root = insert(root,70);
root = insert(root,60);
root = insert(root,80);

int key;
scanf("%d",&key);
root = delete(root,key);
inorder(root);

return 0;
}``````

In Inorder traversal we traverse from left-root-right.

Deletion In BST can be possible in three cases:

1. When the root have no child
2. When the root have one NULL value and one root child
3. When the root have two child

Explanation

1. When the root have no child it is very easy to delete by free method, and return the NULL.
2. When the root have one child then we can replace the root by that child by using some temporary variable to store and free the root.
3. Now when we have two child of a root then deleting the root become difficult, For this we have to replace the root with root right child and delete the root child and point it to the NULL.

## Search A Node In Binary Search Tree

In this post, you will learn how to search a node in a binary search tree using recursion.

To learn searching a node in BST first you need to learn about recursion, which is a function calling itself.

``````#include<stdio.h>
#include<stdlib.h>

struct node{

int key;
struct node *left;
struct node *right;

};

struct node *newnode(int val){

struct node *new = malloc(sizeof(struct node));
new->key   = val;
new->left  = NULL;
new->right = NULL;

return new;

}

int search(struct node *root, int key)
{
if(root == NULL)
return 0;
if(root->key==key)
return 1;
if(root->key<key)
return search(root->right, key);
else
return search(root->left, key);
}

struct node *insert(struct node *root, int val){
if(root==NULL)
return newnode(val);
if(root->key<val)
root->right = insert(root->right,val);
else if(root->key>val)
root->left = insert(root->left, val);
return root;
}
/* Let us create following BST

50

/     \

30      70

/  \    /  \

20   40  60   80 */

int main(){
struct node *root = NULL;
root = insert(root,50);
root = insert(root,30);
root = insert(root,20);
root = insert(root,40);
root = insert(root,70);
root = insert(root,60);
root = insert(root,80);

int key;
scanf("%d",&key);
printf("%d",search(root,key));
return 0;
}``````

In Inorder traversal we traverse from left-root-right.

## Search A Node In Binary Search Tree

Explanation

1. In this code, when we search a number it checks, whether the root data is equal to that number if yes then return 1 and if not then recursively call the function.
2. First we will check if root is null, then there is no such element.
3. Then we will check if the root's data equal to the number or not.
4. If not then we will check if it smaller or greater.
5. If it is small then traverse to the left subtree.
6. Again the function will call itself, and check if the root is null, then check if the root's data equal.
7. Similarly this will continue till we get root's data equal to the key or search element.

## Application of Artificial Intelligence In Personalized Healthcare

Artificial Intelligence (A.I.) is the advancement of technology, that can perform tasks which requires human or our intelligence, like taking certain decisions, doing computation and complex operations and learning new things.

Source: techment.com

As we know that artificial intelligence helps us in giving predictions with high level of accuracy, also it provides help to perform complex problems which human takes days to solve.

The below diagram will help a lot to understand AI, ML and DL.

Figure 1.1 Relationship between AI, ML, Neural Nets, Deep Learning

Example – Artificial Intelligence related robotic surgery

### 1.2 Impact of Artificial Intelligence in Health care

We can see the greatest impact of AI in the field of health care sector. The latest report of PwC tells that artificial intelligence will contribute an additional fifteen point seven trillion to the world economy by 2030.

So there are genrally two reasons that have made AI impactful in health care. The following two reasons are given below:

1. More amount of medical data – As we know that today is the time of digitalization. And most of our records are stored in electronic form. Same in the case of medical data. Today there are tons of medical data which are in the form of medical history, reports and much more. Now by using the data implementing algorithms in AI based on technologies i.e., deep learning, neural networks and machine learning in hospitals, we are using applications of AI in personalized health care.

2. Introduction of complex algorithms – Machine Learning can not handle high dimensional data such as medical or health care data. Also we know that these data are very vast. But to analyze and process these thousands of data we need technologies like AI deep learning and neural networks. So this is how it became much easier for human to understand.

This is how AI comes into the picture in health care sector.

### 1.3 What is personalized healthcare ?

It utilize personalized planning to provide predictive, preventive, and personalized treatment. This approach is based on the person’s history, unique characterstics and biology. Personalized health care can be implemented by using currently available technologies such as AI.

Today we see problems like some drugs work for some peoples and for others it cause some side effects or not found effective. Also the question arises in our mind such as why only some people develop the diseases like cancers, and others do not. It can be possible or true that genes and biological factors are the reason but solving such problems will be a great achievement for us.

Now in such cases mentioned above, medicine should deal to each patients’ illness in personalized manner, on the basis of person’ characteristics and biology. This whole process is known as precision medicine. It is used in personalized healthcare.

Now let’s discover how Artificial Intelligence playing important role in personalized health care and precison medicine.

### 2.0 Applications of AI in Personalized Healthcare

No doctor can have a grip on all 31 million medical papers out there but AI will assist them it will help them analyze data which are in the form of medical history, reports and much more.

### 2.1 Artificial Neuron Network (ANN)

The application of ANNs in personalized health care are diagnosis, imaging, back pain, dementia, pathology, clinical diagnosis, prediction of cancer, speech recognition, prediction of length of stay, image analysis and interpretation, acute pulmonary embolism arrhythmias, or psychiatric disorders diseases. Some of the advantages of ANN as stated by are:

ANN stands for Artificial Neural networks which can learn linear and non linear models. It is found that the accuracy of linear and non linear models made by artificial neural networks can be measured statistically. Also these models are lexible and can be easily updated. So they can be used in dynamic environmnet like health sector. Neural networks completely tolerate incomplete data and noise.

Major disadvantage of ANNs are that they are weak in providing insight into structure or can say that black box algorithms. It cannot predict outside the range.

### 2.2 Machine Learning (ML)

Machine Learning comes under Artificial intelligence and it plays vital role in health care. It can learn from data and take decision without human intervention.

Machine learning is a part of health care right now whether we're talking about the statistical models that doctors currently use as risk scores in the intensive care unit or we're talking about more advanced high-capacity models that are being trained.

To understand what sort of risks are relevant for patients and what sort of treatments might be needed, machine learning and algorithms are a part of health care. Doctors get clinical data from practice and from knowledge by practice, they practice so if we could look at clinical records from a hospital from a clinic and see what sort of reatments are given, how patients are interacting with a healthcare team we could learn from that practice.

But then there's also knowledge maybe we don't just want to learn based on how doctors are practicing we may also want to look at the knowledge that's been generated randomized controlled trials rcts papers that are written textbooks right we could learn from both of those sources once we have that data we can train these simple statistical models or more advanced high-capacity models and then we can predict things important clinical events forecasting treatments that a patient might need those are really important for health care and progress so that's what could happen.

One of the big sources of knowledge is a randomized controlled trial where you give one set of people a treatment and see how well it works in that population however randomized controlled trials are very rare because they're expensive so only 10 to 20 percent of the treatments that are given today are based on randomized controlled trials.

From above paragraph, we can conclude that neither practice nor knowledge are perfect right now without any machine learning without any technology.

So machine learning is used in precision medicine. To implement machine learning we require a lot of medical data for training. It takes time but it is totally worth for it.

### 2.3 Natural Language Processing

The goal of artificial intelligence is to make human language understandable for computer. Now NLP is generally used in text translation and speech recognition tools. But NLP plays a vital role in analyzing unstructured medical notes to classify clinical documents and give various methods and provide useful insight like improving records of patients.

### 2.4 Analyzing Images or Data with AI

Radiologists can look at over 50-100 images per day but a trained computer can look over millions of images in hours it can even go through more data and it could not possible for a physician to cover this amount of data in his life.

AI revolution in CT or MRI scans and draw lines around tumors or pinpoints cells or designate ECG strips it's a hard and monotonous task but it needs to be done for machines to utilize that data simply.

Data analyzers are the eyes of machine learning however there are really complicated tests which are hard to define think about spotting the tumor on a CT scan radiologists analyze the images take the patient's medical records into consideration and have to keep so many things in mind before making a diagnosis for such tasks.

We have to turn to deep learning it's a vastly more advanced method a deep learning algorithm can study raw images or perhaps it doesn't even need images only the raw data coming straight out of the machine to analyze it.

While machine learning algorithms are blind without human help, deep learning algorithms only need to get trained at annotated data.  DL can handle unlabeled and unstructured data without human intervention based on artificial neural networks.

### 2.5 Artificial Intelligence in Genomics Sequencing

Genomics sequencing allows to uncover the genetic code which is about six billion letters and also to look for mistakes and defects in it that can be the drivers of disease like mutations in DNA which can cause cancer. Genome Sequencing is very helpful for treating disease like cancer.

Disease can really be diagnosed in the DNA, genomic sequencing represented a molecular diagnosis. First human genome took about 10 years to complete and now we're doing it in about two days all the credit goes to this revolutionary technology called Artificial Intelligence which consist machine learning and deep learning.

Now with the help of genomic sequencing we can predict which drug works well for the patient and this is how we can use precision medicine. Cancer research is increasingly powered by data. Those data remain siloed across institutions.

### 2.6 AI in Personalized Treatment

Application of AI in health care is data management. Collecting, classifying and tracing huge data sets of already available medical information.

Design treatment plans if able to analyze those data sets and combine them with attributes from a patient's file to identify potential treatment plans , precision medicine classical medical practice put large groups of people in their focus and tries to develop clinical solutions drugs or treatment plans based on the needs of the statistically average person but with the ability to analyze vast amounts of medical information to achieve genome sequencing health sensors and variables.

AI will most likely help healthcare move from the one-size-fits-all medical solutions towards targeted treatments per patient therapies and uniquely composed drugs. AI with evolutionized drug creation speaking of drugs pharmaceuticals - clinical trials take sometimes more than a decade and cost billions of dollars.

We can immensely speed up this process while making it a lot more cost effective this will have an enormous effect on health care and how innovations reach everyday medicine just imagine how fast it could come up with a cure for the next pandemic if supercomputers and AI algorithms could help us in the process, health assistance and medication management.

Today, there are 200,000 leprosy patients diagnosed every year. If you catch it in the stage of a skin lesion, you can cure the person. We are teaching an AI algorithm to recognize leprosy in an image of a skin lesion. With AI, doctors can help patients help themselves to get to the right experts at the right time.

### 2.7 Deep Learning In Personalized Healthcare

Convolutional neural network which are cnns for short, those are used for analyzing images and the second type which is recurrence neural networks or rnns for shorts are used for analyzing what we call sequential data so sequential data, where the natural sequence within that data is important and that includes things like sequences of blood test results so we have blood tests at different points in times.

It also includes things like genetic sequences because each sequence comes after the previous point in the sequence. It also includes things like text because actually in a sentence the positioning is very important so having one word after another one is also very important and so the key benefit of these two approaches to deep learning in medicine is that it enables us to analyze new types of information images text sequential data and these kinds of data that we couldn't really analyze very well before but now that we have these techniques it opens up a whole realm of possibilities within medicine.

### 3.1 Future Scope

The future scope of artificial intelligence in personalized health care is that we can use different trained algorithms which will save lives by analyzing thousands of previous patients data and provide detailed insight, personalized treatment and medicine.

AI is today everywhere from google assistance to translate. Also when this technology came in health care, it completely changed the way of treatment and removed the human error.  In future we can expect major growth of AI in Genomics Sequencing. Rather it is currently being used in countries like USA, and UK.

### 3.2 Conclusion

From this term paper, we can conclude that there is a lot of scope of artificial Intelligence in personalized healthcare. The only need is to implement it in our health sector. As we know that PwC tells that artificial intelligence will contribute an additional 15.7 trillion to the world economy by 2030. This data is clearly showing how fast we are implementing it.