9 replies to this topic
#1
Posted 30 May 2011 - 09:06 AM
Ok, im completly confused with this algorithm.
I have an algorithm which adds together the numeric values of the first three letters from array with 15 names. How i can find, how long does the storage array need to be?
I have an algorithm which adds together the numeric values of the first three letters from array with 15 names. How i can find, how long does the storage array need to be?
"Programming is like sex. One mistake and you have to support it for the rest of your life."
-Michael Sinz|
|
|
#2
Posted 30 May 2011 - 10:10 AM
Without seeing or better explaining the algorithm it's hard to tell.
Out of your current text I deduct that you transform an array of names into a number...
Out of your current text I deduct that you transform an array of names into a number...
#3
Posted 30 May 2011 - 10:35 AM
I have an array of 15 names
First create an index array whose elements refer to the position in my array of the first key which starts with a given letter.
Then create another array which holds pointers to chains holding keys for the different initial letters.
And now i have to improve the previous method by converting the key to an index using hashing function (adds together first 3 letters)
I have to find how long does the new storage array need to be
Arthur Barry Francis...
First create an index array whose elements refer to the position in my array of the first key which starts with a given letter.
Then create another array which holds pointers to chains holding keys for the different initial letters.
And now i have to improve the previous method by converting the key to an index using hashing function (adds together first 3 letters)
I have to find how long does the new storage array need to be
"Programming is like sex. One mistake and you have to support it for the rest of your life."
-Michael Sinz
#4
Posted 30 May 2011 - 10:39 AM
Quote
First create an index array whose elements refer to the position in my array of the first key which starts with a given letter.
Then create another array which holds pointers to chains holding keys for the different initial letters.
And now i have to improve the previous method by converting the key to an index using hashing function (adds together first 3 letters)
I have to find how long does the new storage array need to be
Then create another array which holds pointers to chains holding keys for the different initial letters.
And now i have to improve the previous method by converting the key to an index using hashing function (adds together first 3 letters)
I have to find how long does the new storage array need to be
#5
Posted 30 May 2011 - 10:54 AM
Ok lets try again :P
At the beggining i have a simple array with 15 names(Arthur, Barry, Francis, Garry...)
Then using an index array that its element points to the first name of each first letter (ex. if i have Harry and Henry, index's array element will point only on Harry) So index array will have elements like (0,3,-1,-1,5...) where -1 is when names array doesnt has name which starting with that letter.
So..we can say
IndexArr[0]->A
IndexArr[1]->B
IndexArr[2]->C etc..
Now i have to use the hashing algorithm to improve the efficiency of method above. Each key converted to an index using a hashing function, which adds the numeric values of the first three letters.
At the beggining i have a simple array with 15 names(Arthur, Barry, Francis, Garry...)
Then using an index array that its element points to the first name of each first letter (ex. if i have Harry and Henry, index's array element will point only on Harry) So index array will have elements like (0,3,-1,-1,5...) where -1 is when names array doesnt has name which starting with that letter.
So..we can say
IndexArr[0]->A
IndexArr[1]->B
IndexArr[2]->C etc..
Now i have to use the hashing algorithm to improve the efficiency of method above. Each key converted to an index using a hashing function, which adds the numeric values of the first three letters.
"Programming is like sex. One mistake and you have to support it for the rest of your life."
-Michael Sinz
#6
Posted 30 May 2011 - 11:02 AM
Okay assume 4 names only
Names array = {"dalc", "aalc", "balc", "calc"}
Index array = {1, 2, 3, 0, -1, -1, ...}
And now instead of doing it with 1 letter you wanna have 3?
So
IndexArr[0] -> AAA
IndexArr[1] -> AAB
IndexArr[2] -> AAC
....
And you need to know the total size of indexArr?
Names array = {"dalc", "aalc", "balc", "calc"}
Index array = {1, 2, 3, 0, -1, -1, ...}
And now instead of doing it with 1 letter you wanna have 3?
So
IndexArr[0] -> AAA
IndexArr[1] -> AAB
IndexArr[2] -> AAC
....
And you need to know the total size of indexArr?
#7
Posted 30 May 2011 - 11:06 AM
Names are in alphabetic row
Names array = {"aalc", "balc", "calc", "dalc"}
Index array = {0, 1, 2, 3, -1, -1, ...}
And are the three first letters each name (aal, bal, cal, dal)
Yes, asking the total size. Im really confused with hashing algorithm, so may be the way i understant it to be wrong
Names array = {"aalc", "balc", "calc", "dalc"}
Index array = {0, 1, 2, 3, -1, -1, ...}
And are the three first letters each name (aal, bal, cal, dal)
Yes, asking the total size. Im really confused with hashing algorithm, so may be the way i understant it to be wrong
"Programming is like sex. One mistake and you have to support it for the rest of your life."
-Michael Sinz
#9
Posted 02 June 2011 - 01:13 PM
Ok, i will try one more time. To store the first letter from a word, i need an array of size 26, now to store the first three letters from a word, what the size of the array will be using a simple hashing function?
"Programming is like sex. One mistake and you have to support it for the rest of your life."
-Michael Sinz
#10
Posted 05 June 2011 - 12:52 AM
So you need to create an array of
I think that's just 26³
AAA AAB AAC AAD ... DEA DEB DEC ... ZZZAnd you just need to know the total size of that?
I think that's just 26³
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









