C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 1st, 2003, 11:10 PM
mbaysan16 mbaysan16 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Atlanta
Posts: 3 mbaysan16 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to mbaysan16
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.

Reply With Quote
  #2  
Old April 2nd, 2003, 02:29 AM
anbarasu anbarasu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: india
Posts: 42 anbarasu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
morse code

do u need the program which generates the morse code?

Reply With Quote
  #3  
Old April 2nd, 2003, 08:28 AM
mbaysan16 mbaysan16 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Atlanta
Posts: 3 mbaysan16 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to mbaysan16
yes but just a simple version of it.

Reply With Quote
  #4  
Old April 2nd, 2003, 09:59 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 4,297 dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 3 Days 17 h 31 m 43 sec
Reputation Power: 1013
Re: morse code

Quote:
Originally posted by mbaysan16
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.


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.

Reply With Quote
  #5  
Old April 2nd, 2003, 06:46 PM
Jason Doucette's Avatar
Jason Doucette Jason Doucette is offline
jasondoucette.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada
Posts: 378 Jason Doucette User rank is Private First Class (20 - 50 Reputation Level)Jason Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 h 23 m 8 sec
Reputation Power: 7
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?

Reply With Quote
  #6  
Old April 2nd, 2003, 08:24 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 4,297 dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 3 Days 17 h 31 m 43 sec
Reputation Power: 1013
Quote:
[i]Converting morse code back into ASCII would be a fun project... why didn't we do things like that in school? [/B]


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.

Reply With Quote
  #7  
Old April 3rd, 2003, 09:15 AM
Jason Doucette's Avatar
Jason Doucette Jason Doucette is offline
jasondoucette.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada
Posts: 378 Jason Doucette User rank is Private First Class (20 - 50 Reputation Level)Jason Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 h 23 m 8 sec
Reputation Power: 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.

Reply With Quote
  #8  
Old April 3rd, 2003, 10:21 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 4,297 dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 3 Days 17 h 31 m 43 sec
Reputation Power: 1013
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.

Reply With Quote
  #9  
Old April 3rd, 2003, 12:55 PM
Jason Doucette's Avatar
Jason Doucette Jason Doucette is offline
jasondoucette.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada
Posts: 378 Jason Doucette User rank is Private First Class (20 - 50 Reputation Level)Jason Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 h 23 m 8 sec
Reputation Power: 7
Quote:
Originally posted by dwise1_aol
Sometimes, genius is just looking at the same problem from a slightly different perspective.
Yes, you are quite correct. It's part of of having an open mind, I guess. What you said reminds of this 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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > morse code


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT