Posts

Showing posts from October, 2017

Link list using c++

Image
Link list using c++ Knowledge of linked lists is must for C programmers. This article explains the fundamentals of C linked list with an example C program. Linked list is a dynamic data structure whose length can be increased or decreased at run time. How Linked lists are different from arrays? Consider the following points : An array is a static data structure. This means the length of array cannot be altered at run time. While, a linked list is a dynamic data structure. In an array, all the elements are kept at consecutive memory locations while in a linked list the elements (or nodes) may be kept at any location but still connected to each other. #include<stdio.h> #include<conio.h> #include<alloc.h> #include<process.h> struct linklist {                 int n;                 struct linklist *next; }; typedef struct linklist node; struct linklist *head,*head1; void displayNode() {                 node *temp;             

White Board Video

Image

Binary Search Algorithm using c/c++

Binary Search Algorithm using c/c++ Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty. Binary search Program #include<stdio.h> #include<conio.h> void main() {                 int a[100],n,i,x;                 void sorts(int [],int);                 int binser(int [],int,int,int);                 clrscr();                 printf("How many Element are insert? ");                 scanf("%d",&n);                 printf("Enter Element");                 for(i=0;i<n;i++)                 {                                 printf("\nEnter Element %dth : ",i);                                 scanf("%d",&

Greedy Prim Algorithm using c/c++

Greedy Prim Algorithm using c/c++ In computer science, Prim's algorithm is a greedy algorithm that finds a minimum spanning tree for a weighted undirected graph. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized. The algorithm operates by building this tree one vertex at a time, from an arbitrary starting vertex, at each step adding the cheapest possible connection from the tree to another vertex. #include<stdio.h> #include<conio.h> #include<iostream.h> enum logical {TRUE=1,FALSE=0}; struct edge {                 int from,to ;                 float cost ;                 logical rejected,selected ; }; int nv,ne; struct edge e[20]; void greedy_prim(); logical isnear(int j); void main() {                 clrscr();                                 int i ;                 cout << "No. of vertices = " ;                 cin >