0% found this document useful (0 votes)
8 views3 pages

Technical 2

The document discusses binary tree traversal algorithms including inorder, preorder, and postorder traversal. It defines a node structure with left and right child pointers and item values. Functions are defined to create nodes, insert nodes as children, and perform the different traversal types by recursively visiting nodes. An example binary tree is created and each traversal type is demonstrated on it by calling the respective traversal functions.

Uploaded by

NIRANJAN BEHERA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Technical 2

The document discusses binary tree traversal algorithms including inorder, preorder, and postorder traversal. It defines a node structure with left and right child pointers and item values. Functions are defined to create nodes, insert nodes as children, and perform the different traversal types by recursively visiting nodes. An example binary tree is created and each traversal type is demonstrated on it by calling the respective traversal functions.

Uploaded by

NIRANJAN BEHERA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

1. What is language ?

2. what is the need of communication ?


3. what do you mean by programming language and its need ?

4. what is meaning by computer programming language ?


Ans. C is a genral purpose compiler based High level lanuage.
i.with C we can develop Operating system.
ii.Editor software.
iii.Design compilers
iv.Gaming applications
v.Application software

5. different kind of application


standard alone application
web applincation
network, Gaming
6. #include<stdio.h>
main()
{
printf("hello")
}

#include <stdio.h>
#include <stdlib.h>
struct node{
int item;
struct node* left;
struct node* right;
};
//In order traversal
void inorderTraversal(struct node* root){
if (root == NULL) return;
inorderTraversal(root->left);
printf("%d->", root->item);
inorderTraversal(root->right);
}
//preorder traversal
void preorderTraversal(struct node* root){
if (root == NULL) return;
printf("%d ->", root->item);
preorderTraversal(root->left);
preorderTraversal(root->right);
}
//postorder traversal
void postorderTraversal(struct node* root){
if (root == NULL) return;
postorderTraversal(root->left);
postorderTraversal(root->right);
printf("%d ->", root->item);
}
//create a new node
struct node* createNode(value){
struct node* newNode = malloc(sizeof(struct node));
newNode->item = value;
newNode->left = NULL;
newNode->right = NULL;
return newNode;
}
//insert on the left of the node
struct node* insertLeft(struct node* root, int value){
root->left = createNode(value);
return rooot->left;
}

46.
#include <stdio.h>
#include <stdlib.h>
struct node{
int item;
struct node* left;
struct node* right;
};
//In order traversal
void inorderTraversal(struct node* root){
if (root == NULL) return;
inorderTraversal(root->left);
printf("%d->", root->item);
inorderTraversal(root->right);
}
//preorder traversal
void preorderTraversal(struct node* root){
if (root == NULL) return;
printf("%d ->", root->item);
preorderTraversal(root->left);
preorderTraversal(root->right);
}
//postorder traversal
void postorderTraversal(struct node* root){
if (root == NULL) return;
postorderTraversal(root->left);
postorderTraversal(root->right);
printf("%d ->", root->item);
}
//create a new node
struct node* createNode(value){
struct node* newNode = malloc(sizeof(struct node));
newNode->item = value;
newNode->left = NULL;
newNode->right = NULL;
return newNode;
}
//insert on the left of the node
struct node* insertLeft(struct node* root, int value){
root->left = createNode(value);
return rooot->left;
}

int main(){
struct node* root = createNode(1);
insertLeft(root,2);
insertRight(root,3);
insertLeft(root->left,4);
insertRight(root->right,5);
insertLeft(root->left,6);
printf("Indorer traversal \n");
inorderTraversal(root);
printf("\n Predorer traversal \n");
preorderTraversal(root);
printf(" \nPostdorer traversal \n");
postorderTraversal(root);
}

You might also like