DEV Community

Cover image for Data Structure & Why It Is So Important? 👩‍💻👨‍💻
ahseya03
ahseya03

Posted on • Updated on

Data Structure & Why It Is So Important? 👩‍💻👨‍💻

"To build a house, you need a structure. When you choose the right structure for your house, your design aligns perfectly. Similarly, Data structures are programming structures essential in building your best program." - Ayesha Mahmood

Data Structures are classified into two types:

  1. Primitive Data Types
  2. Non-Primitive Data Types

Learn More about Primitive & Non Primitive Data types **


**Overview of Data Structure Types

Choose your Structure!

Image description

Why do we learn about Data Structure in Computer Science?

It's hard to understand how Data Structure plays a role in programming and confuses many students why they have to learn Data Structure in their first Computer Science class.

Data structures are actually an essential way one can store data in a particular way that makes it efficient for use.

When you are writing code there will be data you want to store and there will also be data from the user.

We need something to store that data. So how do we store that data? This is where data structure comes in handy and that is the function of data structure which is built for organizing, processing, retrieving, and storing data.

Here we defined type as "string name". We are essentially creating a container of string data type to store only strings. There will be data from the user's side. In this example, the user will enter their name(data) as a "string" data type and this name will be stored in the container for string we defined.
For example:

Image description
We are asking the user for input. We are asking the user to type or input their name by using "cin name" command. We are getting input from the user. When asked for a name, the user entered "Sarah". "Sarah" string data is entered by the user which is then stored in the string container. The data is then processed and retrieved back to the console as output "Hello Sarah."

Top comments (0)