Skip to main content

What is Divide And Conquer Technique

Divide and Conquer is a programming technique which makes the program more efficient to write. And this technique work on the concept of recursion to solve a problem step by step. Generally this technique work in three parts:- Divide:-  Divide the problem into some subproblem. Conquer:-  Conquer the subproblem by calling recursively until subproblem solved. Combine:-  (Optional Step) Combine the subproblem solution. So, that we will get the final problem Solution.  When the subproblems are large enough to solve recursively, we call the recursive case. Once the subproblem becomes small enough that we no longer recursive, we say that the recursion "bottom out" and that we have gotten down to the base case.                          Application of Divide and Conquer Quick Sort Strassen's algorithm for matrix multiplication Merge Sort Counting inversions Binary Search Finding Min and ...

Extracting all states of India from wikipedia link using Jsoup jar and Java language

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package urldatafetch;

/**
 *
 * @author Rishabh
 */
import java.io.IOException;
import java.io.PrintWriter;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;



public class testing {
public static void main(String[] args) throws IOException {


      org.jsoup.nodes.Document doc = Jsoup.connect("https://en.wikipedia.org/wiki/India").get();
      org.jsoup.select.Elements tables =doc.select("table");
       // org.jsoup.select.Elements rows = doc.select("tr");
        PrintWriter pw=new PrintWriter("tabledata.txt");
       int i=1;
       int j=1;
       int k=1;
       String state[]=new String[29];
     for(org.jsoup.nodes.Element tableo :tables)
     {  if(i==1 ||i==2 ||i==4){i++;}
     else if(i==3)
     {  org.jsoup.select.Elements rows=tableo.select("tr");
        for(org.jsoup.nodes.Element row :rows)
        {
            org.jsoup.select.Elements columns = row.select("td");
            for (org.jsoup.nodes.Element column:columns)
            {
              if(j==29){j=1;}
             
             
                if(j<=29){
                if(column.text().contains(j+"."))
                {   if(j<10){
                    String mol=column.text().substring(3);
                    pw.append(column.text());
                    state[j-1]=mol;
              // System.out.println(column.text());
                System.out.println(mol);}
                 if(j>9){
                    String mol=column.text().substring(4);
                    pw.append(mol);
                    state[j-1]=mol;
                System.out.println(mol);}
              j++;  }
            }

            }
            //System.out.println();
         
            i++;
        }}}
}
}

Comments

  1. Borgata Hotel Casino & Spa | Jobs, Careers | KTRK
    Welcome to 영천 출장안마 Borgata 바카라 신규 가입 쿠폰 Hotel 여주 출장안마 Casino & Spa! Our flagship property, Borgata Hotel Casino & Spa has become 시흥 출장샵 an exciting destination 전라남도 출장마사지 for travelers visiting

    ReplyDelete

Post a Comment

Popular posts from this blog

What is Divide And Conquer Technique

Divide and Conquer is a programming technique which makes the program more efficient to write. And this technique work on the concept of recursion to solve a problem step by step. Generally this technique work in three parts:- Divide:-  Divide the problem into some subproblem. Conquer:-  Conquer the subproblem by calling recursively until subproblem solved. Combine:-  (Optional Step) Combine the subproblem solution. So, that we will get the final problem Solution.  When the subproblems are large enough to solve recursively, we call the recursive case. Once the subproblem becomes small enough that we no longer recursive, we say that the recursion "bottom out" and that we have gotten down to the base case.                          Application of Divide and Conquer Quick Sort Strassen's algorithm for matrix multiplication Merge Sort Counting inversions Binary Search Finding Min and ...

Sorting numbers using LinkList in C Language

#include<stdio.h> #include<conio.h> //creating  a structure for linked list typedef struct node {     int data;     struct node* next; }node;     //rename whole structure // function for creating nodes of linked list node * createlinkedlist(int n); //return address void display(node * head); void sort1(node * head,int n); int main(){ int n=0; node* HEAD=NULL; node* HEAD1=NULL; printf("how many nodes want to add in a linklist "); scanf("%d",&n); HEAD=createlinkedlist(n); sort1(HEAD,n); display(HEAD); return 0; } node * createlinkedlist(int n) {     int i=0;     node * head=NULL;     node * temp=NULL;     node * p=NULL;     for(i=0;i<n;i++)     {         //creating unattached node         temp=(node*)malloc(sizeof(node));       ...

Reverse Words

Reverse Words Given a list of space separated words, reverse the order of the words. Each line of text contains L letters and W words. A line will only consist of letters and space characters. There will be exactly one space character between each pair of consecutive words. Input The first line of input gives the number of cases, N. N test cases follow. For each test case there will a line of letters and space characters indicating a list of space separated words. Spaces will not appear at the start or end of a line. import java.io.BufferedReader; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Scanner; import java.util.Stack; import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; /**  *  * @author Rishabh  */ public class Reversestring  {     public static void main(String[] args) ...