Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Data
Information. Integer, string, possibly code even.
Data Structure
Data organised in a specific way. In abstract any data that is not simply bits. An integer for instance is a datastructure, insofar as negative numbers are encode in a particular way. Normally however the term is not used unless the data contains pointers to other objects, or and especially copies of itself. Many have names: linked list, queue, stack, etc.
Algortihm
Algorithms are processes for achieving a goal. When you do divide and conquor to "guess" the right number between 0 and 100 you are doing an algorithm. When the computer converts an integer stored in binary into a decimal for you to read it is performing an algorthm.
Algortihm + Data Structure = Computer Program
Normally datastructures and algorithms are pretty intimately related. Certain algorithms need their data organized in certain ways. In other situations an algorithm doesnt care. So long as it can interact with the data in a particular way it doesnt worry. For instance many algorithms use heaps. Heaps in themselves can be implemented many ways, using different data structures and algorithms to implement them. So the algorithm _implementing_ a heap cares how its data is organized, but an algorithm _employing_ a heap doesnt care how the heaps data is organized.

I dont really see what your friend means about a for loop in assembler being a data structure. A for loop in assembler (depending on what this means...) is only a handlful of ops and would probably employ a register as its "data-structure".

The only possible idea I have about your freinds point is that sometimes one wishes to treat code as data. And then you could have an algorithm which operates on that data (which is really code) Consider a compiler, it may indeed wish to treat a for loop as data, and modify it in a particular way. Until the code gets executed its still data. And maybe even later.

In a tongue-in-cheek way of thinking about it you could say that the algorithm part of a program is every instruction the cpu executes, and the data is everything else. This overlooks the difference between an algorithm and a heuristic, and when code is data and data is code, but whatever.

:-)


In reply to Re: Algorithms, Datastructures and syntax by Anonymous Monk
in thread Algorithms, Datastructures and syntax by BUU

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-23 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found