The document discusses various data structures, focusing on queues and arrays, including operations such as enqueue, dequeue, insertion, deletion, and searching. It explains the representation of arrays, basic operations supported, and differentiates between primitive and abstract data types. Additionally, it categorizes data structures into linear and non-linear types, emphasizing their organization and manipulation in memory.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0 ratings0% found this document useful (0 votes)
10 views7 pages
Screenshot 20240426-044736 Drive
The document discusses various data structures, focusing on queues and arrays, including operations such as enqueue, dequeue, insertion, deletion, and searching. It explains the representation of arrays, basic operations supported, and differentiates between primitive and abstract data types. Additionally, it categorizes data structures into linear and non-linear types, emphasizing their organization and manipulation in memory.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 7
:nqueue Operation
4
‘Queue Enqueue
gorithm for enqueue operation
frieenensemih aponighr=
ne oP
ad Fest
Queue Dequeve
gorithm for dequeue operation =
vetalemige ese eh ceDATA STRUCTURE - QUEUE
lowe Pet tebvsranthdbloy Lethe aaia em seed Ha be
povirtertsigett is rpetmememy tenner
‘queue Representation
ponte
respect tener ene er
se
fowmee actors ore regatta mae atone metand
+ k= tt et tt entre
+ fated
Fem
(oarsmen
SANE Siena Sa
poche remermhacete~Deletion Operation
Deletion refers to removing an existing element from the array and re-organizing all elements of
an array.
Algorithm
Consider LAs a linear array with N elements and Kis a positive integer such that K<=N. Below is
the algorithm to delete an element available at the K*” position of LA.
4. start
2! set Jak
3. Repeat steps 4 and 5 while 3 <6
4) See Agdeay = UALS]
5. Set 9 = 3
8. Set H = Ned
7. Stop
Exampl
Below is the implementation of the above algorithm —
‘include = K
5. Set LA[3+1] = LA[3]
6. Set J = 3-1
7. Set LA[K] = ITEM
8. StopDATA STRUCTURE - ARRAYS
Array is a container which can hold fix number of items and these items should be of same type.
Most of the datastructure make use of array to implement their algorithms. Following are
important terms to understand the concepts of Array.
‘+ Element ~ Each item stored in an array is called an element.
+ Index - Each location of an element in an array has a numerical index which is used to
identify the element.
Array Representation
Arrays can be declared in various ways in different languages. For illustration, let's take C array
declaration.
int array [10] = { 35, 33, 42, 10, 14, 19, 27, 44, 26,31}
Arrays can be declared in various ways in different languages. For illustration, let's take C array
declaration.
elements | 35 33) 42 10 14] 19 | 27 | 44 | 26 | 31
index 012345 67 89
Size 10
‘As per above shown illustration, following are the important points to be considered.
+ Index starts with 0.
‘= Array length is 8 which means it can store 8 elements.
* Each element can be accessed via its index. For example, we can fetch element at index 6 as,
9.
Basic Operations
Following are the basic operations supported by an array.
+ Traverse ~ print all the array elements one by one.
+ Insertion — add an element at given index.
+ Deletion ~ delete an elementat given index.
+s
‘h — search an element using given index or by value.
+ Update — update an element at given index.
In C, when an array is initialized with size, then it assigns defaults values to its elements in following
order,Data Type
OA data type is a collection of values and set of operations on that act on those values.
eg. short int
~ set of values between -32768 to 32767
= set of operations +-* /
0 Primitive data type : A data type that is predefined, also called built in data type.
e.g. int, long, float etc.
Abstract Data Type (ADT):
~A.user define data type whose representation is hidden.
- set of values & operations is separated from the representations of the values.
= Mathematical description of an object with set of operations on the object.
eg. Stack, Queue, Link ist, array et.
Tout C3, DI atic 7
Primitive vs Abstract data type
O Primitive
1. PDT is predefined also called built in data type
2. They are basic constructs of the language that is they are built into the language.
3. t's representation is not hidden.
4. PDT tents to be strict data type meaning we can not treat character like integer or Boolean.
5. Int, float, etc. are example of primitive data type.
0 Abstract
1. ADT is called user defined data type
2.Itis generally construct by the user or higher level language.
3. t's representation is hidden.
4, ADT contain ability to either be treated as a specific type of primitive data
S. List, queue, stack, tree etc. are example of ADT.
Tout, C3 Daas 8
Data Structure
> A data structure is logical or mathematical model of a particular
organization of data.
> Adata structure is a mechanism for organizing data in memory.
> A data structure can be defined as an organized collection of data
and the set of operations on those data.
> The choice of particular data structure is depend on the following
considerations:Type of Data Structure
Pe ==
I
[Levee] [oor] [ehracer] [poner] | |
The Tne
— I
‘roy | [Sine] [Gomve] [Unter | [ee] [apr
Type of Data Structure
2 Primitive Data Structure
Primitive data structure are basic structures and are directly operated upon
by machine instructions.
Non primitive data structure
> Non primitive data structure are more sophisticated data structures.
> Non primitive data structure are derived from the primitive data structures.
> The non-primitive data structures emphasize on structuring of a group of
‘homogeneous (same type) or heterogeneous (diferent type}data items.
‘rat tH
Categories of Various Data Structures
The various data structures are divided into two categories:
Linear data structures: A data structure whose elements form a
sequence, Le. every element of the structure has a unique
predecessor and unique successor.
arrays, linked lst, stacks, queues
"Non-linear data structures: A data structure whose elements do
not form a sequence, there Is no unique predecessor or unique
trees, graphs