W
W
WebDev2021-02-24 11:00:46
Data Structures
WebDev, 2021-02-24 11:00:46

Who uses binary trees and other data structures and when?

Hello. There are different data structures (linked lists, trees, hash tables) and different algorithms (quick sort, heap sort, etc.). I am a php + js developer and do not use them, but as I understand it, the language is based on all these data structures and algorithms. For example, the sort function internally uses some sort of algorithm, and arrays are actually hash tables.
Is there any programming language or area where you need to build a binary tree yourself or write a search script in an array, or is this knowledge needed only for academic purposes in order to understand how everything works?
All the programming languages ​​I know already have built-in functions for this. Even "low-level" C has a qsort function.
Thank you.

Answer the question

In order to leave comments, you need to log in

7 answer(s)
W
Wataru, 2021-02-24
@kirill-93

Sometimes you may need something not quite standard. For example, the ability to quickly insert an element at the kth place in the structure and find what lies at the kth position. This is done by an implicit key tree, but in my opinion no language provides a standard structure for this.

1
12rbah, 2021-02-24
@12rbah

Is there any programming language or area where you need to build a binary tree yourself or write a search script in an array, or is this knowledge needed only for academic purposes in order to understand how everything works?

It does not depend on the programming language, because all this is usually implemented by standard means, an attempt to write your own implementations threatens with the presence of errors in them. Their implementations are usually written for a specific task, for example, an ast tree is popular for writing parsers, https://habr.com/ru/company/mailru/blog/323242/ here is a self-written implementation of hash tables.

K
KoreanGuy, 2021-02-24
@KoreanGuy

from personal examples: in a game of the Line Tower Defense genre with a field of hexagons, it was necessary to implement pathfinding. Unity's standard mechanism was clearly overkill, so I manually wrote a simple algorithm that used a graph. The second example is literally a week old: having a set of 11 players and knowing what positions they prefer, determine the most probable arrangement on the field so that you can draw in the UI. Implemented through trees. And linked lists are generally used everywhere.

V
Vladimir Kuts, 2021-02-24
@fox_12

assembler

V
Vasily Bannikov, 2021-02-24
@vabka

I'm a php+js developer and don't use them

It just seems this way to you. In fact, a regular js object is a hash table. Well, associative arrays in php too.
I'm a php+js developer and don't use them

Here's to such nonsense and you need to know about them.
Is there any programming language or area where you need to build a binary tree yourself or write a search script in an array, or is this knowledge needed only for academic purposes in order to understand how everything works?

In principle, any, if the standard implementation is not suitable.

S
Saboteur, 2021-02-24
@saboteur_kiev

Is there any programming language or area where you need to build a binary tree yourself or write a search script in an array

Assembler, C (not C++)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question