Why are Algorithms and Data Structures considered separate disciplines?

This question was the last straw; and I thought about it for a long time,

Why do people think of “algorithms” and “data structures” as something that can be separated from each other?

I see a lot of evidence that they are shared in the minds of programmers.

  • they request "Data Structures and Algorithms."
  • they refer to Data Structures and Algorithms as separate university courses.
  • they "know the algorithms" but are "weak in data structures" (cannot find the link, sorry).
  • and etc.

In my opinion, “Data Structures” are algorithms, since the concept of “Data Structure” refers to algorithms for managing data that enter and from a structure. But the opinion does not seem basic. What am I missing?

Edit : Unfortunately, I have a poorly worded question. The separation of data structures and algorithms in programs that people write is natural, because, well, the former are data, and the latter are functions (and in semi-functional structures such as STL, the core of all this).

But the above points and the question itself relate to how people think, to how they arrange knowledge in their heads. This should not even apply to coding.


Here are some links where people separate “algorithms” and “data structures” when they are the same:

  • Changes: algorithm and data structure
+6
algorithm data-structures
source share
9 answers

They are different. Consider more graphs or trees. Now the tree seems only a tree. But you can view it in preliminary order, in order or according to a schedule (3 algorithms for one structure).

You can have several or only 2 children per node. The tree can be balanced (for example, AVL) or contain additional information (for example, B-tree indexes in databases). These are different structures. But still you go through them on the same algorithm.

Have a look now?

Another point: Algorithms sometimes happen and sometimes do not depend on data structures. Some algorithms have different complexity over various structures (search for paths in a graph presented as a list or a 2D table).

+11
source share

People refer to them as different entities, because they are. Suppose I want to find an item from a dataset. If I put this data in an array, the array will be a data structure. After that, I can use several different algorithms in the array to find the element that interests me. I could sort the array (with any of several types), then use binary search, I could just check each element linearly, etc. Selecting an array as a data structure that I would use, unlike, for example, a linked list, does not select an algorithm.

However, it is important to understand one in order to understand the other. If you are not well versed in algorithms, then it is not obvious what advantages and disadvantages different data structures have, and vice versa. Thus, it makes sense to teach them at the same time. They, however, are different entities.

[Edit] Think about it: if you look at the pseudo-code for most algorithms, the data structure is not specified. You may have a “list” of elements to iterate through, etc., but the exact implementation of this list does not matter for the correctness of the algorithm.

+2
source share

Algorithms and data structures are tightly twisted. The algorithm depends on the data structure, if you change any of them, the complexity will change significantly. They are not the same, but definitely two sides of the same coin. Choosing a good data structure is the way to a better algorithm.

For example , Priority queues can be implemented using binary heaps and binomial heaps, binary heaps allow you to peek at the highest priority element at a constant time, while binomial heaps require O (log N) time to peep.

Thus, a particular algorithm works best for this particular data structure (in a specific context), so Algorithms and Data Structures go hand in hand!

+2
source share

I would say because functional programming separates what works from the operations themselves. The goals and actions are certainly different, even if they are closely intertwined.

It was an object-oriented programming that put data and operations in one component. Perhaps if the OO arrived earlier, there would be one discipline.

+1
source share

I see that algorithms are something that works with or on data structures, so there is a difference between them. A simple data structure is an array, but there are many algorithms that work on simple arrays, so there must be a way to separate the two. An array can also represent a tree, and trees are processed by specialized algorithms.

The difference is small because you cannot have it without others in most cases, but sometimes you can. Consider a trivial algorithm that determines whether a number is prime - it does not use data structures. Consider the GCD algorithm, and there are also no data structures. You can talk about an algorithm without talking about data structures, but you can't talk about a data structure without talking about algorithms. You can talk about the tree, but you will need algorithms to insert, delete, etc.

I think it’s good that there is a difference, because they are, conceptually, different things. An algorithm is a set of steps used to complete a task, and a data structure is something that is used to store data; data is manipulated using algorithms.

+1
source share

These are separate university courses. Typically, a course in data structures emphasizes programming and is a prerequisite for a course in algorithms that emphasizes mathematical analysis of algorithms. I don’t think it’s hard to understand why many people with a university degree in CS can consider them separate.

+1
source share

I agree with you. Both are two sides of the same.

Speaking of data structures, it always stores data in such a way as to optimize certain operations on this data, which leads us to algorithms and complexity.

0
source share

The two, of course, are closely intertwined. This is why the posts you link to request books for both. Not always. The core of the sorting algorithm, for example, does not change no matter what data structure you work in.

0
source share

The title of the book is Algorithm + Data Structures = Programs (1975) by none other than Niklaus Wirth suggests that both are necessary when writing a program.

0
source share

All Articles