Search Results

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

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

  • please help me to choose good boks on algorithms

    - by davit-datuashvili
    i want to help me to choose good books on algorithms many people from this site say me that show me your code and now i ask u to help me to choose good books on algorithms please i have not books on algorithms and in case i decide to buy it of course must buy book which has high quality yes? so please any ideas ?links everything

    Read the article

  • please help me to implement such kind of sort

    - by davit-datuashvili
    hi i need to write sucj kind of sorting maybe it is similary to radix sort and also (this is not homework because i created it problem myself and please if anobody can help me) problem is like this suppose i have array int x[]=new int[]{4,5,3,2,1}; let write it into binary form 5 -0101 4- 0100 3-0011 2-0010 1-0001 i want to sort this elements by using bitwise operatos or check each bit and if less exchange it can anybody help me for example take 5 and 4 check first rightmost bit 0==0 so continue in the 1 index also 1==1 next the same 0=0 and last one 10 it means that first element is greater then second so exchange it please help me

    Read the article

  • question about tree

    - by davit-datuashvili
    i have question for example i want to implement binary tree with array i want understand what will indexes for left child and rigth child ?my array is 0 based i want implement searching in tree using array can anybody help me?

    Read the article

  • Question about permute-by-sorting

    - by davit-datuashvili
    In the book "Introduction to Algorithms", second edition, there is the following problem: Suppose we have some array: int a[] = {1,2,3,4} and some random priorities array: P = {36,3,97,19} and the goal is to permute the array a randomly using this priorities array. This is the pseudo code: PERMUTE-BY-SORTING (A) 1 n ? length[A] 2 for i ? 1 to n 3 do P[i] = RANDOM (1, n 3) 4 sort A, using P as sort keys 5 return A The result should be the permuted array: B={2, 4, 1, 3}; I have written this code: import java.util.*; public class Permute { 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]); //} } } How do I continue?

    Read the article

  • question about permutation problem

    - by davit-datuashvili
    i have posted similar problem here http://stackoverflow.com/questions/2920315/permutation-of-array but i want following we know that with length n there is n! possible permutation from which one such that all element are in order they are in sorted variant so i want break permutation when array is in order and print result but something is wrong i think that problem is repeated of permutation here is my code import java.util.*; public class permut{ public static Random r=new Random(); public static void display(int a[],int n){ for (int i=0;i<n;i++){ System.out.println(a[i]); } } public static void Permut(int a[],int n){ int j=0; int k=0; while (j<fact(n)){ int s=r.nextInt(n); for (int i=0;i<n;i++){ k=a[i]; a[i]=a[s]; a[s]=k; } j++; if (sorted(a,n)) display(a,n); break; } } public static void main(String[]args){ int a[]=new int[]{3,4,1,2}; int n=a.length; Permut(a,n); } public static int fact(int n){ if (n==0 || (n==1) ) return 1; return n*fact(n-1); } public static boolean sorted(int a[],int n ){ boolean flag=false; for (int i=0;i<n-1;i++){ if (a[i]<a[i+1]){ flag=true; } else{ flag=false; } } return flag; } } can anybody help me? result is nothing

    Read the article

  • Longest increasing subsequence

    - by davit-datuashvili
    I have written this code; is it correct? 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

  • very simple question but i am confused

    - by davit-datuashvili
    Suppose we have the following method (it is in c code): const char *bitap_search(const char *text, const char *pattern) My question is how can I compare text and pattern if they are char? This method is like a substring problem but I am confused a bit can I write in term of char such code? if (text[i]==pattern[i])?

    Read the article

  • question about heapsearch order

    - by davit-datuashvili
    ia have meet following problem suppose we have sorted array of size 2^k-1 where k is given number we should copy this array into heapsearch array b the elements in odd positions of a go in order into last half of the positions of b positions congruent to 2 modul0 4 go into b's secodn quarter and so on this is not homework and please nobody tag it as homework it is from programming pearls please any ideas

    Read the article

  • very confused please answer [closed]

    - by davit-datuashvili
    hi i am very surpise when somebody post question everybody are saying it is homework please show us your effort now i have done this code http://stackoverflow.com/questions/2902781/priority-queue-implementation question is is this implementation correct? and nobody tell me answer also this one http://stackoverflow.com/questions/2896811/question-about-siftdown-operation-on-heap-closed can anybody explain me what is happened?no one answer me why?

    Read the article

  • question about partition

    - by davit-datuashvili
    i have question about hoare partition method here is code and also pseudo code please if something is wrong correct pseudo code HOARE-PARTITION ( A, p, r) 1 x ? A[ p] 2 i ? p-1 3 j ? r +1 4 while TRUE 5 do repeat j ? j - 1 6 until A[ j ] = x 7 do repeat i ? i + 1 8 until A[i] = x 9 if i < j 10 then exchange A[i] ? A[ j ] 11 else return j and my code public class Hoare { public static int partition(int a[],int p,int r) { int x=a[p]; int i=p-1; int j=r+1; while (true) { do { j=j-1; } while(a[j]>=x); do { i=i+1; } while(a[i]<=x); if (i<j) { int t=a[i]; a[i]=a[j]; a[j]=t; } else { return j; } } } public static void main(String[]args){ int a[]=new int[]{13,19,9,5,12,8,7,4,11,2,6,21}; partition(a,0,a.length-1); } } and mistake is this error: Class names, 'Hoare', are only accepted if annotation processing is explicitly requested 1 error any ideas

    Read the article

  • bidirectional buble sort

    - by davit-datuashvili
    Here is the code I'm using for shacker sort (or bidirectional buble sort). Something is wrong; the error is java.lang.ArrayIndexOutOfBoundsException. Can anybody help me? public class bidirectional{ public static void main(String[]args){ int x[]=new int[]{12,9,4,99,120,1,3,10}; int j; int n=x.length; int st=-1; while (st<n){ st++; n--; for (j=st;j<n;j++) { if (x[j]>x[j+1]) { int t=x[j]; x[j]=x[j+1]; x[j+1]=t; } } for (j=n;--j>=st;) { if (x[j]>x[j+1]) { int t=x[j]; x[j]=x[j+1]; x[j+1]=t; } } } for (int k=0;k<x.length;k++) { System.out.println(x[k]); } } }

    Read the article

  • please help me to choose good books on algorithms [closed]

    - by davit-datuashvili
    Possible Duplicate: What is the best book for learning about Algorithms? i want to help me to choose good books on algorithms many people from this site say me that show me your code and now i ask u to help me to choose good books on algorithms please i have not books on algorithms and in case i decide to buy it of course must buy book which has high quality yes? so please any ideas ?links everything

    Read the article

  • question about interface

    - by davit-datuashvili
    i have posted this question http://stackoverflow.com/questions/2874487/how-can-i-implement-this-python-snippet-in-java i have compiled it now i need to use in main project public static void main(String[]args){ } ? can anybody show me example?

    Read the article

  • question about interface

    - by davit-datuashvili
    i have posted this question http://stackoverflow.com/questions/2874487/how-can-i-implement-this-python-snippet-in-java i have compiled it now i need to use in main project public static void main(String[]args){ } ? can anybody show me example?

    Read the article

  • question about interface

    - by davit-datuashvili
    i have posted this question http://stackoverflow.com/questions/2874487/how-can-i-implement-this-python-snippet-in-java i have compiled it now i need to use in main project public static void main(String[]args){ } ? can anybody show me example?

    Read the article

  • question on find value in array

    - by davit-datuashvili
    i have seen a few days ago such problem there is given two array find elements which are common of these array one of the solution was sort big array and then use binary search algorithm and also there is another algorithm- brute-force algorithm for (int i=0;i<array1.length;i++){ for (int j=0;j<array2.length;j++){ if (array1[i]==array2[j]){ //code here } } it's complexity is O(array1.length*array2.length); and i am interested the first method's complexity is also same yes? because we should sort array first and then use search method binary search algorithm's complexity is log_2(n) so it means that total time will be array.length*log_2(n) and about sort? please explain me which is better

    Read the article

  • question about Ackermann function

    - by davit-datuashvili
    i am doing to write recursive program which calculates Ackemann function http://en.wikipedia.org/wiki/Ackermann_function here is code public class Ackermann{ public static long ackermann( long m,long n){ return (m==0)? n+1: (m>0 && n==0)? ackermann(m-1,1): (m>0 && n>0)? ackermann(m-1, ackermann(m,n-1)); } public static void main(String[]args){ long m=4; long n=2; System.out.println(ackermann(m,n)); } } but it shows me mistakes Ackermann.java:7: : expected (m>0 && n>0)? ackermann(m-1, ackermann(m,n-1)); ^ Ackermann.java:7: ';' expected (m>0 && n>0)? ackermann(m-1, ackermann(m,n-1)); ^ Ackermann.java:18: illegal start of expression public static void main(String[]args){ ^ Ackermann.java:18: ';' expected public static void main(String[]args){ ^ Ackermann.java:18: illegal start of expression public static void main(String[]args){ ^ Ackermann.java:18: ';' expected public static void main(String[]args){ ^ Ackermann.java:18: ';' expected public static void main(String[]args){ ^ Ackermann.java:26: reached end of file while parsing } ^ 8 errors please help

    Read the article

  • question abouut string sort

    - by davit-datuashvili
    i have question from programming pearls problem is following show how to use lomuto's partitioning scheme to sort varying length bit strings in time proportional to the sum oof their length and algorithm is following each record in x[0..n-1] has an integer length and pointer to the array bit[0..length-1] code void bsort(l,u,depth){ if (l>=u) return; for (int i=l;i<u;i++) if (x[i].length<depth) swap(i,l++); m=l; if (x[i].bit[depth] ==0) swap(i,m++); bsort(l,m-1,depth+1); bsort(m,u,depth+1); please help me i need following things 1. how this algorith works 2.how implement in java?

    Read the article

  • is this code correct? [closed]

    - by davit-datuashvili
    hi i have poste this code from this title http://stackoverflow.com/questions/2896363/hi-i-have-question-here-is-pseudo-code-about-sift-up-and-sift-down-on-heaps i have following code of siftup on heap is it correct?i have put here because i have changed at old place my question and it became unreadable so i have posted here public class siftup{ public static void main(String[]args){ int p; int n=12; int a[]=new int[]{15,20,12,29,23,17,22,35,40,26,51,19}; int i=n-1; while (i!=0){ if (i==1) break; p=i/2; if (a[p]<=a[i]){ int t=a[p]; a[p]=a[i]; a[i]=t; } i=p; } for (int j=0;j<n;j++){ System.out.println(a[j]); } } } //result is this 15 20 19 29 23 12 22 35 40 26 51 17 is it correct?

    Read the article

  • extra storage merge sort

    - by davit-datuashvili
    I need make a merge sort using an additional array. Here is my code: public class extra_storage{ public static void main(String[]args) { int x[]=new int[]{12,9,4,99,120,1,3,10}; int a[]=new int[x.length]; mergesort(x,0,x.length-1,a); for (int i=0;i<x.length;i++){ System.out.println(x[i]); } } public static void mergesort(int x[],int low,int high, int a[]){ if (low>=high) { return; } int middle=(low+high)/2; mergesort(x,low,middle,a); mergesort(x,middle+1,high,a); int k; int lo=low; int h=high; for (k=low;k<high;k++) if ((lo<=middle ) && ((h>high)||(x[lo]<x[h]))){ a[k]=x[lo++]; } else { a[k]=x[h++]; } for (k=low;k<=high;k++){ x[k]=a[k]; } } } But something is wrong. When I run it the output is this: 1 0 3 0 4 0 9 0 What is the problem?

    Read the article

  • question about quicksort 3 way partition

    - by davit-datuashvili
    i want implement quicksort 3 way partition here is code public class quick3{ public static void quicksort3(int a[],int l,int r){ int k; int v=a[r]; if (r<=l) return; int i=l; int j=r; int p=l-1; int q=r; for (;;) { while (a[++i]<v); while (v<a[--j]) if (j==i) break; if (i>=j) break; swap( a,i, j); if (a[i]==v){ p++; swap(a,p,i);} if (v==a[j]){ q--; swap( a,q,j); } } swap(a,i,r); j=i-1; i=i+1; for (k=1;k<=p;k++,j--) swap(a,k,j); for (k=r-1;k>=q;k--,i++) swap(a,k,i); quicksort3(a,l,j); quicksort3(a,i,r); } public static void main(String[]args){ int a[]=new int[]{4,6,5,9,7,8,3}; quicksort3(a,0,a.length-1); for (int i=0;i<a.length;i++){ System.out.println(a[i]); } } public static void swap(int a[],int i,int j){ int t=a[i]; a[i]=a[j]; a[j]=t; } } after change result is 4 8 7 6 3 5 9 any suggestion?please help

    Read the article

  • merge three file into one big file

    - by davit-datuashvili
    suppose that we have three array int a[]=new int[]{4,6,8,9,11,12}; int b[]=new int[]{3,5,7,13,14}; int c[]=new int[]{1,2,15,16,17}; and we want to merge it into one big d array where d.length=a.length+b.length+c.length but we have memory problem it means that we must need use only this d array where we should merge these these three array of course we can use merge sort but can we use merge algorithm without sorting method? like two sorted array we can merge in one sorted array what about three or more array?

    Read the article

  • question on revrse 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

  • i have question about job

    - by davit-datuashvili
    hi i will explain my situation i am study algorithms and data structures and i know many thing practical and others most thoereticaly and trying to implement in practise i want to get job where i will study more quickly i am interested if i have chance to start job when i have not expierence? thanks please advise what to do

    Read the article

  • please help me to solve problem

    - by davit-datuashvili
    i have operation on heap fixdown operation below is code public class HEap{ public static void fixdown(int a[],int k,int n){ while(2*k<=n){ int j=2*k; if (j<n && a[j]<a[j+1]) j++; if (!(a[k]<a[j])) break; int t=a[k]; a[k]=a[j]; a[j]=k; k=j; } } public static void main(String[]args){ int a[]=new int[]{12,15,20,29,23,22,17,40,26,35,19,51}; fixdown(a,1,a.length); for (int i=0;i<a.length;i++){ System.out.println(a[i]); } } } //and result is 12 29 20 40 23 22 17 3 26 35 19 51 i am interested why is 3 in the list?in the array is not

    Read the article

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