Data Structure With JavaScript

In real life, we have containers for food (refrigerator), files (folders/file cabinets), toys (packing boxes), or clothes (cupboard). Each container is specific for a thing. We will not put files in packing boxes as they will crumble. It is a way for us to organize our things so we can go back and retrieve them easily.
Similarly, we put data in data structures and retrieve them from the data structures — that is all it is.
Just like in real life, there are tons of data structures in programming as well.
Introduction to Data Structure
A data structure is a collection of values, these values can have relationships among them and they can have functions applied to them.
Each one is different in what it can do and what it is best used for.
A person who knows how data structures and algorithms work and how to use them can write great programs.
Data Structure + Algorithms = Programs
These are timeless. No matter what programming language you use underneath it’s all data structures and algorithms.
Understanding Data Structure
There are two parts to understanding Data Structure
- How to Build One?
- How to Use One?
The second point is more important than the first point because data structures are usually just tools and most of the time they’re already pre-built for us. Based on our requirement we identify the one we want to use.
How Computers Store Data
For running the code the computer needs to keep track of things like variables, numbers, strings, or array. These variables are stored in Random Access Memory (RAM).
We also have storage where we store things like video, music, and documents. This storage can be a disk drive, a flash drive, or a solid-state drive.
The computer is run by its CPU (the little worker) which does all the calculations. It needs access to the RAM and storage but access to RAM and its information faster than compared to storage.
Random Access Memory
For active learning checkout Registers and RAM: Crash Course Computer Science #6. You can skip the following explanation if you have watched the video.
RAM in the computer is a massive storage area (like data structure). This massive storage area has shelves that are numbered. They are called address or addresses.

Each shelf holds eight bits (1 and 0s). A bit is a tiny electrical switch that can be turned on or off. 8 bits is called a byte. Each shelf has one byte of storage.
The CPU is connected to a memory controller which does the reading/writing of RAM. The memory controller has direct connections to each shelf. Hence accessing shelf 0, or 7, or 10781 doesn’t mean it has to climb or step the shelves. That’s what the name random access memory means.
We can access memory really fast because we have these connections. We need to know which shelf we’re looking for we can access the bits at any random address in memory, right away!
Even though this memory controller can jump between far apart memory addresses really fast, programs tend to access memory that is nearby. The closer the information is to the CPU and the less it has to travel, the faster a program can run. For example, accessing memory at 0 and 1 is still faster than accessing 0 and 1000 position.
For further optimization, the CPU has cache memory that stores recently used data.
How is the Knowledge of Storing Data related to Data Structure?
The data structure is an arrangement of data. Our goal is to minimize the operations done by the CPU to get the information. And that is why data structures are so powerful.
We have a way now to think about how data structures actually affect the process of our computers and how we can use what we know about computers to write great code.
Operations on Data Structure
Before getting into the data structures let us see the operations that can be performed on different Data Structures.

- Insertion — add data in a given collection of items.
- Deletion — delete data from our list.
- Traversal — access each data item exactly once so that it can be processed
- Searching — find out the location of the data item if it exists in a given collection.
- Sorting — based on given information arrange the data.
- Access — fetch data with some given information.
Data Structures Using JavaScript

In Data Structures we will be covering:
We will cover a short introduction, complexities, implementation in JavaScript, and the pros & cons of each one of them in the upcoming series.






