开发者

algorithm || method to write prog

开发者 https://www.devze.com 2023-02-02 14:02 出处:网络
I am one of the computer science student. Everyone solve problem with a different or same method, ( but actually I dont know whether they usemethod or I dont know whether there are such common method

I am one of the computer science student. Everyone solve problem with a different or same method, ( but actually I dont know whether they use method or I dont know whether there are such common method to approach problem.)

  • if there are common method, What is it ?
  • If there are different method, which method are you using ?

All teacher give us problem which in simple form sometimes, but they donot introduce any approach or method(s) so that we cannot make a decision to choose the method then apply that one to problem , afterward find solution then write code.No help from teacher , push us to find method to solve homework. Ex: my friend is using no method , he says "I start to construct algorithm while I try to write prog."

I have found one method when I failed the course,

More accurately, my method: When I counter problem in language , I will get more paper and then ;

first, input/ output  step ; 
       my prog will take this / these there argument(s) and return namely X , 
       ex : in c, 
            input length is not known and at same type ,
                so I must use pointer 
            desired output is in form of package , 
                so use structure 
second, execution part    ;
   in that step , I am writing all step which are goes to final output 
       ex : in python ;
             1.) [ + , [- , 4 , [ * , 1 , 2 ]], 5]
             2.) [ + , [- , 4 , 2 ],5 ]
             3.) [ + , 2 , 5] 
             4.)  7      ==> return 7 
third, I will write test code 
       ex :    in c++
           input : append 3  4 5 6 vector_x remove 0 1 
           desired output  vector_x holds : 5 6       
  • now, my other question is ; What is/are other method(s) which have/has been;

     used to construct class  :::: for  c++开发者_JAVA技巧 , python, java  
    
    
     used to communicate classes / computers
    
    
     used for solving  embedded system problem  ::::: for c 
    

by other user?

  • Some programmer uses generalized method without considering prog-language(java , perl .. ), what is this method ?

Why I wonder , because I learn if you dont costruct algorithm on paper, you may achieve your goal. Like no money no lunch , I can say no algorithm no prog

therefore , feel free when you write your own method , a way which is introduced by someone else but you are using and you find it is so efficient


A computer scientist is often confronted with a large problem, one that is largely abstract in nature. However, computers take only small instructions: add these numbers, subtract these numbers. Computing has not yet reached the point where we can simply say, "Computer, solve this problem." - we must phrase the problem as a series of small instructions that the computer can understand.

Compare this to a chef in a kitchen. If he is writing a cookbook, he cannot simply say "John's Special Chili" - he must write down what ingredients are used, what procedure is used to cook or prepare the various ingredients, what quantities to use, etc.

Likewise, a computer scientist must take an abstract problem, and break it down into instructions that a machine can use to arrive at the correct output, given an input of the problem. This act of breaking a larger problem, often down into smaller problems before finally arriving at code, is a fundamental skill for any programmer, and quite possibly the hardest skill to teach, as it relies on the problem-solving abilities of an individual.

Algorithms are essentially the result of solving a problem: an algorithm, as defined by Wiktionary, is "A precise step-by-step plan for a computational procedure that begins with an input value and yields an output value in a finite number of steps." It's the method by which you go from an input to an output, and it's typically what programmers must figure out. Some problems are of course already solved: sorting, being an example typically given to early students, has a known algorithm: typically you're just implementing this in a particular language.

Once the basics have been passed, often the problem is unique. It is then up to the programmer to work out the algorithm. Common advice given is to "break the problem down into smaller, easier to solve sub-problems" - often two (or more) smaller problems are equivalent to your larger problem. If we wanted to solve the problem of "flip a image file upside down", I might break it into:

  1. Load the image
  2. Flip the rows of pixels in the image
  3. Write the resulting image back into a file

Each of those are still very abstract, and would need to be fleshed out further, but the idea is the same: keep breaking it apart, until the idea is simple enough to translate into code. Depending on what language you're using, the human form of the problem will translate differently. I would not write the same code in C or C++ as I would in Python, or Java, etc.

(PS: The question is difficult to understand, so if this doesn't answer what you're asking, or if something in it is unclear, please comment as such.)

0

精彩评论

暂无评论...
验证码 换一张
取 消