0% found this document useful (0 votes)
1 views3 pages

Data Structures

A data structure in computer science is a method of organizing and storing data for efficient access and manipulation, categorized into primitive (basic types like integers and Booleans) and non-primitive (complex structures like arrays and linked lists). Key characteristics include correctness, time complexity, and space complexity, addressing issues like efficient data processing, memory management, and algorithm design. Understanding data structures is essential for optimizing performance in applications with large datasets.

Uploaded by

murugancse2007
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views3 pages

Data Structures

A data structure in computer science is a method of organizing and storing data for efficient access and manipulation, categorized into primitive (basic types like integers and Booleans) and non-primitive (complex structures like arrays and linked lists). Key characteristics include correctness, time complexity, and space complexity, addressing issues like efficient data processing, memory management, and algorithm design. Understanding data structures is essential for optimizing performance in applications with large datasets.

Uploaded by

murugancse2007
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

WHAT IS DATA STRUCTURE?

In computer science, a data structure is a way of organizing and storing data in a computer

program so that it can be accessed and used efficiently. Data structures provide a means of

managing large amounts of data, enabling efficient searching, sorting, insertion and deletion

of data.

Data structures can be categorized into two types: Primitive data structures and non

primitive data structures.

Primitive data structures are the most basic data structures available in a programming

language,

such as integers, floating-point numbers, characters and Booleans.

Non-primitive data structures are complex data structures that are built using primitive data

types, such as arrays, linked lists, stacks, queues, trees, graphs and hash tables.

Characteristics of a Data Structure

 Correctness − Data structure implementation should implement its interface

correctly.

 Time Complexity − Running time or the execution time of operations of data structure

must be as small as possible.

 Space Complexity − Memory usage of a data structure operation should be as little as

possible.

Need for Data Structure

As applications are getting complex and data rich, there are three common problems that

applications face now-a-days.

1. Efficient data processing: Data structures provide a way to organize and store data in a

way that allows for efficient retrieval, manipulation and storage of data. For example, using a

hash table to store data can provide constant-time access to data.

2. Memory management: Proper use of data structures can help to reduce memory usage
and optimize the use of resources. For example, using dynamic arrays can allow for more
efficient use of memory than using static arrays.

3. Code reusability: Data structures can be used as building blocks in various algorithms and

programs, making it easier to reuse code.

4. Abstraction: Data structures provide a level of abstraction that allows programmers to

focus on the logical structure of the data and the operations that can be performed on it,

rather than on the details of how the data is stored and manipulated.

5. Algorithm design: Many algorithms rely on specific data structures to operate efficiently.

Understanding data structures is crucial for designing and implementing efficient algorithms.

6. Data Search − Consider an inventory of 1 million (106) items of a store. If the application
is to search an item, it has to search an item in 1 million (106) items every time slowing down
the search. As data grows, search will become slower.

7. Processor Speed − Processor speed although being very high, falls limited if the data grows

to billion records.

8. Multiple Requests − As thousands of users can search data simultaneously on a web server,

even the fast server fails while searching the data.

Primitive data structures are the most basic types of data structures provided by

programming languages. They include:

 Integer: Whole numbers (e.g., 1, 2, 100).

 Float: Numbers with decimal points (e.g., 3.14, 0.001).

 Character: Single characters (e.g., ‘A’, ‘B’).

 Boolean: Logical values (true or false).

Sample Program in C++ (Primitive Data Types)

#include <iostream>

using namespace std;

int main() {
int num = 10; // Integer

float pi = 3.14; // Float

char letter = 'A'; // Character

bool isHappy = true; // Boolean

cout << "Integer: " << num << endl;

cout << "Float: " << pi << endl;

cout << "Character: " << letter << endl;

cout << "Boolean: " << isHappy << endl;

return 0;

2. Non-Primitive Data Structures

Non-primitive data structures are more complex and are built using primitive data types.
They

are further divided into:

a. Linear Data Structures

In linear data structures, elements are arranged sequentially, and each element has a unique

predecessor and successor (except the first and last elements).

 Array: A collection of elements of the same type, stored in contiguous memory

locations.

 Linked List: A collection of nodes where each node contains data and a pointer to the

next node.

 Stack: A collection of elements following the Last In First Out (LIFO) principle.

 Queue: A collection of elements following the First In First Out (FIFO) principle.

You might also like