0% found this document useful (0 votes)
65 views10 pages

Subject Name: Data Structure II Subject Code: CS-3004 Semester: 3

This document provides an introduction to the subject of Data Structure II. It discusses key concepts like data types, data representation, data structures, common operations on data structures, and different types of data structures. It also discusses how data structures and programming are related, and outlines the standard process of program design involving defining components, data structures, and control structures.

Uploaded by

Quantico Smith
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
65 views10 pages

Subject Name: Data Structure II Subject Code: CS-3004 Semester: 3

This document provides an introduction to the subject of Data Structure II. It discusses key concepts like data types, data representation, data structures, common operations on data structures, and different types of data structures. It also discusses how data structures and programming are related, and outlines the standard process of program design involving defining components, data structures, and control structures.

Uploaded by

Quantico Smith
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 10

Subject Name: Data Structure II

Subject Code: CS-3004


Semester: 3rd
Downloaded from be.rgpvnotes.in

Data Structure-2 Lecture Notes

Unit -1

INTRODUCTION:
Computer Science is the study of data, its representation and transformation by
Computer. For every data object, we consider the class of operations to be performed and then the
way to represent the object so that these operations may be efficiently carried out. We require two
techniques for this:
- Devise alternative forms of data representation
- Analyse the algorithm which operates on the structure.

These are several terms involved above which we need to know carefully before we
proceed. These include data structure, data type and data representation.

A data type is a term which refers to the kinds of data that variables may hold. With every
programming language there is a set of built-in data types. This means that the language allows
variables to name data of that type and provides a set of operations which meaningfully manipulates
these variables. Some data types are easy to provide because they are built-i i to the o puter s
machine language instruction set, such as integer, character etc. Other data types require
considerably more efficient to implement. In some languages, these are features which allow one to
construct combinations of the built-in types like stru tures i C . Ho e er, it is e essar to ha e
such mechanism to create the new complex data types which are not provided by the programming
language. The new type also must be meaningful for manipulations. Such meaningful data types are
referred as abstract data type.

DATA STRUCTURE:
Data Structures are the programmatic way of storing data so that data can be used efficiently.
Almost every enterprise application uses various types of data structures in one or the other way.
Thus, a data structure is the portion of memory allotted for a model, in which the required data can
be arranged in a proper fashion.

OPERATION ON DATA STRUCTURES:

The four major operations performed on data structures are:


(i) Insertion : - Insertion means adding new details or new node into the data structure.
(ii) Deletion : - Deletion means removing a node from the data structure.
(iii) Traversal : - Traversing means accessing each node exactly once so that the nodes of a
data structure can be processed. Traversing is also called as visiting.
(iv) Searching : - Searching means finding the location of node for a given key value.

Apart from the four operations mentioned above, there are two more operations occasionally
performed on data structures. They are:
(a) Sorting :- Sorting means arranging the data in a particular order.
(b) Merging : - Merging means joining two lists.

Page no: 1 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

TYPES OF DATA STRUCTURES: -

Figure: 1.1 Type of Data Structure

A data structure can be broadly classified into (i) Built-in/Primitive data structure
(ii) User Defined/Non-primitive data structure

(i) Primitive data structure


The data structures, typically those data structure that are directly operated upon by machine
level instructions i.e. the fundamental data types such as int, float, double in ase of are k o as
primitive data structures.

(ii) Non-primitive data structure


The data structures, which are not primitive, are called non-primitive data structures.
There are two types of non-primitive data structures.
(a) Linear Data Structures:-
A list, which shows the relationship of adjacency between elements, is said to
be linear data structure. The most, simplest linear data structure is a 1-D array, but
because of its deficiency, list is frequently used for different kinds of data.
(b) Non-linear data structure:-
A list, hi h does t show the relationship of adjacency between elements, is
said to be non-linear data structure.

Linear Data Structure:

A list is an ordered list, which consists of different data items connected by means of a link or
pointer. This type of list is also called a linked list. A linked list may be a single list or double linked
list.

Page no: 2 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

 Single linked list: - A single linked list is used to traverse among the nodes in one


direction.
Double linked list: - A double linked list is used to traverse among the nodes in both the
directions.

A linked list is normally used to represent any data used in word-processing applications, also
applied in different DBMS packages.

 Stack: - It is also called as last-in-first-out (LIFO) system. It is a linear list in which insertion
A list has two subsets. They are: -

 Queue: - It is also called as first-in-first-out (FIFO) system. It is a linear list in which


and deletion take place only at one end. It is used to evaluate different expressions.

insertion takes place at once end and deletion takes place at other end. It is generally
used to schedule a job in operating systems and networks.

Non-linear data structure:-


The frequently used non-linear data structures are
(a) Trees : - It maintains hierarchical relationship between various elements
(b) Graphs : - It maintains random relationship or point-to-point relationship between
various elements.
The data structures can also be classified on the basis of the following characteristics:

Characterstic Description

Linear In Linear data structures,the data items are arranged in a linear sequence.
Example: Array

Non-Linear In Non-Linear data structures,the data items are not in sequence. Example: Tree, Graph

Homogeneous In homogeneous data structures,all the elements are of same type. Example: Array

Non- In Non-Homogeneous data structure, the elements may or may not be of the same type.
Homogeneous Example: Structures

Static Static data structures are those whose sizes and structures associated memory locations
are fixed, at compile time. Example: Array

Page no: 3 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

Dynamic Dynamic structures are those which expands or shrinks depending upon the program
need and its execution. Also, their associated memory locations changes.
Example: Linked List created using pointers

DATA STRUCTURES AND PROGRAMMING:


Data Structure: Data Structure is a way of collecting and organising data in such a way that we can
perform operations on these data in an effective way. Data Structures is about rendering data
elements in terms of some relationship, for better organization and storage. For example, we
have data player's name "Virat" and age 26. Here "Virat" is of String data type and 26 is
of integer data type.
Programming: Programming is the process of taking an algorithm and encoding it into a notation, a
programming language, so that it can be executed by a computer. Although many
programming languages and many different types of computers exist, the important first step
is the need to have the solution. Without an algorithm there can be no program.Computer
science is not the study of programming. Programming, however, is an important part of what
a computer scientist does. Programming is often the way that we create a representation for
our solutions. Therefore, this language representation and the process of creating it becomes
a fundamental part of the discipline.

PROGRAM DESIGN:

Every computer program is built from components, data, and control. For a single-user application
(used by one person at a time), which normally reads data, saves it in a data structure, computes on
the data, and writes the results, there is a standard way of organizing the component structure, data
structure, and control structure:

1. First, design the program's component structure with three components, organized in
a model-view-controller pattern.
2. Next, decide what form of data structure (array, table, set, list, tree, etc.) will hold the
program's data. The data structure will be inserted in the program's model component.
3. Then, write the algorithm that defines the execution steps- the control structure. The
algorithm will be placed inside the program's controller.
4. Determine the form of input and output (disk file, typed text in a command window, dialogs,
a graphical-use interface, etc.) that the program uses. This will be embedded in the
program's view.

Good, logical programming is developed through good pre-code planning and organization. This is
assisted by the use of pseudocode and program flowcharts.1)Pseudo Code 2)Flow Chart
1)Pseudo Code: Consists of natural language-like statements that precisely describe the steps
of an algorithm or program.
 Statements describe actions
 Focuses on the logic of the algorithm or program.
 Avoids language-specific elements.

Page no: 4 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

 Written at a level so that the desired programming code can be generated almost
automatically from each statement.
 Steps are numbered. Subordinate numbers and/or indentation are used for dependent
statements in selection and repetition structures
 Example:

Input: An integer Limit


Ouput: Two integers: Number and Sum

1. Enter Limit
2. Set Number = 0.
3. Set Sum = 0.
4. Repeat the following:
a. If Sum > Limit, terminate the repitition, otherwise.
b. Increment Number by one.
c. Add Number to Sum and set equal to Sum.
5. Print Number and Sum.

2)Flow Chart:. Flowcharts are written with program flow from the top of a page to the bottom. Each
command is placed in a box of the appropriate shape, and arrows are used to direct program flow.
The following shapes are often used in flowcharts:

Figure: 1.2 Flowchart Symbols

Page no: 5 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

COMPLEXITIES:

In computer science, the time complexity of an algorithm quantifies the amount of time taken by
an algorithm to run as a function of the length of the string representing the input. The
time complexity of an algorithm is commonly expressed using big O notation, which excludes
coefficients and lower order terms.Complexities can be mesaure in 2 ways, space and time.

There may be many algorithms devised for an application and we must analyse and validate
the algorithms to judge the suitable one.

To judge an algorithm the most important factors is to have a direct relationship to the
performance of the algorithm. These have to do with their computing time & storage requirements (
referred as Time complexity & Space complexity).

Space Complexity:
The space complexity of an algorithm is the amount of memory it needs to run.

Time Complexity:
The time taken by a program is the sum of the compiled time & the run time. The time complexity of
an algorithm is given by the number of steps taken by the algorithm to compute the function it was
written for.

Algorithm : a procedure for solving a mathematical problem in a finite number of steps that
frequently involves repetition of an operation; broadly : a step-by-step procedure for solving a
problem or accomplishing some end especially by a computer.

TIME COMPLEXITY:

In computer science, the time complexity of an algorithm quantifies the amount of time taken by an
algorithm to run as a function of the length of the string representing the input. The time
complexity of an algorithm is commonly expressed using big O notation, which excludes coefficients
and lower order terms.
Time complexity is expressed via Asymptotic Notations.

ORDER OF GROWTH:

Order of growth in algorithm means how the time for computation increases when you increase the
input size. It really matters when your input size is very large.
Order of growth provides a useful indication of how we may expect the behavior of the process to
change as we change the size of the problem. Depending on the algorithm, the behaviour changes.
So, this is one of the most important things that we have to care when we design an algorithm for
some given problem.
There are different notations to measure it and the most important one is Big O which gives you the
worst case time complexity.

Page no: 6 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

Figure: 1.3 Order of Growth Table

ASYMPTOTIC NOTATIONS:

Following are the commonly used asymptotic notations to calculate the running time complexity of
an algorithm.
a Ο Notatio
Ω Notatio
θ Notatio

Big Oh Notatio , Ο
The otatio Ο is the for al a to e press the upper ou d of a algorith 's ru i g ti e. It
measures the worst case time complexity or the longest amount of time an algorithm can possibly
take to complete.

Figure: 1.4 Big Oh Notation


For example, for a function f(n)
Οf = { g : there e ists > a d su h that f .g for all > .}

Page no: 7 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

O ega Notatio , Ω
The otatio Ω is the for al a to e press the lo er ou d of a algorith 's ru i g ti e. It
measures the best case time complexity or the best amount of time an algorithm can possibly take to
complete.

Figure: 1.5 Omega Notation


For example, for a functionf(n)
Ωf { g : there e ists > a d su h that g .f for all > .}

Theta Notatio , θ
The otatio θ is the for al a to e press oth the lo er ou d a d the upper ou d of a
algorithm's running time. It is represented as follo s −

Figure: 1.6 Theta Notation


θf ={g if a d o l if g = Οf a dg =Ω f for all > .}

Page no: 8 Follow us on facebook to get real-time updates from RGPV


We hope you find these notes useful.
You can get previous year question papers at
https://qp.rgpvnotes.in .

If you have any queries or you want to submit your


study notes please write us at
rgpvnotes.in@gmail.com

You might also like