0% found this document useful (0 votes)
18 views7 pages

Types of Arrays

The document provides an overview of data structures, focusing on arrays, abstract data types (ADTs), and concrete data structures (CDTs). It explains the characteristics, advantages, and disadvantages of arrays, the role of ADTs in data management, and basic data types in C programming, including pointers and their types. Additionally, it discusses the importance of ADTs in enhancing modularity, reusability, and simplifying problem-solving.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views7 pages

Types of Arrays

The document provides an overview of data structures, focusing on arrays, abstract data types (ADTs), and concrete data structures (CDTs). It explains the characteristics, advantages, and disadvantages of arrays, the role of ADTs in data management, and basic data types in C programming, including pointers and their types. Additionally, it discusses the importance of ADTs in enhancing modularity, reusability, and simplifying problem-solving.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DSA

Q.1.
Array
an array is a linear data structure that stores a fixed-size collection of elements
of the same data type in contiguous memory locations

they permit, access for the specific element using index or position.
index starts from 0 in most programming languages

They are abstract because they can be String, int or Person

int[] arrA = new int[1];


String[] arrB = new String[1];
Person[] arrC = new Person[3]; // where Person is treated as a defined class

Contiguous Memory Allocation – Elements are stored in consecutive memory


locations, allowing constant-time access.

Opperations of Array (Abstract data type) -

Traverse, Insert, Delete, Search, Update,

Representation of Array data type -


LOC(A[i])=BA+i×w

Types of Arrays
1. One-Dimensional Array (1D):

DSA 1
Represents a simple list of elements.

Example: int marks[5] = {10, 20, 30, 40, 50};

2. Two-Dimensional Array (2D):

Represents elements in a matrix or table form (rows and columns).

Example: int matrix[3][3];

3. Multidimensional Array:

Advantages
Fast, random access of items or elements.

Very memory efficient, very little memory is needed other than that needed to
store the contents.

Disadvantages
Slow insertion and deletion of elements

Array size must be known when the array is created and is fixed (static)

Q.2.
The Data Type is basically a type of data that can be used in different computer
program.
It signifies the type like integer, float etc, the space like integer will take 4-bytes,
character will take 1-byte of space etc.

The abstract datatype is special kind of datatype, whose behavior is


defined by a set of values and set of operations.

The keyword "Abstract" is used as we can use these datatypes, we can


perform different operations. But how those operations are working that is

DSA 2
totally hidden from the user.

The ADT is made of with primitive datatypes, but operation logics are
hidden.

Some examples of ADT are Stack, Queue, List, Array, and Tree etc.

Some important commands used in these -

Stack −

isFull(), This is used to check whether stack is full or not

isEmpry(), This is used to check whether stack is empty or not

Queue −

isFull(), This is used to check whether queue is full or not

isEmpry(), This is used to check whether queue is empty or not

List −

size(), this function is used to get number of elements present into the list

insert(x), this function is used to insert one element into the list

Q.3.

Definintion : A Concrete Data Structure is the physical implementation of an


Abstract Data Type (ADT) in a programming language, defining how data is
stored, organized, and accessed in memory.

It provides the real-world implementation of abstract concepts

Characterstics of CDT -

Defines actual data storage method in memory.

DSA 3
Provides specific algorithms for performing operations like insertion, deletion,
and traversal.

Focuses on efficiency, memory usage, and execution speed.

Dependent on programming language and machine architecture.

Concrete Data Types or


S. No. Abstract Data Types or structure (ADT)
structure (CDT)

Concrete data types or


Abstract Data Types or structures
structures provide how these
1 describe the data and the operations to
operations are actually
manipulate and change it.
implemented.

Most of the program becomes


Which is not possible in
independent of the abstract data types
2 Concrete Data Types or
representation, so it can be improved
structure (CDT)
without breaking the program.

It's easier for each part of a program to


It is not so efficient compared
3 use an implementation of its data types
to ADT.
and that will be more efficient.

Implementation of a simple
4 Implementation of a high level concept
concept

It is rarely reusable beyond its


5 It is usable beyond its original use.
original use.

6 It hides the internal details. It doesn't hide anything.

7 It uses class. It uses structure.

Examples-Arrays, linked lists,


8 Examples- lists, sets, stacks.
trees, graphs.

Q.4. Role of Abstract Data Structure in Data

Role of Abstract Data Structure in Data

DSA 4
1. Provides Data Abstraction:

It hides the details of how data is stored or implemented and focuses only on
what operations can be performed.

2. Defines Logical Structure:

It helps in defining the logical organization of data and the set of operations
that can be performed on it.

3. Improves Reusability:

Abstract data structures can be reused in different programs without rewriting


the implementation.

4. Enhances Modularity:

Programs become modular — changes in data implementation do not affect


the rest of the program.

5. Simplifies Problem Solving:

By separating data behavior from its storage, ADTs make algorithm design
and data management easier.

6. Foundation for Concrete Structures:

Abstract data structures serve as a blueprint for creating concrete data


structures like arrays, stacks, and queues

Q.5.

Basic Data Types in C


Definition:

“In the C programming language, data types specify the type of data a
variable can hold and how much memory it occupies.”

They define the range of values, the operations that can be performed, and
the storage requirements of variables.

DSA 5
C provides several basic (or primary) data types to handle different kinds of
data like integers, floating-point numbers, and characters.

Types of Basic Data Types


Data Type Keyword Description

Integer int Used to store whole numbers (positive or negative).

Character char Used to store single characters or small integers.

Used to store real numbers (numbers with decimal


Floating Point float
points).

Double Floating Used for storing large real numbers with higher
double
Point precision.

Represents no value or no type, often used with


Void void
functions that return nothing.

Derived and Modifier Types


C also provides type modifiers that change the size or range of basic types:

Type Modifiers: short , long , signed , unsigned

Q.6.

Definition :

A pointer is a special variable in C that stores the memory address of another


variable. Instead of holding a direct value, a pointer points to the location in
memory where the value is stored.

Using this, programmers can dynamically allocate memory, pass arguments by


reference, and manipulate arrays and strings efficiently

DSA 6
Pointer Operators
& (Address-of operator): Returns the memory address of a variable.

(*) (Dereference operator): Accesses the value stored at the address a


pointer is pointing to

Types of Pointers
1. Null Pointer: Points to nothing (initialized as NULL ).

2. Void Pointer: Can hold the address of any data type ( void *ptr ).

3. Wild Pointer: Uninitialized pointer pointing to an unknown location.

4. Dangling Pointer: Points to a memory location that has been freed.

5. Function Pointer: Points to a function instead of a variable

Advantages of Pointers:

Efficient Memory Access

Dynamic Memory Allocation

Function Argument Passing

Array and String Handling

Efficient Data Structures

DSA 7

You might also like