Search Results

Search found 133 results on 6 pages for 'davit datuashvili'.

Page 5/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • i have done code so please help

    - by davit-datuashvili
    public class bitap{ public static void main(String[]args){ String text="tbillisi"; String pattern="tbilxiri"; int k=2; int m=pattern.length(); long pattern_mask[]=new long[Character.MAX_VALUE+1]; String result=""; boolean[]R=new boolean[m+1]; long i,d; for (i=0;i<=k;i++){ R[i]=~1; } for (i=0;i if (0==(R[k]& (1< System.out.println(result); } } http://en.wikipedia.org/wiki/Bitap_algorithm from this site

    Read the article

  • comlen function in Java

    - by davit-datuashvili
    in c or c++ the function comlen is defined such int comlen(char *p,char *q){ int i=0; while *p && (*p++==*q++) i++; return i; } Is this code equivalent of this function? int comlen(String s,String m){ int i=0; while (i<s.length() && s.charAt(i)==m.charAt(i)){ i++; } return i; }

    Read the article

  • generate k distinct number less then n

    - by davit-datuashvili
    hi i have following question task is this generate k distinct positive numbers less then n without duplication my method is following first create array size of k where we should write these numbers int a[]=new int[k]; //now i am going to cretae another array where i check if (at given number position is 1 then generate number again else put this number in a array and continue cycle i put here a piece of code and explanations int a[]=new int[k]; int t[]=new int[n+1]; Random r=new Random(); for (int i==0;i<t.length;i++){ t[i]=0;//initialize it to zero } int m=0;//initialize it also for (int i=0;i<a.length;i++){ m=r.nextInt(n);//random element between 0 and n if (t[m]==1){ //i have problem with this i want in case of duplication element occurs repeats this steps afain until there will be different number else{ t[m]=1; x[i]=m; } } so i fill concret my problem if t[m]==1 it means that this element occurs already so i want to generate new number but problem is that number of generated numbers will not be k beacuse if i==0 and occurs duplicate element and we write continue then it will switch at i==1 i need like goto for repeat step or for (int i=0;i<x.length;i++){ loop: m=r.nextInt(n); if ( x[m]==1){ continue loop; } else{ x[m]=1; a[i]=m; continue;//continue next step at i=1 and so on } } i need this code in java please help

    Read the article

  • longest increasing subsequent

    - by davit-datuashvili
    i have write this code is it correct? public class subsequent{ public static void main(String[] args){ int a[]=new int[]{0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}; int a_b[]=new int[a.length]; a_b[0]=1; int int_max=0; int int_index=0; for (int i=0;i<a.length;i++){ for (int j=0;j<i;j++){ if (a[i]>a[j] && a_b[i]<(a_b[j]+1)){ a_b[i]=a_b[j]+1; } } if (a_b[i]>int_max){ int_max=a_b[i]; int_index=i; } } int k=int_max+1; int list[]=new int[k]; for (int i=int_index;i>0;i--){ if (a_b[i]==k-1){ list[k-1]=a[i]; k=a_b[i]; } } for (int g=0;g<list.length;g++){ System.out.println(list[g]); } } }

    Read the article

  • question about combinatorical

    - by davit-datuashvili
    here is task How many ways are there to choose from the set {1, 2, . . . , 100} three distinct numbers so that their sum is even? first of all sum of three numbers is even if only if 1.all number is even 2.two of them is odd and one is even i know that (n) = n!/(k!*(n-k)! (k) and can anybody help me to solve this problem

    Read the article

  • complexity of algorithms

    - by davit-datuashvili
    i have question what is complexity of this algorithm public class smax{ public static void main(String[]args){ int b[]=new int[11]; int a[]=new int[]{4,9,2,6,8,7,5}; for (int i=0;i int m=0; while (m int k=a[0]; for (int i=0;i k && b[a[i]]!=1){ b[a[i]]=1; } } m++; } for (int i=0;i for (int j=0;j //result=2 4 5 6 7 8 9 } } ?

    Read the article

  • programming books [closed]

    - by davit-datuashvili
    I have only one dream -- to buy these two books: Introduction to Algorithms, Third Edition Concrete Mathematics: A Foundation for Computer Science Sorry for my dream, this is a site for posting programming questions, but unfortunately everything happened

    Read the article

  • serious problems please help me

    - by davit-datuashvili
    guys some of you tell me that i have not accepted your answers on my problems or it is 0 % accepted answers really trust me it is technical problem i did not know what to do in case of get answers please tell me what to do i have accepted all answers they helped me very much what to do? can u explain me what to do and how to do in case i will get correct answers and i accept it?

    Read the article

  • question about permut-by-sorting

    - by davit-datuashvili
    hi i have following question from book introduction in algorithms second edition there is such problem suppose we have some array A int a[]={1,2,3,4} and we have some random priorities array P={36,3,97,19} we shoud permut array a randomly using this priorities array here is pseudo code P ERMUTE -B Y-S ORTING ( A) 1 n ? length[A] 2 for i ? 1 to n do P[i] = R ANDOM(1, n 3 ) 3 4 sort A, using P as sort keys 5 return A and result will be permuted array B={2, 4, 1, 3}; please help any ideas i have done this code and need aideas how continue import java.util.*; public class Permut { public static void main(String[]args){ Random r=new Random(); int a[]=new int[]{1,2,3,4}; int n=a.length; int b[]=new int[a.length]; int p[]=new int[a.length]; for (int i=0;i<p.length;i++){ p[i]=r.nextInt(n*n*n)+1; } // for (int i=0;i<p.length;i++){ // System.out.println(p[i]); //} } } please help

    Read the article

  • question about random select

    - by davit-datuashvili
    here is code print number in decreasing order import java.util.*; public class select { public static void Select(int m,int n){ Random r=new Random(); if (m>0) if (r.nextInt(0x3fff8001) % n <m ){ System.out.println(n-1); Select(m-1,n-1); } else{ Select(m,n-1); } } public static void main(String[]args){ int m=35; int n=200; Select(m,n); } } and question is how to changes code such that print number in increasing order? please help

    Read the article

  • question about Littles Law

    - by davit-datuashvili
    I know that Little's Law states (paraphrased): the average number of things in a system is the product of the average rate at which things leave the system and the average time each one spends in the system, or: n=x*(r+z); x-throughput r-response time z-think time r+z - average response time now i have question about a problem from programming pearls: Suppose that system makes 100 disk accesses to process a transaction (although some systems require fewer, some systems will require several hundred disk access per transaction). How many transactions per hour per disk can the system handle? please help

    Read the article

  • please help me to solve problem

    - by davit-datuashvili
    hi everybody fisrt of all this is not homework and now question is like this suppose i have array int a[]=new int[]{0xBCDA,0xABFE,0xBCAD,0xEFCA,0xFFCA} i know that there is always some hexadecimal number which occurs in all number or in this case A is repeat in array everywhere so my aim is print only repeat number and other numbers should be zero so my new array should be like this 0x000A, 0xA000,0x00A0 0x000A,0x000A any idea please help me? p.s please nobody say that this is homework

    Read the article

  • question on reverse array

    - by davit-datuashvili
    we know algorithm how reverse array of n integers for (int i=0;i<n/2;i++){ swap(a[i],a[n-1-i]): } is this method better according the speed of algorithm or not because swap using xor is more fast then in other method here is code public class swap { public static void main(String[]args){ int a[]=new int[]{2,4,5,7,8,11,13,12,14,24}; System.out.println(" array at the begining:"); for (int i=0;i<a.length;i++){ System.out.println(a[i]); } for (int j=0;j<a.length/2;j++){ a[j]^=a[a.length-1-j]; a[a.length-1-j]^=a[j]; a[j]^=a[a.length-1-j]; } System.out.println("reversed array:"); for (int j=0;j<a.length;j++){ System.out.println(a[j]); } } } Result: array at the begining: 2 4 5 7 8 11 13 12 14 24 reversed array: 24 14 12 13 11 8 7 5 4 2

    Read the article

  • select k th mimimum from array a[0..n-1]

    - by davit-datuashvili
    i have done folloing code from progrmming pearls here is code import java.util.*; public class select { public static int select1(int x[],int l,int u,int k){ //pre l<=k<=u //post x[l..k-1]<=x[k]<=x[k+1..u] Random r=new Random(); int t=r.nextInt(u-1-l)+l; if (l>=u) return -1 ; swap(l,t); int s=x[l]; int i=l; int j=u+1; while (true){ do { i++; }while (i<=u && x[i]<t); do { j--; }while (x[j]>t); if (i>j) break; int temp=x[i]; x[i]=x[j];x[j]=t; swap(l,j); if (j<k){ return select1(x,j+1,u,k); } } return select1(x,l,j-1,k); } public static void main(String[] args) { int x[]=new int[]{4,7,9,3,2,12,13,10,20}; select1(x,0,x.length-1,5); } public static void swap(int i,int j){ int c=i; i=j; j=c; } } but here is mistake Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 at select.select1(select.java:21) at select.main(select.java:36) Java Result: 1 please help

    Read the article

  • priority queue implementation

    - by davit-datuashvili
    i have implemented priority queue and i am interested if it is correct public class priqueue { private int n,maxsize; int x[]; void swap(int i,int j){ int t=x[i]; x[i]=x[j]; x[j]=t; } public priqueue(int m){ maxsize=m; x=new int [maxsize+1]; n=0; } void insert(int t){ int i,p; x[++n]=t; for (i=n;i>1 && x[p=i/2] >x[i];i=p) swap(p,i); } public int extramin(){ int i,c; int t=x[1]; x[1]=x[n--]; for (i=1;(c=2*i)<=n;i=c){ if (c+1<=n && x[c+1]<x[c]) c++; if (x[i]<=x[c]) break; swap(c,i); } return t; } public void display(){ for (int j=0;j<x.length;j++){ System.out.println(x[j]); } } } public class priorityqueue { public static void main(String[] args) { priqueue pr=new priqueue(12); pr.insert(20); pr.insert(12); pr.insert(22); pr.insert(15); pr.insert(35); pr.insert(17); pr.insert(40); pr.insert(51); pr.insert(26); pr.insert(19); pr.insert(29); pr.insert(23); pr.extramin(); pr.display(); } } //result: 0 12 15 17 20 19 22 40 51 26 35 29 23

    Read the article

  • it is very important for me this problem [closed]

    - by davit-datuashvili
    please help this is very important problem for me i am going to get job and need such kind of practise implement heaps priortiy queue and so on what is wrong in my java code please tell i want insert number with heap property and return minimum element what is wrong explain please look http://stackoverflow.com/questions/2902781/priority-queue-implementation/2903288#2903288

    Read the article

  • fill array with binary numbers

    - by davit-datuashvili
    hi, first of all this is not homework!! my question is from book: Algorithms in C++ third edition by robert sedgewick question is: there is given array of size n by 2^n(two dimensional) and we should fill it by binary numbers with bits size exactly n or for example n=5 so result will be 00001 00010 00011 00100 00101 00110 00111 and so on we should put this sequence of bits into arrays please help me

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >