0% found this document useful (0 votes)
12 views

DS _ unit-1

The document provides an overview of data structures (DS), including their classification into primitive and non-primitive types, and discusses abstract data types (ADT) which encapsulate data and operations. It outlines key concepts such as abstraction, encapsulation, and the features, advantages, and disadvantages of ADTs. Additionally, it covers algorithms, their characteristics, and details about arrays, including one-dimensional and multi-dimensional arrays.
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)
12 views

DS _ unit-1

The document provides an overview of data structures (DS), including their classification into primitive and non-primitive types, and discusses abstract data types (ADT) which encapsulate data and operations. It outlines key concepts such as abstraction, encapsulation, and the features, advantages, and disadvantages of ADTs. Additionally, it covers algorithms, their characteristics, and details about arrays, including one-dimensional and multi-dimensional arrays.
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
You are on page 1/ 6

Data Structure

- data is collection of facts & figures or set of values of specific format that refers to a single
set of items
- DS is a branch of CS
- study of DS allows us to understand the organisation of data & management of data flow in
order to increase efficiency of any process of program
- DS is the building block of any software

Data-items: it is a single unit of value


Group-item: data-items that have sub-ordinate data are known as group-item
Elementary-items: data-items unable to divide into sub-items are known as elementary-items

Entity & Attributes:


- a class of certain objects is represented by entity which contains different attributes

Classification of DS:

Primitive DS (PDS):
- PDS consisting of numbers & characters that come’s built in the program
- these DS can be manipulated operated directly by machine level instructions
- these data types are also called as simple data types as they contain char’s that
cannot be divided further

Non-Primitive DS (NPDS) :
- NPDS are DS that are derived from PDS
- these DS cannot be manipulated or operated directly by machine level instructions
- the main focus of these DS is on forming a set of data elements i.e. either
homogenous or heterogenous
- Based on the structures & arguments we can divide NPDS into 2 sub-categories i.e.
i) Linear DS & ii)Non-Linear DS
1.Linear DS :-
- arrangement of data is done linearly where each element consists of successors &
predecessors first & last data element
- based on memory allocation the linear DS is further classified into two types i.e.
i)Static & ii)Dynamic

Static DS
- the DS which is having fixed size is called as static DS
- the memory for this Ds is allocated at compiler line & their size cannot be
changed by user after being complied
- E.g., Array

Dynamic DS
- the dynamic DS which is having dynamic (changeable) size, more over the
user can change size as well as the data elements stored in the DS at
runtime of the program
- e.g., linked list, stack, queue, etc

Abstract Data Type (ADT) :

- an ADT is an abstraction of DS that provides only the interface to which the DS must
depends
- ADT are the entities that are definitions of data & operation but do not have
implementation details
- in this case, we know the data that we’re storing & the operations that can be
performed on the data but we don’t know the implementation details
- ADT for objects whose behaviour is defined by set of values & set of operations
- it does not specify how data will be organised in memory & what algorithms will be
used for implementing the operations
- it is called abstract bcoz it gives an implementation independent view
- users only need to know what data types can do but not how it will be implemented
- e.g., a C DS is implemented using structures, while C++ DS is implemented using
objects & classes

Abstraction : it is technique of hiding the internal details from the user & only showing
necessary details to the user

Encapsulation : it is a technique combining data & member functions in the single unit
1.List ADT (LADT) :
- the data is generally stored in a key sequence in a list which has head structure
consisting of compare functions which need to compare data in a list
- the main functions of LADT are;
- get() : returns an element from the list at any given position
- insert() : inserts an element at any given position in a list
- remove() : removes the 1st occurrence of an element from a list
- removeAt() : removes the element from the given position from a list
- replace() : replaces an element by given element
- size() : returns the number of elements in the list
- isEmpty() : returns TRUE if the list is empty else returns FALSE
- isFull() : returns TRUE if the list is full else returns FALSE

2.Stack ADT (SADT) :


- the program allocates memory for the data & address is passed to SADT
- the head node & data node are encapsulated
- in ADT, the calling function can only see the pointer to the stack
- stack head structure also contains a pointer to top & counts number of entries
currently in a stack
- the main functions of SADT are;
- push() : inserts an element at top end of the stack
- pop() : removes an element at top of the stack
- peek() : returns the top element in the stack
- isEmpty() : returns TRUE if the stack is empty else returns FALSE
- isFull() : returns TRUE if the stack is full else returns FALSE

3.Queue ADT (QADT) :


- each node contains void pointer to the data & the link pointer to the next element in
the queue
- the program's responsibility is to allocate the memory for storing the data in
sequential manner
- the main functions of QADT are;
- enqueue() : inserts an element at the end of the queue
- dequeue() : removes & returns an element from the start of the queue
- peek() : returns an element from the front of the queue
- size() : returns the number of elements in the queue
- isEmpty() : returns TRUE if the queue is empty else returns FALSE
- isFull() : returns TRUE if the queue is full else returns FALSE

Features of ADT:
1.Abstraction
- the user does not need to know the implementation of DS, only essential data is
provided

2.Encapsulation
- ADT hides the internal details of data & provide a public interface for users to interact
with data
3.Information Hiding
- ADT can protect integrate of the data by allowing access only to authorised user’s

4.Data Abstraction
- ADT provide level of abstraction from implementation details of that data
- users only need to know the operations that can be performed on that data, not how
those operations are implemented

Advantages of ADT:
1.Encapsulation
- ADT provide a way to encapsulate data & operations into a single unit working
making it easier to manage & modify DS
2.Abstraction
- ADT allow users to work with DS without having to know the implementation details
3.DS Independency
- ADT can be implemented using different DS which can make it easier to adapt
changing needs & requirement
4.Information Hiding
- ADT provides integrate of the data by allowing access to authorised users
5.Modularity
- ADT can be combined with other ADT to perform more complex DS which can
increase flexibility & modularity in our programming

Disadvantages of ADT:
- Overhead
- Complexity
- Learning curve
- Limited flexibility
- Cost

Algorithm:
- algorithm means set of finite rules or instructions to be followed in calculation or other
problem solving techniques
- algorithms are necessary for solving complex problem efficiently & effectively
- It also enables computer to perform task that would be difficult to humans to do
manually
Characteristics of Algorithm:

1.Clean & Unambiguous


- each of its step should be clear be clear in all aspects & must lead to one meaning

2.Well Defined Input


- if an algorithm says to take input then that input should be well defined

3.Well Defined Output


- algorithm must clearly define what output should get
- it should be producing at least one output

4.Finiteness
- algorithm must be finite i.e. it should terminate after finite time

5.Feasible
- algorithm must be simple, generic & practical, such that it can execute with the
available resource

6.Language Independent
- algorithm design must be language independent

7.Input
- algorithm has zero or more input
- each input contains fundamental operator

8.Output
- algorithm must produce at least one output
- each instructions contains fundamental operator
Array:
- an array is a collection of items of same DT that are stored in continuous memory
location
- there are two types of array i.e. i)One-Dimensional Array & ii) Multi-Dimentional Array
- 1D-Array = array stored in single row
- Multi-Dimentional Array = array stored in multiple row of elements

1D-Array:
- this is the simplest form of an array may be defined abstractly as a finite order which
is a set of homogenous & heterogenous elements
- we must also specify how the structure is accessed
- two basic operations of an array are extraction & storing
- the extraction operation is a function that accesses an array A & index (i) & returns
an element of the array at index[i]
- here is an example of an array A storing an element ‘x’ at index[i]

- the smallest element of an array is called as the lower bound


- the highest element of an array is called as the upper bound
- if the lower bound of an array & upper bound

You might also like