What is a Red Black Tree? Red-Black Tree is a self-balancing Binary Search Tree (BST) ...

Read More »## C Program for Drawing a Line using Bresenham Line Algorithm

#include<graphics.h> #include<conio.h> #include<stdio.h> void main() { int gd=DETECT,gm; int x1,y1,x2,y2,x,y,dy,dx,p; float m; clrscr(); initgraph(&gd,&gm,"c:\\tc\\"); printf("Enter first co-ords of line\n"); scanf("%d",&x1); scanf("%d",&y1); printf("Enter second co-ords of line\n"); scanf("%d",&x2); scanf("%d",&y2); dy=y2-y1; dx=x2-x1; m=(float)(y2-y1)/(x2-x1); x=x1;y=y1; if(m>1.0) { printf("This algorithm is not applicable!!! press Enter to exit\n"); }else { p=2*dy-dx; while(x<x2) { if(p>=0) { putpixel(x,y,5); y=y+1; p=p+2*dy-2*dx; } else { putpixel(x,y,5); p=p+2*dy; } x=x+1; ...

Read More »