Giter VIP home page Giter VIP logo

comp9319_bwt's Introduction

README

encode

Firstyly, I read the original file and store it in a char array and change all the delimiter to the char 0, so that when I sort the sentence, the delimiter has the highest priority. Then, according to the frequency of each character, I split the file into three small temporary files and after sorting these three files, I can merge them directly without comparation.

The sort function I used is qsort() in c library which has been optimised and has a good performance. The only problem is that when I pass the arguments to qsort() , it would automatically make a copy of the arguments, which would consume a large amount of memory and this is why I split into three files rather than two. Sort is according to the lexicographic order and the only different is when I compare two delimiters, the former one is smaller(eg. The delimiter of the first sentence is smaller than the second one).

The sorted file is the Suffix array so I need to miners one for each position index and the result would be the BWT result for the original file.

I also keep a position file for searching. The content is the original sentence sequency of the delimiter in BWT result.

search

The first two steps before doing search is make the frequency table and occurrence table.

The frequency table can be built by visiting BWT file once and count the frequency of each characters.

For the occurrence table, I store it in searching temporary file for every 1000 characters. When I need the occurrence number of one character, I just need to get the result from temporary file and count the number from the left result.

For -m, according to the backward-search algorithm, the Last - First + 1 would be the final result.

For -n, -a, I need to continue backward-search until reaching the delimiter. According to the position file created in encoding, I can know this delimiter is the result of witch sentence and store the result in a integer array.

For -n, the result is the number of non-duplicate number in this integer array.

For -a, I just need to print all the non-duplicate number in increasing order.

For -i, because the sequence of BWT result is same as the sequence of original sentence, I just need to do the backward-search according the arguments and output the result in reverse order.

comp9319_bwt's People

Contributors

giraffe0313 avatar

Watchers

 avatar

Forkers

keithwzx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.