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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.