|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
morse code
thanks for helpss. the thing is I just cant cheat because this is a homework for a class, and prof. clearly told that we should do it by using a function and arrays. So if you please explain it in details I would appriceate it.
|
|
#2
|
|||
|
|||
|
morse code
do u need the program which generates the morse code?
|
|
#3
|
|||
|
|||
|
yes but just a simple version of it.
|
|
#4
|
||||
|
||||
|
Re: morse code
Quote:
Just because the link that was provided includes source code shouldn't mean that you cannot research it for ideas -- just so long as the code you end up writing is your own. Giving it due credit in the comments would be a nice idea. I don't think that would constitute cheating any more than posting here for help. Without having looked at that code, here are a few ideas that occur to me off the top of my head: 1. Store the codes in an array. 2. The codes are of varying lengths (eg, e = '.', a = '.-', s = '...'), so the data type for the codes needs to handle varying lengths, like strings. 3. The ASCII code of the letter you are converting to morse will be used to index into the array. However, you must avoid empty entries in the array (eg, it cannot be a simple morse['A'] to get the code for 'A'). You will need to translate from the ASCII code to the corresponding index for the array. Also, you will need to handle mixed case; the ASCII code for an 'A' is different than for an 'a'. 4. The function could either be the letter-to-index translation or, better, one that you pass the letter to and it returns the morse code. That should be more than enough to get you started. Of course, if you ever need to go from Morse back to ASCII, that would be a much more fun project. But definitely more advanced. Last edited by dwise1_aol : April 2nd, 2003 at 10:03 AM. |
|
#5
|
||||
|
||||
|
Just a note: You should continue replying in the original thread so that others know what you are speaking about who have not read it, yet.
Converting morse code back into ASCII would be a fun project... why didn't we do things like that in school? ![]()
__________________
Jason Doucette / Xona.com™ - Programming Windows Errata Addendum "Discussion is an exchange of knowledge; argument is an exchange of ignorance." |
|
#6
|
||||
|
||||
|
Quote:
Actually we did, in a way. Upper division class on data communications back in 1981. Our programming assignments merged into a project which accepted an input text file, generated a Huffmann-code for it, Huffmann-encoded it into a bit stream, then decoded it back to the original text. We called it "Huff 'n Puff". Basically, Huffmann encoding is a simple form of data compression that uses character frequency to assign shorter bit strings for more frequent characters and the longer strings for the less frequent. Our instructor pointed out that Morse code does pretty much the same thing. A few years later, I read that Huffmann was an undergraduate student when he came up with it. His instructor presented to the class this problem he'd been working on and Huffmann came up with the approach that had been eluding the instructor. We learn from our students! The approach we were taught was to construct a binary tree and then start combining the nodes with the lower frequencies -- ie, connect them with an intermediate node whose frequency value is the sum of the nodes in its subtree. At first, we were to write a program to construct the tree, but too many students were having trouble with it so the instructor just had us do it by hand. Too late, I'd already written the program. I'll have to try to dig it out one of these days. Anyway, to decode, you read each bit coming in and use it to traverse down the tree. When you read a terminal node, print out that character, go back to the root of the tree, and continue on with the next input bit. I figure that a Morse code reader would be similar, except I think there are pauses between characters. Also, the code is already written, so you wouldn't have to generate the code. Last edited by dwise1_aol : April 2nd, 2003 at 08:28 PM. |
|
#7
|
||||
|
||||
|
Yes, I did a bit of research on the Huffmann encoding algorithm. It is commonly used to compress chess positions to store in transpositional tables. I was looking to implement this into my small chess engine project for school, but I simply ran out of time. It still bothers me that I did not get this implemented, but I just have no time to mess with that stuff right now due to current (more important) projects. Huffman must have been quite an intelligent guy. I do not know why schools deter students from answering questions in their own way - I know that almost every class I took in school did so by marking questions incorrectly if they were not answered 'by the book'. I guess they do not realize that at some point in the past a 'student' wrote that book, and perhaps his method isn't the best way.
|
|
#8
|
||||
|
||||
|
I tend to suspect that the "by the book" instructors tend to be the ones who only know a bit more than the students do (not necessarily a bad thing -- when you are just starting out in a new subject, like foreign language and dancing, a teacher who still remembers being a beginner can be a lot better than one who knows it thoroughly and naturally) and therefore must depend on the book more.
In Huffmann's case, the problem was one that the professor himself had been working on and was stumped. The professor kept wanting to start building the tree using he most frequent characters. Huffmann just took the opposite approach and started with the least frequent. Sometimes, genius is just looking at the same problem from a slightly different perspective. |
|
#9
|
||||
|
||||
|
Quote:
"Open your mind up to things that have no connection with the problem you're trying to solve: subscribe to an unusual magazine; spend a morning at an elementary school; go to work two hours early; test drive an exotic car; attend a city council meeting; ...try an Indonesian recipe." - Roger von Oech |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > morse code |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|