Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Algorithms, Datastructures and syntax

by Anonymous Monk
on Apr 04, 2003 at 15:51 UTC ( [id://248105]=note: print w/replies, xml ) Need Help??


in reply to Algorithms, Datastructures and syntax

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.

:-)

  • Comment on Re: Algorithms, Datastructures and syntax

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://248105]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-20 02:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found