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

CSE302: Data Structures Using C: DR Ashok Kumar Sahoo 9810226795

The document provides a syllabus for a course on Data Structures Using C. It covers key topics like arrays, stacks, queues, linked lists, trees, searching, hashing, sorting, binary search trees, and file structures. It also discusses concepts like algorithm complexity, asymptotic notation, and analysis of common algorithms like Fibonacci numbers. The course aims to teach students the mathematical and logical representation of data in computer memory using various data structures and algorithms.

Uploaded by

Priyanshu Dimri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views

CSE302: Data Structures Using C: DR Ashok Kumar Sahoo 9810226795

The document provides a syllabus for a course on Data Structures Using C. It covers key topics like arrays, stacks, queues, linked lists, trees, searching, hashing, sorting, binary search trees, and file structures. It also discusses concepts like algorithm complexity, asymptotic notation, and analysis of common algorithms like Fibonacci numbers. The course aims to teach students the mathematical and logical representation of data in computer memory using various data structures and algorithms.

Uploaded by

Priyanshu Dimri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

CSE302: Data Structures Using C

Dr Ashok Kumar Sahoo


[email protected]
9810226795
Syllabus Unit 1
• Introduction: Basic Terminology, Pointer and dynamic memory
allocation, Elementary Data Organization, Data Structure
operations
• Algorithm Complexity and Time-Space trade-off
• Arrays: Array Definition, Representation and Analysis, Single
and Multidimensional Arrays, address calculation, application of
arrays, Array as Parameters, Ordered List, Sparse Matrices.
• Stacks: Array. Representation and Implementation of stack,
Operations on Stacks: Push & Pop, Array Representation of
Stack, Linked Representation of Stack, Operations Associated
with Stacks, Application of stack: Conversion of Infix to Prefix
and Postfix Expressions, Evaluation of postfix expression using
stack.
• Recursion: Definition and processes, recursion in C, example of
recursion, Tower of Hanoi Problem, tail recursion.
Syllabus Unit 2
• Queues: Array and linked representation and
implementation of queues, Operations on Queue:
Create, Add, Delete, Full and Empty. Circular
queue, Dequeue, and Priority Queue.
• Linked list: Representation and Implementation of
Singly Linked Lists, Two-way Header List,
Traversing and Searching of Linked List, Overflow
and Underflow, Insertion and deletion to/from
Linked Lists, Insertion and deletion Algorithms,
Doubly linked list, Linked List in Array, Polynomial
representation and addition, Generalized linked
list.
Syllabus Unit 3
• Trees: Basic terminology, Binary Trees, Binary tree
representation, algebraic Expressions, Complete
Binary Tree. Extended Binary Trees, Array and
Linked Representation of Binary trees, Traversing
Binary trees, Threaded Binary trees. Traversing
Threaded Binary trees, Huffman algorithm &
Huffman tree.
• Searching and Hashing: Sequential search,
binary search, comparison and analysis, Hash
Table, Hash Functions, Collision Resolution
Strategies, Hash Table Implementation.
Syllabus Unit 4
• Sorting: Insertion Sort, Bubble Sorting,
Quick Sort, Two Way Merge Sort, Heap
Sort, Sorting on Different Keys, Practical
consideration for Internal Sorting.
• Binary Search Trees: Binary Search Tree
(BST), Insertion and Deletion in BST,
Complexity of Search Algorithm, Path
Length, AVL Trees.
Syllabus Unit 5
• File Structures: Physical Storage Media
File Organization, Organization of records
into Blocks, Sequential Files, Indexing and
Hashing, Primary indices, Secondary
indices, B+ Tree index Files, B Tree index
Files, Indexing and Hashing Comparisons,
Graph, Traversal(DFS,BFS), Minimum
spanning tree.
Text & Reference books
Textbooks :
1. Horowitz and Sahani, “Fundamentals of data Structures”, Galgotia
Publication Pvt. Ltd., New Delhi.
2. R. Kruse et al, “Data Structures and Program Design in C”, Pearson
Education Asia
3. A. M. Tenenbaum, “Data Structures using C & C++”, Prentice-Hall of India
Pvt. Ltd.
4. K Loudon, “Mastering Algorithms with C”, Shroff Publisher & Distributors Pvt.
Ltd.
5. Bruno R Preiss, “Data Structures and Algorithms with Object Oriented
Design Pattern in C++”, Jhon Wiley & Sons
6. Adam Drozdek, “Data Structures and Algorithms in C++”, Thomson Asia Pvt
Ltd
Data Structure

The mathematical and logical


representation of data in computer
memory is called a data structure.
Data Structure Operations
• Traversing
• Insertion
• Deletion
In addition
• Sorting
• Searching
• Merging
Data Structure Operations
• Traversing- It is used to access each data
item exactly once so that it can be
processed.
• Inserting- It is used to add a new data item
in the given collection of data items.
• Deleting- It is used to delete an existing
data item from the given collection of data
items.
Data Structure Operations
• Searching- It is used to find out the location
of the data item if it exists in the given
collection of data items.
• Sorting- It is used to arrange the data items
in some order i.e. in ascending or descending
order in case of numerical data and in
dictionary order in case of alphanumeric
data.
• Merging- It is used to combine the data
items of two sorted files into single file in
the sorted form.
Data Structures
• Array
• Linked List
• Stack
• Queue
• Graph
• Tree
• Heap
• File Structure
Algorithm
• Definition: An algorithm is a finite set of instructions that,
if followed, accomplishes a particular task. In addition, all
algorithms must satisfy the following criteria:
1) Input. Zero more quantities are externally supplied.
2) Output. At least one quantity is produced.
3) Definiteness. Each instruction is clear and
unambiguous.
4) Finiteness. If we trace out the instructions of an
algorithm, then for all cases, the algorithm terminates
after a finite number of steps.
5) Effectiveness. Every instruction must be basic enough to
be carried out, in principle, by a person using only pencil
and paper.
Recursive Algorithms

Recursive program:

int main()
{
int n=10;
printf(“%d”, rfib(n));
}
int rfib(int n)
{
if (n==1 || n==2) return 1;
return rfib(n1)+rfib(n2);
}
Performance Analysis
• Space Complexity: The space complexity
of a program is the amount of memory
it needs to run to completion.
• Time Complexity: The time complexity
of a program is the amount of computer
time it needs to run to completion.
Space Complexity
• A fixed part that is independent of the
characteristics of the inputs and outputs. This part
typically includes the instruction space, space for
simple variables and fixed-size component
variables, space for constants, etc.
• A variable part that consists of the space needed by
component variables whose size is dependent on the
particular problem instance being solved, the space
needed by referenced variables, and the recursion
stack space.
Time Complexity
• The time taken by a program is the sum
of the compile time and the run (or
execution) time.
• The compile time does not depend on the
instance characteristics.
• We focus only on the run time of a
program.
Fibonacci Numbers
• The Fibonacci sequence of numbers
starts as 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,
55, …
• Each new term is obtained by taking the
sum of the two previous terms. If we
call the first term of the sequence F0
then F0 = 0, F1 = 1, and in general,
• Fn = Fn-1 + Fn-2 , n ≥ 2.
C Program of Fibonacci Numbers
1. void fibonacci (int n)
2. // compute the Fibonacci number Fn
{
3. int fn; int fnm2 = 0; int fnm1 = 1;
4. if (n <= 1) printf(“%d\n”, n); // F0 = 0, and F1 = 1
5. else { // compute Fn
6. for (int i = 2; i <= n; i++)
7. {
8. fn = fnm1 + fnm2;
9. fnm2 = fnm1;
10. fnm1 = fn;
11. } // end of for
12. printf(“%d\n”, fn);
13. } // end of else
14. } // end of fibonacci
Step Count
Line # Execution times Remarks
1 Function invocation -
2 - Opening Bracket
3 One Initialization
4 Two n=0, n=1
5 n-1 Else
6 n-1 For loop
7 - Opening Bracket
8 n-1 fn = fnm1 + fnm2;

9 n-1 fnm2 = fnm1;

10 n-1 fnm1 = fn;


11 - Closing Bracket
12 One Printf statement
13 - Closing Bracket
Asymptotic Notation
• Determining step counts help us to
compare the time complexities of two
programs and to predict the growth in run
time as the instance characteristics
change.
• But determining exact step counts could
be very difficult. Since the notion of a step
count is itself inexact, it may be worth the
effort to compute the exact step counts.
• Definition [Big “oh”]: f(n) = O(g(n)) iff there
exist positive constants c and n0 such that
0 ≤ f(n) ≤ cg(n) for all n, n ≥ n0
Examples of Asymptotic Notation

• 3n + 2 = O(n)
3n + 2 ≤ 4n for all n ≥ 3
• 100n + 6 = O(n)
100n + 6 ≤ 101n for all n ≥ 10
• 10n2 + 4n + 2 = O(n2)
10n + 4n + 2 ≤ 11n for all n ≥ 5
2 2
[Big “oh”]

= n0
Asymptotic Notation (Cont.)

• Definition: [Omega] f(n) = Ω(g(n)) iff


there exist positive constants c and n0
such that f(n) ≥ cg(n) for all n, n ≥ n0.
• Example:
 3n + 2 = Ω(n)
 100n + 6 = Ω(n)
 10n2 + 4n + 2 =Ω(n2)
Asymptotic Notation (Cont.)

• Definition: Theta f(n) = Θ(g(n)) iff there


exist positive constants c1, c2, and n0
such that c1g(n) ≤ f(n) ≤ c2g(n) for all n,
n ≥ n0 .
Practical Complexities
• If a program P has complexities Θ(n) and
program Q has complexities Θ(n2), then,
in general, we can assume program P is
faster than Q for a sufficient large n.
• However, caution needs to be used on the
assertion of “sufficiently large”.
Function Values

log n n n log n n2 n3 2n
0 1 0 1 1 2

1 2 2 4 8 4

2 4 8 16 64 16

3 8 24 64 512 256

4 16 64 256 4096 65536

5 32 160 1024 32768 4294967296

You might also like