9. WRITE A PROGRAM TO IMPLEMENT K-NEAREST NEIGHBOUR ALGORITHM TO CLASSIFY THE IRIS DATA SET. PRINT BOTH CORRECT AND WRONG PREDICTIONS. JAVA/PYTHON ML LIBRARY CLASSES CAN BE USED FOR THIS PROBLEM. SOLUTION 1  NO DATASET FOR SOLUTION 1  REQUIRES INTERNET lab9.pyfrom sklearn.datasets import load_irisfrom sklearn.neighbors import KNeighborsClassifierfrom sklearn.model_selection import train_test_splitimport numpy as np dataset=load_iris()X_train,X_test,y_train,y_test=train_test_split(dataset[“data”],dataset[“target”],random_state=0) kn=KNeighborsClassifier(n_neighbors=1)kn.fit(X_train,y_train) for i in range(len(X_test)):    x=X_test[i]  ..

Read more

2. FOR A GIVEN SET OF TRAINING DATA EXAMPLES STORED IN A .CSV FILE, IMPLEMENT AND DEMONSTRATE THE CANDIDATE-ELIMINATION ALGORITHM TO OUTPUT A DESCRIPTION OF THE SET OF ALL HYPOTHESES CONSISTENT WITH THE TRAINING EXAMPLES.SOLUTION  1 trainingdata.csv Sunny Warm Normal Strong Warm Same Yes Sunny Warm High Strong Warm Same Yes Rainy Cold High Strong Warm Change ..

Read more

8. Write a program to find the shortest path between vertices using bellman-ford algorithm.BellmanFord.java – PROGRAMimport java.util.Scanner;public class BellmanFord { int d[],noofvertices; public BellmanFord(int noofvertices)  { this.noofvertices = noofvertices; d = new int[noofvertices + 1]; } public static void main(String[] args)  { int noofvertices,source; Scanner s = new Scanner(System.in); System.out.println(“Enter the number of vertices:”); noofvertices = s.nextInt(); ..

Read more

1 B – Write a Java program to implement the Stack using arrays.Write Push(), Pop(), and Display() methods to demonstrate its working.import java.util.Scanner;public class lab1b { final int max=5; int s[]=new int[max]; int top=-1; void push(int ele) { if(top>=max-1) System.out.println(“stack overflow”); else s[++top]=ele; } int pop() { int z=0; if(top==-1) System.out.println(“stack underflow”); else z=s[top–]; return z; ..

Read more

5. Implement and study the performance of GSM on NS2/NS3 (Using MAC layer) or equivalent environment.cn5.tcl – PROGRAM# Simulation parameters setupset val(chan)   Channel/WirelessChannel    ;# channel typeset val(prop)   Propagation/TwoRayGround   ;# radio-propagation modelset val(netif)  Phy/WirelessPhy            ;# network interface typeset val(mac)    Mac/802_11                 ;# MAC typeset ..

Read more

8. WRITE THE PHP PROGRAMS TO DO THE FOLLOWING:A. IMPLEMENT SIMPLE CALCULATOR OPERATIONS.B. FIND THE TRANSPOSE OF A MATRIX.C. MULTIPLICATION OF TWO MATRICES.D. ADDITION OF TWO MATRICES. SOLUTION  1  Requires XAMPP control panel for Solution 1 If xampp is in the system, save the program in C:xampphtdocs (start apache in xampp control panel)   & Open Google Chrome & type http://localhost/prog8b.php prog8b.php<!DOCTYPE html><html><body> <?php function pr($a){ ..

Read more

9 – Find Minimum Cost Spanning Tree of a given connected undirected graph using Prim’s algorithm.import java.util.Scanner;public class lab9 { public static void main(String[] args)  { int w[][]=new int[10][10]; int n,i,j,s,k=0; int min;   int sum=0; int u=0,v=0; int flag=0; int sol[]=new int[10]; System.out.println(“Enter the number of vertices”); Scanner sc=new Scanner(System.in); n=sc.nextInt(); for(i=1;i<=n;i++) sol[i]=0; System.out.println(“Enter the weighted ..

Read more

5. Clip lines using Cohen-Sutherland algorithm#include<stdio.h>#include<GL/glut.h> #define true 1;#define false 0;#define bool int;double x,y;int xmin=50,xmax=100,ymin=50,ymax=100;const int RIGHT=8,LEFT=2,TOP=4,BOTTOM=1;int outcode0,outcode1,outcodeout,done,accept; int computeoutcode(double x,double y){  int code=0;  if(y>ymax)    code|=TOP;  else if(y<ymin)    code|=BOTTOM;  if(x>xmax)    code|=RIGHT;  else if(x<xmin)    code|=LEFT;  return code;} void LineClip(double x0,double y0,double x1,double y1){  int accept=false;  int done=false;  outcode0=computeoutcode(x0,y0);  outcode1=computeoutcode(x1,y1);  do{    if(!(outcode0|outcode1))  ..

Read more