Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to complete this code for BWT for this assighment responsible to get data from P1 and compress the obtained data. The compression scheme

How to complete this code for BWT for this assighment

" responsible to get data from P1 and compress the obtained data. The compression scheme is called "Burrows-Wheeler Transform (BWT)"

this is the BWT not compleated I need to take the matrix on the random generator and do the BWT to it.

struct rotation { int index; char *suffix; };

int cmpfunc (const void *x, const void *y) { struct rotation *rx = (struct rotation *)x; struct rotation *ry = (struct rotation *)y; return strcmp(rx -> suffix, ry -> suffix); } int *computeSuffixArray(char *input_text, int len_text) { // Array of structures to store rotations and indexes struct rotation suff[len_text]; // Structure is needed to maintain old indexes of rotations after sorting them for(int i = 0; i < len_text; i++) { suff[i].index = i; suff[i].suffix = (input_text+i); } // Sorts rotations using comparison function qsort(suff, len_text, sizeof(struct rotation), cmpfunc); // Stores the indexes of sorted rotations int *suffix_arr = (int *) malloc (len_text * sizeof(int)); for (int i = 0; i < len_text; i++) suffix_arr[i] = suff[i].index; // Returns the computed suffix array return suffix_arr; } char *findLastChar(char *input_text, int *suffix_arr, int n) { // Iterates over the suffix array to find the last char of each cyclic rotation char *bwt_arr = (char *) malloc (n * sizeof(char)); int i; for (i = 0; i < n; i++) { // Computes the last char which is given by input_text[(suffix_arr[i] + n - 1) % n] int j = suffix_arr[i] - 1; if (j < 0) j = j + n; bwt_arr[i] = input_text[j]; } bwt_arr[i] = '\0'; // Returns the computed Burrows - Wheeler Transform return bwt_arr; }

and this is my P1

int *RandomDataGenerator(){ int x; static int fr[100];

srand((unsigned)time(NULL));

for(x=0;x<100;x++){ fr[x] = (int)rand()/RAND_MAX;

} return fr; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions