Tree Definition of Tree: Tree is finite set of nodes with one specially designated node called the root and the remaining nodes are partitioned into n>=0 disjoint sets T1 & Tn which are called the sub-root trees of the root. Types of Trees: Binary Tree :- It's finite set of nodes, with one special node called root and the other nodes are partitioned into two disjoints sets, which are binary tree called its left and right subtree. It is a tree where every nodes can have atmost two branches. Stritly Binary Tree :- Strictly binary tree is a where all no-leaf nodes have two branches. A Strictly binary tree may not be full. All leaf nodes may not be the same levels. Complete Binary Tree(Full Binary Tree):- Full binary tree of depth d has 2d-1 nodes, In a full binary tree, all the levels are full and all leaf nodes are the same level. Full binary tree is a strictly binary tree. All leaf nodes are the same level Al-Most Complete Bi...
Heap-Sort CODE 👇 #include<stdio.h> #include<stdlib.h> void heapsort(int a[], int n); void heapify(int a[], int i, int last); void buildheap(int a[], int n); void display(int a[], int n); void heapsort(int a[10], int n) { int i,temp; buildheap(a,n); printf("\n Initialize Heap"); display(a,n); printf("\n"); for(i=n-1; i>=1; i--) { temp=a[0]; a[0]=a[i]; a[i]=temp; printf("\nAfter %d Iteration-->", n-i); display(a,n); //printf("\n"); heapify(a, 0, i-1); } } void buildheap(int a[], int n) { //convert a[0] ... a[n-1] into heap int i; for(i=(n/2)-1; i>=0; i--) heapify(a,i, n-1); } void heapify(int a[], int i, int last) { int j, temp, key; key=a[i]; j=2*i+1; if((j<last )&&(a[j]<a[j+1])) j=j+1; if((j<=last)&&(key < a[j])) { temp = a[i]; a[i] = a[j]; a[j] = temp; heapify(a, j ,last); } } void display(int a[...