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

File

The document outlines a syllabus for a course on Data and File Structures, covering topics such as linear and non-linear data structures, abstract data types, and various algorithms for sorting and searching. It emphasizes the importance of data structures for efficient data management, scalability, and optimal performance. Additionally, it discusses algorithm characteristics, complexity analysis, and provides examples of time and space complexity.

Uploaded by

hiyahir222
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

File

The document outlines a syllabus for a course on Data and File Structures, covering topics such as linear and non-linear data structures, abstract data types, and various algorithms for sorting and searching. It emphasizes the importance of data structures for efficient data management, scalability, and optimal performance. Additionally, it discusses algorithm characteristics, complexity analysis, and provides examples of time and space complexity.

Uploaded by

hiyahir222
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Data and File Structures

Syllabus
UNIT 1:
Introduction to Linear Data Structures:

Introduction and Classification of Data Structures, Abstract Data Types.

Arrays: Single Dimension, Multi Dimensions, Memory Representation, Address


Calculation, Sparse Matrices- Types, Representation and Operations, Linear
and Binary Search, Selection Sort, Bubble Sort, Insertion Sort, Radix Sort,
Merge Sort, Shell Sort.

Linked List: Dynamic Memory versus Static Memory Allocation, Types and
Operations Singly Linked List, Doubly Linked List, Header Linked List, Circular
Linked List, Applications Polynomial Arithmetic.

Stacks and Queues: Introduction and Implementation, Types of Queues and


Applications, Multi Stacks and Multi Queues, Applications of Stacks- Need,
Evaluation and Conversion between Polish and Reverse Polish Notations,
Quick Sort, Recursion.

Introduction to Data Structures


Data structure is a way to store and organize the data so that it can be used
efficiently.

Organizing the data in the memory

Use any programming language to structure data in the memory

Linear Data Structures


The arrangement of data in the sequential manner is known as linear data
structure. The data structure used for this purpose is Arrays, LinkedList, Stacks
and Queues .

Data and File Structures 1


In this data structures, one element is connected to next element in a linear
form.
Non-Linear Data Structures
When one element is connected to the n number of elements known as non-
linear data structures. The data structures used for this purpose is Trees and
Graphs .

In this data structures, elements are arranged in a random manner.


Abstract Data Type

An abstract data type is an abstraction of data structure that provides only the
interface to which the data structure must adhere. The interface does not give
any specific details about something, should be implemented or in what
programming language. The reason for not having implementation details is
that every programming language has a different implementation strategy. For
example: A list is an abstract data type that is implemented using a dynamic
array and linked list. A queue is implemented using linked list based queue,
array based queue, and stack based queue.

Need of Data Structures

Data and File Structures 2


Efficient Data Management: Data structures enables the efficient storage
and organization of data, allowing operations like searching, insertion,
deletion, and sorting to be performed quickly.

Scalability: As application grow in size and complexity, data structures


help manage large amounts of data efficiently.

Optimal Performance: Data structures allow operations to be performed


with minimal resource consumption, optimizing both time and space.

Abstraction: Data structures provide an abstraction to deal with complex


problems by hiding the implementation details. Example: A stack can be
implemented using arrays or linked lists, but the user interacts with it
through its operations (push, pop).

Improved Algorithm Performance: Algorithms rely heavily on efficient data


structures for optimal performance. Example: Sorting algorithms like
quicksort rely on arrays, while graph algorithms like Dijkstra’s use
adjacency lists or matrices.

Data Structure Classification

Data and File Structures 3


Operations on Data Structures

1. Traversing: Every data structure contains a set of data elements.


Traversing data elements means visiting each element of data structure in
order to perform some specific operation like searching or sorting.

2. Insertion: It can be defined as the process of adding the elements to the


data structure at any location. If the size of data structure is n then we can
only insert n-1 data elements to it.

3. Deletion: The process of removing an element from the data structure is


called deletion. we can delete an element from data structure at any
random location. If we try to delete an element from an empty data
structure than underflow(not enough data or capacity to perform) occurs.

4. Searching: The process of finding the location of an element within data


structure is called searching. There are two algorithms to perform
searching, linear search and binary search.

5. Sorting: The process of arranging the data structure in a specific order is


called sorting. There are many algorithms that can be used to perform
sorting. There are many algorithms that can be used to perform sorting for
example: insertion sort, selection sort, bubble sort, etc.

Introduction to Algorithms
An algorithm is a process or a set of rules required to perform calculations or
some other problem solving operations especially by a computer. It is just a
logic of a program, which can be represented either as an informal description
using a flowchart or pseudo code.

Characteristics of Algorithms

Input: An algorithm has some input values. We can pass 0 or some input
value to an algorithm.

Output: We will get 1 or more output at the end of an algorithm.

No Ambiguity: An algorithm should not contain any ambiguity which


means that instruction should be clear and simple.

Data and File Structures 4


Finite Instructions: An algorithm should have limited number of
instructions.

Asymptotic Analysis
The time required by an algorithm comes under three types:

Worst Case: It defines the input for which the algorithm takes more time.

Average Case: It takes average time for the program execution.

Best Case: It defines the input for which the algorithm takes less time.

Asymptotic Notations

1. Big Oh Notation(O):This notation provides an upper bound on a function


which ensures that function never grows faster than the upper bound. It
measures the worst case or the longest amount of time an algorithm can
possibly take to complete.

2. Theta Notation(θ): This notation is the formal way to express both the
lower bound and the upper bound of an algorithm’s running time. It mainly
describes average case.

3. Omega Notation(Ω): This notation is the formal way to express the lower
bound of an algorithm’s running time. It measures the best case or best
amount of time an algorithm can possible take to complete.

Algorithm Complexity

1. Time Complexity: The time complexity of an algorithm is not equal to the


actual time required to execute a particular code, but the number of times
a statement executes. The time complexity of an algorithm is denoted by
the big O Notation. Here, big O Notation is the asymptotic notation to
represent time complexity. The time complexity is mainly calculated by
counting the number of steps to finish execution.

sum = 0;
// suppose we have to calculate the sum of n numbers
for i = 1 to n
sum = sum + i;

Data and File Structures 5


// when the loop ends then sum holds the sum of n numbers
return sum;

In the above code, the time complexity of the loop statement will be atleast
n, and if value of n increases, then time complexity also increases. TC:
O(n)

// O(1)
int arr = [1,2,3,4,5];
print(arr[2]); // 3
------------------------
// O(log n)
void operation(int n){
for (int i = 1; i <= n; i *=2){ // doubles i in eac
h step
printf("%d ", i);
}
}
int main(){
operation(16); // output: 1 -> 2 -> 4 -> 8 -> 16
return 0;
}

Data and File Structures 6


------------------------
// O(n)
int fact = 1;
for (int i = 1; i <= n; i++){ // loops run n times
fact *= i;
}
------------------------
// O(nlogn): occurs in sorting algorithms like merge so
rt, quick sort, greedy algorithms
------------------------
// O(n^2)
for (int i = 0; i < n; i++) { // n times
for (int j = 0; j < n; j++) { // n times
printf("i=%d, j=%d\n", i, j);
}
}
------------------------
// O(n^3)
for (int i = 0; i < n; i++) { // n times
for (int j = 0; j < n; j++) { // n times
for (int k = 0; k < n; k++) { // n times
printf("i=%d, j=%d, k=%d\n", i, j, k);
}
}
}
------------------------
// O(2^n)
int fibonacci(int n) {
if (n <= 1) {
return n;
}
return fibonacci(n - 1) + fibonacci(n - 2); // Two
recursive calls (exponential growth)
}

Data and File Structures 7


------------------------
// O(n!): String -> All possible permutations

2. Space Complexity: It refers to the amount of memory space an algorithm


or program requires to solve a problem as a function of the input size. It is
a measure of the efficiency of an algorithm in terms of memory usage,
helping to understand how much additional memory is needed beyond the
input itself.

// input space: the memory required to store the input


data
// auxiliary space: the extra space used by the algorit
hm, excluding the input space. This includes temporary
variables, stack space, etc.
// Total Space Complexity: input space + auxiliary spac
e

Data and File Structures 8


Data and File Structures 9
Data and File Structures 10
Arrays

Data and File Structures 11


Data and File Structures 12
Data and File Structures 13
Data and File Structures 14
Data and File Structures 15
Data and File Structures 16
Data and File Structures 17

You might also like