Posts

Servlet Program to Print Today’s Date and Time using refresh header

Simple Java Servlet Program to Print Date and Time using refresh header (Time updates automatically) Code: import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.Date; public class servlet2 extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse rsp) throws ServletException, IOException { rsp.setIntHeader("Refresh", 1); rsp.setContentType("text/html"); PrintWriter out = rsp.getWriter(); Date now = new Date(); out.println("<html>"); out.println("<head><title> Time Check </title></head>"); out.println("<body>"); out.println("<p text-align=auto>Current Time: " + now + "</p>"); out.println("</body></html>"); } }

Java program to implement Word Count using Map-Reduce in Hadoop Cluster

Simple Java program to implement Word Count using Map-Reduce in Hadoop Cluster Code: import java.io.IOException; import java.util.StringTokenizer;  import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.Reducer; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;   public class wc {     public static class TokenizerMapper     extends Mapper<Object, Text, Text, IntWritable>{   private final static IntWritable one = new IntWritable(1); private Text word = new Text();   public void map(Object key, Text value, Context context                 ) throws IOException, InterruptedException {   StringTokenizer itr = new StringTokenizer(value.toString());   while (itr.hasMoreTokens()) {    

C program to implement Doubly Circular Linked List Data Structure

Simple C program to implement Doubly Circular Linked List Data Structure along with following operations: Insertion at end Insertion at front Insert after a value Insert before a value Delete at end Delete at front Delete after a value Delete before a value Delete element itself Delete the whole list Display linked list Code: #include<stdio.h> #include<conio.h> #include<stdlib.h> struct node{ int data; struct node *next; struct node *prev; }; struct node *head,*tail; void insertend(){ int val; printf("\nEnter the value to be Entered: "); scanf("%d",&val); struct node *head2; head2=head; struct node *temp; temp=(struct node*)malloc(sizeof(struct node)); temp->data=val; temp->next=NULL; temp->prev=NULL; if(head==NULL){ head=temp; temp->next=head; temp->prev=head; } else{ while(head2->next!=head){ head2=head2->next; } temp->prev=head2; temp->next=head; head2->next=temp; tail=temp; head-

Java program to implement Apriori Algorithm

Simple Java program to implement Apriori Algorithm Code: package apriori; import com.sun.xml.internal.ws.util.StringUtils; import java.util.*; import java.lang.Object; public class Apriori { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter Number Of Transactions:"); int n = sc.nextInt(); System.out.println("Enter Minumum Limit:"); int min = sc.nextInt(); sc.nextLine(); ArrayList<Set<String>> aray = new ArrayList<>(); Set<String> list = new HashSet<>(); Set<String> list1= new HashSet<>(); Set<String> list2,list3,list4; System.out.println("Enter Item id saperated by space per transaction"); for(int i=0;i<n;i++){ System.out.println("Entere Item Id included in transaction-"+(i+1)); String tempp =sc.nextLine(); Se

Java program to check the given string is palindrome or not without using Reverse String

Simple Java program to check the given string is palindrome or not without using Reverse String Code: import java.util.Scanner; class p84{public static void main(String args[]){ Scanner sc = new Scanner(System.in); String s = sc.nextLine(); boolean palindrome=true; int j=(s.length()-1); for(int i=0;i<(s.length()/2);i++){ if(s.charAt(i)!=s.charAt(j)){palindrome=false;} j--; } if(palindrome){System.out.println("palindrome");} else{System.out.println("Not palindrome");} }}