Data Structure Unit1
Data Structure Unit1
Greater Noida
Unit: 01
Subject Name
Data Structures Mrs. Nidhi Sharma
(AOE0662) NIET, Greater Noida.
Electronics and
Course Details
(B Tech 4th Sem) Communication
Engineering.
Research Interests
VLSI Design, Communication System, Internet of Things.
UNIT III: Basic terminology used with Tree, Binary Trees, Binary Tree Representation: Array Representation and Pointer (Linked List)
Representation, Binary Search Tree, Strictly Binary Tree, Complete Binary Tree, An Extended Binary Trees. Tree Traversal algorithms: In-order,
Pre-order and Post-order. Constructing Binary Tree from given Tree Traversal, Operation of Insertion, Deletion, Searching & Modification of data
in Binary Search tree, Introduction of Binary Heaps, Threaded Binary trees, Traversing Threaded Binary trees, AVL Tree, B-Tree.
UNIT IV: Graphs: Terminology used with Graph, Data Structure for Graph Representations: Adjacency
matrices, Adjacency List. Graph Traversal: Depth First Search and Breadth First Search. Connected
Component, Spanning Trees, Minimum Cost Spanning Trees: Prim’ s and Kruskal’s algorithm. Shortest Path
algorithms: Dijkstra Algorithm.
UNIT-V: Searching: Concept of Searching, Sequential search, Index Sequential Search, Binary Search. Concept of
Hashing. Sorting: Insertion Sort, Selection, Bubble Sort, Quick Sort, Merge Sort, Heap Sort and Radix Sort. File Structure:
Concepts of files, records and files, Sequential, Indexed and Random File Organization, indexing structure for index files,
multi-Key file organization and Access Methods.
Ms. Nidhi Sharma AOE0662 Data Stuctures Unit1
BRANCH WISE APPLICATION
When we talked about it is very vast majority
used today’s and the biggest example of it is
social media. People all around the world
connect with each other through social media.
From the origin of the primary programming
languages to the fashionable programming
languages presently in use, computer
programing has evolved quite lot. it’s currently
become additional powerful, efficient, and
advanced. However, the basic ideas and use of
information structure and algorithms in laptop
programming haven’t changed. It must be the
core of computer programming from the
beginning. you may have detectedAOE0662 Data
StucturesA getting used in the main within the
field of computer science. However, the
employment ofAOE0662 Data StucturesA isn’t
restricted to the sector of computing. we will
conjointly notice the construct ofAOE0662 Data
StucturesA being used in day to day life.
Nidhi Sharma AOE0662(DS) Unit-1
Course Objective
https://www.youtube.com/watch?v=ZAU5IlCQBls
• Students will be familiar with the concept of time and space complexity.
• Students will be able to demonstrate linear data structure array.
The study of data structure, includes the following three steps/ characteristics:
(3) Quantitative analysis of the structure, which include determining the amount
of memory needed to store the structure and the time required to process the
structure.
1. Data
Data can be defined as a representation of facts, concepts or instructions in a
formalized manner suitable for communication, interpretation or processing by
human or electric machines. Data is represented with the help of characters like
alphabets (A-Z,a-z), digits (0-9) and special characters (+,-,*,<, >, =, ^ etc.).
3. Record
Record is a collection of related data items. E.g. a student record for a
student’s contains data fields such as name, age,class etc.
5. Entity:
An entity is a person, place, thing, event or concept about which information
recorded.
6. Attribute:
Attributes gives the characteristics or properties of the entity.
7. Data Value:
A data value is the actual data or information contained in each attribute.
Example:
Entity : Employee
Attributes: Id, Name, Age
Value: 1, ABC, 18
8.Entity Set
Entities with similar attributes form an entity set. For example, All the
employees in an organization form an entity set.
Secondary Key: A field in a record which identifies the records but not
uniquely is called a secondary key. For Example, NAME and MARKS are the
secondary keys in Student file.[2]
• https://video.search.yahoo.com/search/video?fr=mcafee&p=elementary+
data+organization+video#id=1&vid=5a74b11f053de91ba9baa46c6a762b3
b&action=click
After studying Built in Data Types in C/python students will understand the
concept of various types of data types.
Python has the following data types built-in by default, in these categories:
Data Type
Memory (bytes)
Range
Format Specifier
short int
2
-32,768 to 32,767
%hd
unsigned short int
2
0 to 65,535
%hu
05/12/2025 Nidhi Sharma AOE0662 Data Structures Unit 1
Built in Data Types in C/python
unsigned int
4
0 to 4,294,967,295
%u
int
4
-2,147,483,648 to 2,147,483,647
%d
long int
4
-2,147,483,648 to 2,147,483,647
%ld
unsigned long int
4
0 to 4,294,967,295
%lu
long long int
8
-(2^63) to (2^63)-1
%lld
05/12/2025 Nidhi Sharma AOE0662 Data Structures Unit 1
Built in Data Types in C/python
unsigned long long int
8
0 to 18,446,744,073,709,551,615
%llu
signed char
1
-128 to 127
%c
unsigned char
1
0 to 255
%c
float
4
1.2E-38 to 3.4E+38 %f
double
8
1.7E-308 to 1.7E+308 %lf
long double
16
05/12/2025 3.4E-4932 to 1.1E+4932
Nidhi Sharma AOE0662 Data Structures
%Lf Unit 1
Built in Data Types in C/python
Integer Types
The integer data type in C is used to store the whole numbers without decimal
values. Octal values, hexadecimal values, and decimal values can be stored in
int data type in C. We can determine the size of the int data type by using the
sizeof operator in C. Unsigned int data type in C is used to store the data
values from zero to positive numbers but it can’t store negative values like
signed int. Unsigned int is larger in size than signed int and it uses “%u” as a
format specifier in C programming language. Below is the programming
implementation of the int data type in C.
What is an Algorithm?
An algorithm is a well-defined list of steps for solving a particular problem.
For Example: Algorithm To add Two numbers :
• Time Complexity.
Complexity of Algorithms:
In order to compare algorithms, we must have some criteria to measure the
efficiency of our algorithms.
After studying ‘Time and Space Complexity’ students will come to know
how much is the importance of (run time) time while writing efficient
algorithms.
Time Complexity
Time Complexity of an algorithm(basically when converted to program) is the
amount of computer time it needs to run to completion. The time taken by a
program is the sum of the compile time and the run/execution time . The
compile time is independent of the instance(problem specific) characteristics.
following factors effect the time complexity:
• Characteristics of compiler used to compile the program.
• Computer Machine on which the program is executed and physically
clocked.
• Multiuser execution system.
• Number of program steps.
After studying ‘Asymptotic notations: Big Oh, Big Theta and Big Omega’
students will be capable of quantifying the complexity of an algorithm.
https://video.search.yahoo.com/search/video?fr=mcafee&p=big+oh+notation
+data+structure+video#id=2&vid=0da5ae6151918fd479169873ccb78a6b&act
ion=click
Q1: If time taken by an algorithm to run is more then that algorithm is ………………
Efficient/inefficient.
Q2: In case of Big Oh notation worst case is ………………… tightly Bound/ Loosly bound/
Efficient case.
Time Complexity
Time Complexity of an algorithm(basically when converted to program) is the
amount of computer time it needs to run to completion. The time taken by a
program is the sum of the compile time and the run/execution time .
Big oh notation (O)- Worst Case (Tightly Bound) – e.g. O(1), O(n), O(n 2 ),
O(n 3 ), O(n n ), O(log n), O(n log n)
After studying ‘Abstract Data Types (ADT)’ students will come to know
about ADTs.
Abstract Data type (ADT) is a type (or class) for objects whose behavior is
defined by a set of values and a set of operations. The definition of ADT only
mentions what operations are to be performed but not how these operations
will be implemented. It does not specify how data will be organized in
memory and what algorithms will be used for implementing the operations. It
is called “abstract” because it gives an implementation-independent view.
The process of providing only the essentials and hiding the details is known as
abstraction.
05/12/2025 Nidhi Sharma AOE0662 Data Structures Unit 1
Abstract Data Types (ADT)
Q1: What is the difference between elementary data item and grouped data
item?
Q2: What is primary Key and Secondary key? Give example of each.
Q3: Define Entity and Attribute with example.
Q4: Define traversing ,searching, sorting operations .
Q5: What is recurrence? Explain with the help of example.
Q6: What is the Abstract data type?
Q7: What is time space trade off?
Q8: Explain the concept of field, record and file.
After studying ‘Arrays’ students will understand the concept of one of the
linear data structure which stores similar data items – Array.
Linear array:
A linear array is a list of a finite number n of homogeneous data elements.(i.e.
data elements of same type) such that:
1. The elements of the array are referenced respectively by an index set
consisting of consecutive numbers.
2. The elements of the array are stored respectively in successive memory
locations.
Length of an array:
The number n of elements is called the length or Size of the array.
Length= UB-LB+1
05/12/2025 Nidhi Sharma AOE0662 Data Structures Unit 1
Arrays: Single and Multidimensional Arrays
Basic Operations
Following are the basic operations supported by an array.
Step 5: Exit
Step 5: Exit .
Insertion Algorithm:
We have to insert a name- Rahul at index no. 3
NAME NAME NAME
1 Amit 1 Amit 1 Amit
2 Manish 2 Manish 2 Manish
3 Sumit 3 3 Rahul
4 Ram 4 Sumit 4 Sumit
5 Ramesh 5 Ram 5 Ram
6 6 Ramesh 6 Ramesh
7 7 7
8 8 8
[End of loop ]
#include <stdio.h>
int main()
{
int arr[100] = { 0 };
int i, x, pos, n = 10;
05/12/2025 Nidhi Sharma AOE0662 Data Structures Unit 1
Operation on arrays
// insert x at pos
arr[pos - 1] = x;
return 0;
}
05/12/2025 Nidhi Sharma AOE0662 Data Structures Unit 1
Operation on arrays
Deletion Algorithm:
We have to delete a name- Ram.
• https://video.search.yahoo.com/search/video?fr=mcafee&p=algorithm+fo
r+traversing+a+linear+array#id=1&vid=5b42cd22970b6591707cad125d98
2dbf&action=click-
Q1: How index number is affected by insertion and deletion operation into
the array?
Q2: What is row major and column major order?
Q3: How the LOC is found in a linear array?
Array
An array is a collection of items stored at contiguous memory locations.
Array Operations
Traverse − print all the array elements one by one.
Insertion − Adds an element at the given index.
Deletion − Deletes an element at the given index.
LOC (A [J, K]) = The location of the element in the Jth row and Kth
column.
Base (A) = The base address of the array A.
W = The number of bytes required to store single element of the array A.
N = The total number of columns in the array.
J = The row number of the element.
K = The column number of the element.
Suppose we have to find the location of A [3, 2]. The required values are:
Base (A) = 1000
w = 2 (because an integer takes 2 bytes in memory)
N=4
J=3
K=2
Now put these values in the given formula as below:
LOC (A [3, 2]) = 1000 + 2 [4 (3-1) + (2-1)]
= 1000 + 2 [4 (2) + 1]
= 1000 + 2 [8 + 1]
= 1000 + 2 [9]
= 1000 + 18
= 1018
05/12/2025 Nidhi Sharma AOE0662 Data Structures Unit 1
Representation of Arrays: Row Major Order, and
Column Major Order
INTEGER NUMB(2:5,-3:1)
• It is a 2D array
• No. of rows=5-2+1=4
• No. of Columns= 1-(-3)+1=5
• https://video.search.yahoo.com/search/video?fr=mcafee&p=Representati
on+of+arrays+in+memory#id=2&vid=c91f7715bd3ec193dc18f0af08d5980
a&action=click
Linked list:
A Linked List or One Way List, is a linear collection of data
elements , called nodes, where the linear order is given by
means of pointers. That is, each node is divided into two parts:
the first part contains the information of the element, and the
second part, called the link field or nextpointer field, contains
the address of the next node in the list.
A Two way list is a linear collection of data elements, called nodes, where each
node N is divided into three parts:
1 An information field INFO which contains the data of N.
2 A pointer field FORW which contains the location of the next node in the list.
3 A pointer field BACK which contains the location of the preceding node in
the list.
• This means that how the data in the INFO field of all the nodes is stored in
the form of an array.
PTR:= LINK[PTR]
A header linked list is a linked list which always contains a special node,
called the header node, at the beginning of the list.
Two types of header lists:
1. A grounded header list is a header list where the last node contains the
null pointer.
2. A circular header list is a header list where the last node points back to
the header node.
Input:
1st number = 5x2 + 4x1 + 2x0
2nd number = -5x1 - 5x0
Output:
5x2-1x1-3x0
Input:
1st number = 5x3 + 4x2 + 2x0
2nd number = 5x^1 - 5x^0
Output:
5x3 + 4x2 + 5x1 - 3x0
Addition-of-two-polynomial
Examples:
• In this approach we will multiply the 2nd polynomial with each term of 1st
polynomial.
• Store the multiplied value in a new linked list.
• Then we will add the coefficients of elements having the same power in
resultant polynomial.
Examples:
• https://video.search.yahoo.com/search/video;_ylt=Awr9NVUptbxem0YA.
DL7w8QF;_ylu=X3oDMTBncGdyMzQ0BHNlYwNzZWFyY2gEdnRpZAM-;_yl
c=X1MDOTY3ODEzMDcEX3IDMgRhY3RuA2NsawRjc3JjcHZpZANsT3JOS3p
Fd0xqTFpsdlhHV3lqV1ZRQ1pNVEEyTGdBQUFBRHpUVUlwBGZyA21jYWZlZ
QRmcjIDc2EtZ3AEZ3ByaWQDSjg3TjdvazVSUS5CdllKd1hvQVJGQQRuX3Jzb
HQDNjAEbl9zdWdnAzEwBG9yaWdpbgN2aWRlby5zZWFyY2gueWFob28uY
29tBHBvcwMwBHBxc3RyAwRwcXN0cmwDBHFzdHJsAzIxBHF1ZXJ5A0xpb
mtlZCUyMGxpc3QlMjB2aWRlbwR0X3N0bXADMTU4OTQyODg5Mw--?p=Li
nked+list+video&ei=UTF-8&fr2=p%3As%2Cv%3Av%2Cm%3Asa&fr=mcafe
e#id=2&vid=801d07015208266e022a01875d6c2ba2&action=view
05/12/2025 Nidhi Sharma AOE0662 Data Stuctures Unit1
FAQs
Q1: What do you by linked list? State the types of linked lists.
Q2: Explain Circular linked list with neat diagram.
Q3: Explain how a node is inserted as first node in the linked list?
Q4: Write an algorithm to delete a node from the given location.
Q5: Write an algorithm to insert a node before the given location.
List operations:
Insertion of a Node as First node
Insertion of a Node after a given location
Deletion of a node at given LOC.
Q1: How index number is affected by insertion and deletion operation into
the array?
Q2: What is row major and column major order?
Q3: How the LOC is found in a linear array?
Q4: What are Character strings? Explain with suitable examples.
Q5: What do you mean by Sparse Matrix? Explain the types of Sparse
Matrices.
Q6: What do mean by linear array and multi-dimensional array?
Find the location of A [2, 3]. The required values are:Base (A) = 1000W = 2 (because
1 10 CO2 K1,K2
an integer takes 2 bytes in memory)M = 3J = 3K = 2
2 Distinguish between a linked list and a doubly linked list. 10 CO2 K1,K2
How do you find the complexity of an algorithm? What is the relation between the
3 10 CO2 K1,K2,K3
time and space complexities of an algorithm? Justify your answer with an example.
Given the base address of an array B[1300…..1900] as 1020 and size of each
7 10 CO2 K1,K2
element is 2 bytes in the memory. Find the address of B[1700].
8 Write an algorithm to insert an node after a given node with diagram. 10 CO2 K1,K2
Find the base address of an array A[-15:65]. The size of each element is 2
9 10 CO2 K1,K2,K3
bytes in the memory and the location of A[37] is 4279.
https://noidainstituteofengtech-
my.sharepoint.com/:b:/g/personal/
nidhisharma_niet_co_in/
EYRnv18D_TlNso22HXXGW3sBtHvazqQLJWEd7y
xtzwhrwA?e=RL0Vcs
05/12/2025Nidhi Sharma AOE0662 Data Structures Unit 1
Expected Questions for University Exam
Time Complexity
Time Complexity of an algorithm(basically when converted to program) is the
amount of computer time it needs to run to completion. The time taken by a
program is the sum of the compile time and the run/execution time .
Big oh notation (O)- Worst Case (Tightly Bound) – e.g. O(1), O(n), O(n 2 ),
O(n 3 ), O(n n ), O(log n), O(n log n)
Data
Data can be defined as a representation of facts, concepts or instructions in a
formalized manner suitable for communication.
Entity:
An entity is a person, place, thing, event or concept about which information
recorded.
Attribute:
Attributes gives the characteristics or properties of the entity.
Data Value:
A data value is the actual data or information contained in each attribute.
Entity Set
Entities with similar attributes form an entity set.
05/12/2025 Nidhi Sharma AOE0662 Data Structures Unit 1
Recap
Secondary Key: A field in a record which identifies the records but not
uniquely is called a secondary key.
Array
An array is a collection of items stored at contiguous memory locations.
Array Operations
Traverse − print all the array elements one by one.
Insertion − Adds an element at the given index.
Deletion − Deletes an element at the given index.
For 2D array
Column Major order
LOC (A [J, K]) = Base (A) + w [M (K-1) + (J-1)]
Sparse Matrices
Sparse matrices are those matrices whose most of the entries are zero.
Character Strings.
Thank You