Giter VIP home page Giter VIP logo

exercise_10's Introduction

Suffix Trees

Task 1

  • In R, implement a function SuffixArray() to create a suffix array from a string.

  • Input:

    • a DNAString
  • Output:

    • a vector of integers

Task 2

  • In R, implement a function InverseSuffixArray() to create an inverse suffix array from a suffix array.

  • Input:

    • a vector of integers representing suffix array
  • Output:

    • a vector of integers

Task 3

  • In R, implement a function LCPArray() according to pseudocode.

  • Input:

    • a DNAString representing analyzed string
    • a vector of integers representing a suffix array
    • a vector of integers representing an inverse suffix array
  • Output:

    • a vector of integers
LCPArray(text, SA, ISA)
1   LCP[1] <- -1
2   LCP[m + 1] <- -1
3   l <- 0
4   for i <- 1 to m
5     j <- ISA[i]
6     if j > 1 then
7       k <- SA[j - 1]
8       while text[k + l] = text[i + l] do
9         l <- l + 1
10      LCP[j] <- l
11      l <- max{l - 1, 0}
12  return LCP

Hint: The text will be indexed at m + 1 position, that does not exist. Add one character at the end of the text (in general use $, for DNAString in R use +).

Task 4

  • In R, implement a function BinarySearchSA() according to the following pseudocode.

  • Input:

    • a vector of integers representing a suffix array
    • a DNAString representing a pattern to be found
    • a DNAString representing a text to be searched
  • Output:

  • a vector of two integers (start and end indexes of suffix array, where the pattern was found)

BinarySearchSA(Pattern, Text, SuffixArray)
1   minIndex <- 1
2   maxIndex <- length (Text)
3   while minIndex < maxIndex
4     midlIndex <- floor(minIndex + maxIndex) / 2
5     if Pattern <= suffix of Text starting at position SuffixArray(midlIndex)
6       maxIndex <- midlIndex
7     else
8       minIndex <- midlIndex + 1
9   First <- minIndex
10  maxIndex <- length(Text)
11  while maxIndex > minIndex
12    midlIndex <- floor(minIndex + maxIndex) / 2
13    if suffix of Text starting at position SuffixArray(midlIndex) <= Pattern
14      minIndex <- midlIndex + 1
15    else
16      maxInd <- midlIndex
17  Last <- maxIndex - 1
18  if Last < First
19    return('Pattern does not appear in Text')
20  else
21    return First, Last
Download files from GitHub
Basic Git settings
  • Configure the Git editor
git config --global core.editor notepad
  • Configure your name and email address
git config --global user.name "Zuzana Nova"
git config --global user.email [email protected]
  • Check current settings
git config --global --list
  • Create a fork on your GitHub account. On the GitHub page of this repository find a Fork button in the upper right corner.

  • Clone forked repository from your GitHub page to your computer:

git clone <fork repository address>
  • In a local repository, set new remote for a project repository:
git remote add upstream https://github.com/mpa-prg/exercise_10.git

Send files to GitHub

Create a new commit and send new changes to your remote repository.

  • Add file to a new commit.
git add <file_name>
  • Create a new commit, enter commit message, save the file and close it.
git commit
  • Send a new commit to your GitHub repository.
git push origin main

exercise_10's People

Contributors

kjureckova avatar

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.