Search code examples
data-structures

Are files data structures?


I'm new to programming and I'd like to know if files such as BMPs, MP3s, EXEs are considered to be data structures as well.

I'm new to programming and I'd like to know if files such as BMPs, MP3s, EXEs are considered to be data structures as well.


Solution

  • No, they are some form of compressed(or not) data that should be read on any kind of program that can read them.

    But they are structured data. That means you have some specific way your program should read them. For example, in bmp you should know how to read its width and height of the image, then start reading its pixels. Then you continue looping it until its over.

    There is more complexes structured datas, as exe's, which your operating system reads, or mp3 which you have to execute some algorithms to make the data understandable

    Data structures are actually some default way to think about how to store and read your data and use them for specific situations, such as a command history.

    The well known command CTRL+Z, CTRL+SHIFT+Z, (undo & redo), they are implemented as stacks, which means each command is piled up one above the other, when undoing you will need to take the command that is topmost in the stack, pop it and execute its undo function.