Q.1 write a program to create binary tree 1 to 16 numbers?
Q.2 write a program to creat a binary search tree for the
member that is given by user?
Answer / Gaurav Rastogi
C|```cn// Q.1 Creating Binary Tree with numbers from 1 to 16n#include <stdio.h>n#include <stdlib.h>n#define SIZE 16nnstruct Node {n int data;n struct Node* left;n struct Node* right;n};nnstruct Node* createNode(int value)n{n struct Node* node = (struct Node*)malloc(sizeof(struct Node));n if(node == NULL) {n printf("Memory Error
");n return NULL;n }nn node->data = value;n node->left = NULL;n node->right = NULL;nn return node;n}nnstruct Node* createTree()n{n struct Node* root = createNode(1);n root->left = createNode(2);n root->right = createNode(3);nn root->left->left = createNode(4);n root->left->right = createNode(5);nn root->right->left = createNode(6);n root->right->right = createNode(7);nn root->left->left->left = createNode(8);n root->left->left->right = createNode(9);nn root->left->right->left = createNode(10);n root->left->right->right = createNode(11);nn root->right->left->left = createNode(12);n root->right->left->right = createNode(13);nn root->right->right->left = createNode(14);n root->right->right->right = createNode(15);nn return root;n}nnvoid inorderTraversal(struct Node* node)n{n if(node == NULL) return;nn inorderTraversal(node->left);n printf("%d ", node->data);n inorderTraversal(node->right);n}nnint main()n{n struct Node* root = createTree();n inorderTraversal(root);n return 0;n}
| Is This Answer Correct ? | 0 Yes | 0 No |
Write a program to find the smallest and largest element in a given array in c language
What kind of structure is a house?
Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
Why data types in all programming languages have some range? Why ritche have disigned first time likethat?Why not a single data type can support all other types?
can we store values and addresses in the same array? explain
A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor
What is the process to generate random numbers in c programming language?
What are the 4 data types?
5. distance conversion: Convert a distance from miles to kilometers .there are 5280 feets per mile,12 inches per foot .2.54 centimeters per inch and 100000centimeters per kilometer
What is the difference between printf and scanf )?
write a c program to find the roots of a quadratic equation ax2 + bx + c = 0
11 Answers CSC, St Marys, TATA,
Explain logical errors? Compare with syntax errors.