473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Hirschberg algorithm

21
somebody have a tried/implemented Hirschberg Algorithm to c#?
i need it :(

to make the program compare the two string and tell where the array index that the different,

thx u
Apr 28 '10 #1
17 6367
jkmyoung
2,057 Expert 2GB
To be honest, based on your earlier posts I would try to understand recursion and tree searches first.


1. One way to look at it: The algorithm is like a tree search except that many of the branches are shared.

2. The algorthim provided is also like filling in a grid, and then finding the best path to the goal.

Figure out how to fill a single cell.
Then figure out how to fill the cell next to it.
Then do that over and over in for loops.
Apr 28 '10 #3
abz89
21
@ChBinder
it can't be downloaded >.<

@jkmyoung
oh dear i've create the programs with needleman-wutsch but it takes so much memory :(

and i've found the hirschberg algo. but i didn't understand the algo :(
Apr 29 '10 #4
Christian Binder
218 Expert 100+
@abz89
It can be downloaded!
You've to choose "Source Code"-Menu, not "Download" then click on "3546"-Link and there you'll find the files and a complete download :-)
Apr 29 '10 #5
abz89
21
owh yes.. :D
but the source cannot be tested (run) :(

i'm using vc# 2008 express,, hwa
Apr 29 '10 #6
Christian Binder
218 Expert 100+
What happens when you want to run it? Any messages?
Does even compiling doesn't work?

The program expects to be started with command-line-parameters and any file given. I didn't try this program, I just looked a bit through the There are some test-methods inside it which you can maybe use.
Apr 29 '10 #7
jkmyoung
2,057 Expert 2GB
You can simplify the space requirements by only storing 2 columns at a time.
Calculate the last column, starting from the bottom. ArrayA

loop{
based on ArrayA calculate the column before, starting from the bottom. ArrayB.
Set ArrayA = ArrayB.
}
Apr 29 '10 #8
abz89
21
@chbinder
yupz, it said some missing object etc...bla bla bla

@jkmyoung
i couldn't understand what you mean, (cause i'm so dumb --_--)

after i've googling, i found the more nice and faster algorithm,
"lazy DPA"

i think,
- needleman or other standard dpa is taking memory and times too much
- hirchberg is fine, but it ate so much time, cause it does double checking

i've been ported the hirchberg to c#, but it cannot processing arrays too long (in my case up to 16k), it said boundary issue or not enough memory resources :(

so i prefer to "lazy dpa",

have somebody tried on c sharp? some source tell that c sharp is slowest when benchmarked with the other languages, such as python, perl, even c++..

i wanna porting the applet (lazy dpa) like this site.
http://drp.id.au/align/2d/AlignDemo.shtml

any help or suggest is so appreciated :)
May 14 '10 #9
jkmyoung
2,057 Expert 2GB
Regarding space:
Notice how the demo only calculates one row at a time?
Each row is only dependent on itself and the row above.
Eg, once you've calculated row 4, you can throw away the results from row 3. You don't need row 3 to get the results for row 5.

A lazy Hirschberg algorithm is the same except it goes backwards, from the bottom to the top, then right to left.
May 14 '10 #10
abz89
21
@jkmyoung

yupz, hirschberg is only calculated the single row and above ones then immedietly flushing the memory with throw the other unnecessary datas..
but it taking two times longer, cause the traceback check will missed the data (which trown before)

sorry that i mistaked, i've been ported the needleman into c sharp..
but it takes error when i use it cause my array data is 16thousand char long,

it said array outbound of index and sometime memory resources issue.

so i need the optimization on needleman, maybe add a pause time?? how can i do that?

if the optimization on needleman not succesed, i'll try hirschberg :)

thx a lot
May 14 '10 #11
jkmyoung
2,057 Expert 2GB
If you're getting an out of bounds errors, there's probably a small mistake in how you've implemented it. It's hard to tell without seeing the relevant code.

Make sure you're aligning the two strings so that you only need to store only as many cells equal to the shortest string's length..
May 17 '10 #12
abz89
21
hmm, here is my codes..

hope u could notify me the error :D
thx a lot
May 18 '10 #13
jkmyoung
2,057 Expert 2GB
1. Optimization: convertStringToArr
You create a list, and then you copy the list into a int[] array. Why not create the int[] array to begin with?

l.Count equals str.Length
====
2. Error
for(int y=0;y<source.Length;y++)
for(int x=0;x<dest.Length;x++)

These should both be <=
=====
3. Optimization.
You call NeedlemanWunsch.convertStringToArr(s1) twice for each string. Call it once each string, and store the variable.
May 18 '10 #14
abz89
21
<quote>
1. Optimization: convertStringToArr
You create a list, and then you copy the list into a int[] array. Why not create the int[] array to begin with?
</quote>

hmm, i will make the GUI for this program with string1 and string2 input fron text box, so i designed it is like this...

<quote>2. Error
for(int y=0;y<source.Length;y++)
for(int x=0;x<dest.Length;x++)

These should both be <=
<quote>

did you mean:

for(int y=0;y<=source.Length;y++)
for(int x=0;x<=dest.Length;x++)

ok..


hi bos, could you fix my codes directly :)
so i can make sure that codes is more efficient and i can learn it

i'm so appreciated with your help :D
thx a lot
May 18 '10 #15
jkmyoung
2,057 Expert 2GB
Regarding 1.
What I meant is: create the string, that's fine. Don't create the List. In your first for loop set the values of the int array.

--
Unfortunately don't have the time to fix every poster's code, and it would be counter-productive of you to rely on a volunteer service that could disappear any time due to heavy work load on the volunteer's side. If you didn't understand the code at that point, you'd be screwed.
May 18 '10 #16
abz89
21
okay, i'll try it..

thx.. :D
May 19 '10 #17
abz89
21
i've pre-finished my program with hirscberg :D
thx for everyone ;)

to mod;please lock this thread, if you would..
May 30 '10 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jack Smith | last post by:
Hello, any help appreciated with following problem. I figured out the algorithm (I think), just having trouble proving it is optimal. Suppose we are given n tasks each of which takes 1 unit...
16
by: cody | last post by:
I have to write an algorithm with must ensure that objects are put in buckets (which are always 4 in size). The objects have two properties: A and B. It is not allowed that in a bucket are objects...
10
by: bpontius | last post by:
The GES Algorithm A Surprisingly Simple Algorithm for Parallel Pattern Matching "Partially because the best algorithms presented in the literature are difficult to understand and to implement,...
32
by: Cmorriskuerten | last post by:
HI, is this is this solution to test if a number is a prime number or not: /* * Is n a prime number? * Return TRUE (1): n is a prime number * Return FALSE (0): n is a *not* a prime number...
2
by: ben | last post by:
hello, i'm following an algorithm book and am stuck on an early excersise in it, not because of the c programming side of it or even the algorithm side of it, i don't think, but because of maths....
113
by: Bonj | last post by:
I was in need of an encryption algorithm to the following requirements: 1) Must be capable of encrypting strings to a byte array, and decyrpting back again to the same string 2) Must have the same...
4
by: FBM | last post by:
Hi, I am working on a program that simulates one of the elements of ATM. The simulation stores events which occurs every some milliseconds for a certain amount of time. Every time that an event...
2
by: Julio C. Hernandez Castro | last post by:
Dear all, We have just developped a new block cipher called Raiden, following a Feistel Network structure by means of genetic programming. Our intention now consists on getting as much feedback...
0
by: aruna | last post by:
hey guys i earlier had very valuable responses from you all for base64 encoding algorithm.so thank for that. so now i need your assistance to do a float encoding algorithm. you may wonder why i'm...
1
by: almurph | last post by:
Hi everyone, Concerning the Needleman-Wunsch algorithm (cf. http://en.wikipedia.org/wiki/Needleman-Wunsch_algorithm) I have noticed a possible loop. Inside the algorithm there is an...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.