| there is a subroute foo which can take a list of strings, and a default string,
\- which then iterates all items in that list,
| \- and for each item in that list
| 1. appends the contents of that item to the end of the default string
| 2. removes all instances of the string "id" in that item
|
\ and returns a list, which contains
1. the concatentated default string
2. the modified input list
You may want to give an example. If your code focuses too much on language specifics that are not part of the algorithm, then Understandably, it could be said you had non-algorithm mixed with your algorithm, resulting in an incorrect result.
I Feel for the reasoning, the whole point of learning is to show you understand the concept, not to bend over and tick all the right boxes.
A computer can be taught to pass university, but a computer cant be yet taught to actually think for itself and apply knowledge.
Eat and regurgitate mentality is why I never graduated.
With respect to your recent comment, its important to realise pseudocode is undefined. There are generally reused terms in it, but its not a strict language any more than english is ( otherwise it would be a programming language, which could be parsed and executed verbatim )
The importance of pseudocode is to flesh out the logic part of the system and not have to worry overly about the syntax beyond 'it makes sense'
Often this can make the pseudocode both more terseand more understandable.
Pseudocode also doesn't rely on the reader having an understanding of the 'magic syntax' in the language in order to process it, all they need to understand is the terms used.
If you were to give the average person an algorithm in perl for example, most people would just die from horror because they don't see past the screeds of line noise.
may make some coherent sence to somebody versed in perl, to the average code reader all they get is a "what the hell did you just say" response. Documenting it doesn't help a lot either.
| there is a subroute foo which can take a list of strings, and a default string,
\- which then iterates all items in that list,
| \- and for each item in that list
| 1. appends the contents of that item to the end of the default string
| 2. removes all instances of the string "id" in that item
|
\ and returns a list, which contains
1. the concatentated default string
2. the modified input list
Suddenly it becomes less ambiguous and a greater percentage of peoples can understand it.
So possibly, half the exercise with writing the algorithm is an exercise in "Not only do you have to prove you understand it, you also have to prove you can explain your reasoning to others whom know nothing of the problem" , which is a vital ability you need. If you can't communicate what you have done, nobody can use it.
there's also this nasty little problem with code, that doesn't exist in an algorithm, and that is the code may look right, but may not do what you think it does, and if it doesn't do it right, and you don't realise, people reading the code reverse engineering it will foul it up and copy a broken algorithm. not good. the algorithm in human form better translates 'this is what i want it do do'
You need to supply more information. You were asked for an algorithm, but supplied code. Did you comment the code? How much? (I'd like to see the question and your answer, but perhaps that's requesting too much).
So I'll answer based on my own experience. If I'm asking for an algorithm, then I want something that explains, in decent english, how to solve the problem and/or meet the requirements of the question. Diagrams are also good (sometimes better). Paragraph, point form, whatever - it just needs to be clear, concise and correct.
If you supply me with code that does the above, then full marks. However, if you supply code that is pure "language" and rather cryptic, then marks will be lost - more or less depending on how cryptic the code actually is. Even with code, I'd like to see a diagram as well, just to show complete understanding of the concepts.
One of the hardest things I face when teaching programming is in getting students to write MORE, not less. Sometimes I have had to remind them that an assignment (or exam) is not an entry in the "most obfuscated code contest". ;-)
特别是在算法类中,提供正确性证明(无论是归纳法、反证法等)以及算法的空间和时间复杂度的大 O 表示法始终很重要。
As a grader for an advanced algorithms course, I would always take off points if there is simply a coded solution.
Some things simply cannot be expressed as eloquently in code as they can in English. Pseudo-code is an attempt to break free of strict compiler syntax and allow some expressiveness. It's a step in the right direction of understandability, but not always enough.
Especially in an algorithms class, it's always important to provide a proof of correctness (whether it be by induction, contradiction, etc.), as well as a big-O notation for the space- and time- complexity of your algorithm.
The problem with using code instead of pseudocode is that, theoretically speaking, one could assume that it was code, not pseudocode. Anyway, the teacher grades you for your response, not for your knowledge - you would be better off answering what you were asked for, in the terms the teacher likes. Yes, we all know, you know better. But it is never a bad exercise to try to reason another person's way, you know. And at least in my country the teacher has the right to evaluate you freely, so... get along with him!
Just talk to your professor and ask him why you got the question wrong. Ask him what a right answer would be, and what the fundamental difference is between the two.
Could it be that the algorithm you wrote wasn't correct?
Code is an algorithm written so that a machine may execute it. There's nothing in that definition that says it's not also written for a human to understand. Did writing in Java obscure your algorithm? That would determine whether I agreed with your teacher.
发布评论
评论(8)
你可能想举个例子。 如果您的代码过于关注不属于算法的语言细节,那么可以理解,可以说您将非算法与算法混合在一起,从而导致了错误的结果。
我觉得对于推理来说,学习的重点是让你理解这个概念,而不是弯腰勾选所有正确的方框。
可以教计算机通过大学,但还不能教计算机真正独立思考和应用知识。
吃和反胃的心态是我从未毕业的原因。
关于您最近的评论,重要的是要认识到伪代码未定义。 其中通常有重复使用的术语,但它并不比英语更严格的语言(否则它会是一种可以逐字解析和执行的编程语言)
重要性伪代码的strong>是充实系统的逻辑部分,而不必过度担心“它有意义”之外的语法,
通常这可以使伪代码更加简洁 em> 并且更容易理解。
伪代码也不依赖读者理解语言中的“神奇语法”来处理它,他们需要理解的只是所使用的术语。
例如,如果你给普通人一个 Perl 算法,大多数人都会吓死,因为他们看不到线路噪音。
虽然:
对于精通 Perl 的人来说可能会产生一些连贯的意义,但对于普通的代码阅读器来说,他们得到的只是“你刚刚说什么”的回应。 记录它也没有多大帮助。
突然之间,它变得不再那么模糊,更多的人能够理解它。
因此,编写算法的练习可能有一半是“你不仅要证明你理解它,你还必须证明你可以向其他不知道问题的人解释你的推理”,这是至关重要的你需要的能力。 如果你无法传达你所做的事情,那么没有人可以使用它。
代码中还存在一个令人讨厌的小问题,该问题在算法中不存在,即代码可能看起来正确,但可能不会按照您的想法做> 确实如此,如果它做得不对,而你没有意识到,阅读代码的人进行逆向工程,它就会弄乱它并复制一个损坏的算法。 不好。 人类形式的算法可以更好地翻译“这就是我想要它做的事情”
You may want to give an example. If your code focuses too much on language specifics that are not part of the algorithm, then Understandably, it could be said you had non-algorithm mixed with your algorithm, resulting in an incorrect result.
I Feel for the reasoning, the whole point of learning is to show you understand the concept, not to bend over and tick all the right boxes.
A computer can be taught to pass university, but a computer cant be yet taught to actually think for itself and apply knowledge.
Eat and regurgitate mentality is why I never graduated.
With respect to your recent comment, its important to realise pseudocode is undefined. There are generally reused terms in it, but its not a strict language any more than english is ( otherwise it would be a programming language, which could be parsed and executed verbatim )
The importance of pseudocode is to flesh out the logic part of the system and not have to worry overly about the syntax beyond 'it makes sense'
Often this can make the pseudocode both more terse and more understandable.
Pseudocode also doesn't rely on the reader having an understanding of the 'magic syntax' in the language in order to process it, all they need to understand is the terms used.
If you were to give the average person an algorithm in perl for example, most people would just die from horror because they don't see past the screeds of line noise.
While:
may make some coherent sence to somebody versed in perl, to the average code reader all they get is a "what the hell did you just say" response. Documenting it doesn't help a lot either.
Suddenly it becomes less ambiguous and a greater percentage of peoples can understand it.
So possibly, half the exercise with writing the algorithm is an exercise in "Not only do you have to prove you understand it, you also have to prove you can explain your reasoning to others whom know nothing of the problem" , which is a vital ability you need. If you can't communicate what you have done, nobody can use it.
there's also this nasty little problem with code, that doesn't exist in an algorithm, and that is the code may look right, but may not do what you think it does, and if it doesn't do it right, and you don't realise, people reading the code reverse engineering it will foul it up and copy a broken algorithm. not good. the algorithm in human form better translates 'this is what i want it do do'
在这种情况下,你必须服从教授。
In this case, you have to defer to the professor.
您需要提供更多信息。 系统要求您提供算法,但提供了代码。 你评论了代码吗? 多少? (我想看看这个问题和你的答案,但也许这要求太多了)。
那我就根据我自己的经历来回答一下吧。 如果我要求一个算法,那么我想要一些可以用体面的英语解释如何解决问题和/或满足问题要求的东西。 图表也很好(有时更好)。 段落、要点形式,无论什么——它只需要清晰、简洁和正确。
如果您向我提供执行上述操作的代码,则满分。 但是,如果您提供纯粹“语言”且相当神秘的代码,那么标记将会丢失 - 或多或少取决于代码实际的神秘程度。 即使有了代码,我也想看一个图表,只是为了展示对概念的完全理解。
在教授编程时,我面临的最困难的事情之一是让学生写更多,而不是更少。 有时我不得不提醒他们,作业(或考试)并不是“最混乱的代码竞赛”的参赛作品。 ;-)
干杯,
-R
You need to supply more information. You were asked for an algorithm, but supplied code. Did you comment the code? How much? (I'd like to see the question and your answer, but perhaps that's requesting too much).
So I'll answer based on my own experience. If I'm asking for an algorithm, then I want something that explains, in decent english, how to solve the problem and/or meet the requirements of the question. Diagrams are also good (sometimes better). Paragraph, point form, whatever - it just needs to be clear, concise and correct.
If you supply me with code that does the above, then full marks. However, if you supply code that is pure "language" and rather cryptic, then marks will be lost - more or less depending on how cryptic the code actually is. Even with code, I'd like to see a diagram as well, just to show complete understanding of the concepts.
One of the hardest things I face when teaching programming is in getting students to write MORE, not less. Sometimes I have had to remind them that an assignment (or exam) is not an entry in the "most obfuscated code contest". ;-)
Cheers,
-R
作为高级算法课程的评分者,如果只有一个编码解决方案,我总是会扣分。
有些事情根本无法像用英语那样用代码来表达。 伪代码是一种摆脱严格的编译器语法并允许一定表达能力的尝试。 这是朝着可理解性的正确方向迈出的一步,但还不够。
特别是在算法类中,提供正确性证明(无论是归纳法、反证法等)以及算法的空间和时间复杂度的大 O 表示法始终很重要。
As a grader for an advanced algorithms course, I would always take off points if there is simply a coded solution.
Some things simply cannot be expressed as eloquently in code as they can in English. Pseudo-code is an attempt to break free of strict compiler syntax and allow some expressiveness. It's a step in the right direction of understandability, but not always enough.
Especially in an algorithms class, it's always important to provide a proof of correctness (whether it be by induction, contradiction, etc.), as well as a big-O notation for the space- and time- complexity of your algorithm.
我所知道的是,在拥有算法之前,您不应该编写任何代码。
All I know is you shouldn't write any code until after you have an algorithim.
使用代码而不是伪代码的问题在于,从理论上讲,人们可以假设它是代码,而不是伪代码。 不管怎样,老师对你的评分是根据你的回答,而不是你的知识——你最好用老师喜欢的方式回答你所要求的内容。 是的,我们都知道,你更清楚。 但你知道,尝试以他人的方式推理从来都不是一个坏的练习。 而且至少在我国老师有自由评价你的权利,所以……和他相处吧!
The problem with using code instead of pseudocode is that, theoretically speaking, one could assume that it was code, not pseudocode. Anyway, the teacher grades you for your response, not for your knowledge - you would be better off answering what you were asked for, in the terms the teacher likes. Yes, we all know, you know better. But it is never a bad exercise to try to reason another person's way, you know. And at least in my country the teacher has the right to evaluate you freely, so... get along with him!
只需与您的教授交谈并询问他为什么您做错了问题。 问他正确的答案是什么,以及两者之间的根本区别是什么。
难道是你写的算法不正确?
Just talk to your professor and ask him why you got the question wrong. Ask him what a right answer would be, and what the fundamental difference is between the two.
Could it be that the algorithm you wrote wasn't correct?
代码是一种编写的算法,以便机器可以执行它。 该定义中没有任何内容表明它不是为人类理解而编写的。 用 Java 编写是否会掩盖您的算法? 这将决定我是否同意你老师的观点。
Code is an algorithm written so that a machine may execute it. There's nothing in that definition that says it's not also written for a human to understand. Did writing in Java obscure your algorithm? That would determine whether I agreed with your teacher.