INSTITUTE:CHANDIGARH UNIVERSUITY
DEPARTMENT: UIC
Bachelor of Computer Application
Subject Name: Data Structure
Code:CAT-201
Data structure and Algorithm DISCOVER . LEARN . EMPOWER
Font size 24
SCHEME
Bachelor of Computer Applications Semester – III (2018-21)
Subject Code Title L T P S Credits
CAT-201 Data Structures 3 0 0 - 3
CAT-202 Database Management System 3 0 0 - 3
CAT-208 Probability & Statistics 3 1 0 - 4
CAT-209 System Software & Operating System 3 0 0 - 3
UCT-249 Introduction to Artificial Intelligence 1 0 0 - 1
TDP-205 Soft Skills 0 0 1 - 1
CAP-206 Data Structures Lab 0 0 4 - 2
CAP-207 Database Management System Lab 0 0 4 - 2
CAY-211 Summer Training/Institutional Training 0 0 0 - 3*
UCY-241 Social and Professional Ethics 2 0 0 - 2*
UCY- 247 Gender Equality and Woman 2 0 0 - 2*
Empowerment
Total 19
2
SYLLABUS
DATA STRUCTURES L T P C
Total Contact Hours:45
CAT- 201 Applicable to which 3 0 0 3
branch: BCA
Prerequisite: Knowledge of Programming in C
Marks
Internal: 40 External: 60
Course Objective
To learn the systematic way of solving problems.
To introduce various techniques for representation of the data in the real world
To efficiently implement solutions for specific problems.
Unit Course Outcome
Student will be able to apply appropriate constructs of Programming language, coding standards for application
1.
development
2. Students will learn to Select and use appropriate data structures for problem solving and programming.
To implement Trees, Graphs and Select appropriate searching and/or sorting techniques for application development
3.
3
SYLLABUS
Unit-I
Introduction: Pointers and Dynamic memory allocation, Types of data structures, Mathematical
notation and functions.
Algorithm Analysis: Space Complexity, Time Complexity, Asymptotic Notation and Algorithmic
complexity. Abstract Data Type.
Arrays & Structure: Linear Search, Binary Search (Recursive & iterative, Evaluation of
Polynomial, Polynomial representation, Polynomial Addition).
Structures: Internal representation of structure, Self –referential structure
4
SYLLABUS
Unit-II
Stack: Memory Representation of Stacks via arrays and Linked List, Stack Operations, Application
of Stack.
Evaluation of Expression: Evaluation of postfix expression, Infix to postfix and prefix forms for
expressions.
Queue: Representation using array and linked List, Queue Operations, Types of queues,
Applications of queue.
Linked List: Representation of linked list, linked list operations (Create, Insertion, Printing,
Deleting and Traversing), Circular Linked List, Double linked list.
5
SYLLABUS
Unit-III
Trees: Definition, Terminology, Representation, Binary tree: Representation and its types, Traversal
(In-order, Pre-order, Post-order). Binary Search Tree, Heap, AVL/Height Balanced Tree
Graphs: Representation of Graphs, Adjacency Matrix and List, In degree, out degree of graph.
Graph operation: Depth First Search and Breath First Search.
Sorting: Bubble sort, Selection sort, Insertion sort, Quick Sort and Merge Sort
6
Course Outcome
CO Number Title Level
Algorithm CO1 Explain the algorithm and it’s terms related to array Understand
analysis CO2 Explain the basic concepts of searching Understand
CO3 Explain the different types of Linear Data structure Understand
CO4 Explain the stack data structure Understand
CO5 Analyse the algorithms Understand
7
DATA STRUCTURE
Data Structure
• A data structure is an arrangement of data in a computer's memory or even disk storage.
• The logical and mathematical model of a particular organization of data is called a data structure.
• A data structure is a particular way of storing and organizing data in a computer so that it can be
used efficiently.
An example of several common data structures:
• arrays,
• linked lists,
• stacks,
• queues,
• trees,
• and Graph
8
DATA STRUCTURE(ARRAY)
Linear array (One dimensional array) : A list of finite number n of similar data elements
referenced respectively by a set of n consecutive numbers, usually 1, 2, 3,…..n. That is a specific
element is accessed by an index.
• Let, Array name is A then the elements of A is : a1,a2….. an
• Or by the bracket notation A[1], A[2], A[3],…………., A[n]
• The number k in A[k] is called a subscript and A[k] is called a subscripted variable.
9
DATA STRUCTURE(ARRAY)
Two dimensional array)
• Two dimensional array is a collection of similar data elements where each element is referenced
by two subscripts.
• Such arrays are called matrices in mathematics and tables in business applications.
2.Multidimensional arrays are defined analogously
10
Array Data Structure
• It can hold multiple values of a single type.
• Elements are referenced by the array name and an ordinal index.
• Each element is a value
• Indexing begins at zero.
• The array forms a contiguous list in memory.
• The name of the array holds the address of the first array element.
• We specify the array size at compile time, often with a named constant.
11
DATA STRUCTURE (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.
• Dynamically allocate space for each element as needed.
Reference: http://www.studytonight.com/data-structures/introduction-to-linked-list
12
DATA STRUCTURE (STACK)
• Stacks are a special form of collection
with LIFO semantics
• Two methods
- add item to the top of the stack
- remove an item from the top of the stack
• Like a plate stacker
Fig 2 stack
Reference:http://www.studytonight.com/data-
structures/stack-data-structure
13
DATA STRUCTURE (QUEUE)
Like a stack, a queue is also a list. However,
with a queue, insertion is done at one end,
while deletion is performed at the other end
• The insertion end is called rear
• The deletion end is called front
Fig 3 queue
Reference: http://www.studytonight.com/data-
structures/queue-data-structure
14
DATA STRUCTURE(TREE)
• Tree is a non-linear data structure which
organizes data in hierarchical structure and
this is a recursive definition.
• Tree data structure is a collection of data
(Node) which is organized in hierarchical
structure and this is a
Reference: http://btechsmartclass.com/DS/U3_T1.html
15
DATA STRUCTURE(GRAPH)
• Graph is a collection of vertices and arcs
which connects vertices in the graph is a
collection of nodes and edges which connects
nodes in the graph
• Generally, a graph G is represented as G = ( V
, E ), where V is set of vertices and E is set of
edges.
Fig 5 graph
Reference: http://btechsmartclass.com/DS/U3_T8.html
16
Algorithm
Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a certain
order to get the desired output. Algorithms are generally created independent of underlying
languages, i.e. an algorithm can be implemented in more than one programming language.
• From the data structure point of view, following are some important categories of algorithms
−
• Search − Algorithm to search an item in a data structure.
• Sort − Algorithm to sort items in a certain order.
• Insert − Algorithm to insert item in a data structure.
• Update − Algorithm to update an existing item in a data structure.
• Delete − Algorithm to delete an existing item from a data structure.
17
Algorithmic Notation
The format for the formal presentation of an algorithm consists of two parts. The first part is a
paragraph which tells the purpose of the algorithm, identifies the variables which occur in the
algorithm and lists the input data. The second part of the algorithm consists of the lists of steps that
is to be executed.
Example : A nonempty array DATA with N numerical values is given. Find the location LOC and
the value MAX of the largest element of DATA.
18
Algorithmic Notation
Algorithm 2.3: Given a nonempty array DATA with N numerical values, this algorithm finds the
location LOC and the value MAX of the largest element of DATA.
1. Set K : = 1, LOC : =1 and MAX : =DATA[1].
2. Repeat steps 3 and 4 while K<=N:
3. If MAX<DATA[K], then :
Set LOC : =K and MAX : =DATA[K].
[End of if structure]
4. Set K : = K+1.
5. Write: LOC, MAX.
6. Exit.
19
Algorithmic Notation
Steps, Control, Exit :
• The steps of the algorithm are executed one after the other, beginning with step 1.
• Control may be transferred to step n by Go to step n
• If several statements appear in the same step, e. g.
Set K : = 1, LOC : =1 and MAX : =DATA[1].
• Then they are executed from left to right.
• The algorithm is completed when the statement Exit Is encountered.
Comments :
• Step may contain a comment in brackets which indicates the main purpose of the step.
20
Algorithmic Notation
Variable names :
• Will use capital letters, as in MAX and DATA
• Counters and subscripts will also be capitalized (K, N)
• Assignment Statement :
• Will use the dots-equal notation : =MAX : =DATA[1]
• Assigns the value in DATA[1] in MAX.
• Input and Output :
• Data may be input and assigned to variables by means of a read statement and Read: Variable
names.
• Messages placed in quotation marks and Data in variables may be output by Write or print
statement.
• Write : Messages and/ or Variable names.
21
Complexity of Algorithm
The complexity of an algorithm is a function describing the efficiency of the algorithm in terms of
the amount of data the algorithm must process. There are two main complexity measures of the
efficiency of an algorithm:
• Time complexity is a function describing the amount of time an algorithm takes in terms of the
amount of input to the algorithm. "Time" can mean the number of memory accesses performed,
the number of comparisons between integers, the number of times some inner loop is executed, or
some other natural unit related to the amount of real time the algorithm will take.
• Space complexity is a function describing the amount of memory (space) an algorithm takes in
terms of the amount of input to the algorithm. We often speak of "extra" memory needed, not
counting the memory needed to store the input itself.
22
Complexity of Algorithm
• Suppose M is an algorithm, n size of the input data. The time and space used by the algorithm M
are the two main measures for the efficiency of M.
• The time is measured by counting the number of key operations – in sorting and searching
algorithms, for example the number of comparisons.
• The space is measured by counting the maximum of memory needed by the algorithm.
• The complexity of an algorithm M is the function f(n) which gives the running time and or storage
space requirement of the algorithm in terms of the size n of the input data. Frequently, the storage
space required by an algorithm is simply a multiple of the data size n.
23
DATA STRUCTURE APPLICATIONS
• In Computer science graphs are used to represent the flow of computation.
• Google maps uses graphs for building transportation systems, where intersection of two(or more)
roads are considered to be a vertex and the road connecting two vertices is considered to be an
edge, thus their navigation system is based on the algorithm to calculate the shortest path between
two vertices.
• In Facebook, users are considered to be the vertices and if they are friends then there is an edge
running between them. Facebook’s Friend suggestion algorithm uses graph theory.
• In Operating System, we come across the Resource Allocation Graph where each process and
resources are considered to be vertices. Edges are drawn from resources to the allocated process,
or from requesting process to the requested resource. If this leads to any formation of a cycle then
a deadlock will occur.
24
REFERENCES
Reference Books:
• Seymour Lipschutz, Schaum's Outlines Series Data structures TMH
• Introduction to Data Structures Applications, Trembley&Soreson, Second Edition, Pearson
Education
Reference websites:
• http://btechsmartclass.com/DS/U1_T9.html
• https://www.studytonight.com/data-structures/introduction-to-data-structures
• https://www.edx.org/course/implementation-of-data-structures
• http://www.xpode.com/ShowArticle.aspx?ArticleId=87
• www.geeksforgeeks.org/analysis-of-algorithms-set-3asymptotic-notations/
• www.tutorialspoint.com/data_structures_algorithms/asymptotic_analysis.htm
25
THANK YOU
For queries
Email: [email protected]