Académique Documents
Professionnel Documents
Culture Documents
1 | Basics of Data
Structure
Aim
To learn basic characteristics of
standard data structures and
learn algorithms used by those
data structures
Instructional
Objectives
Objectives of this chapter are:
Explain the role of Data Structures in
Computer Science.
Describe the different types and
classification of Data Structures and the
concept of Elementary Data Organization.
Explain the concept of Time and Space
Complexity of an algorithm.
Describe the different memory allocation
techniques.
How to access the address of a variable?
3
Quiz/Assessment
1) What are the characteristics of data
structures which differ them from others?
2) Why dynamic data structures such as linked
lists are preferred over static array-based
data structures?
3) Linear data structures are the ones in which
elements are not arranged sequentially.
a) True
b) False
7
10
12
13
Quiz/Assessment
4) Differentiate between linear data structures and
non-linear data structures.
5) Graphs maintains random relationship or point-topoint relationship between various elements.
a) True
b) False
6) Stack is a _____ system whereas a queue is a _____
system.
a)
b)
c)
d)
Elementary Data
Organization
15
Elementary Data
Organization
Data
Data item
Entity
Entity Set
Information
Field
Record
File
Key
16
17
18
19
20
21
22
23
Quiz/Assessment
7) Define space complexity and time complexity
with respect to algorithms.
8) Name the three asymptotic notations that are
used to represent time complexity of
algorithms.
9) When determining the efficiency of algorithm
the time factor is measured by
a) Counting microseconds
b) Counting the number of key operations
c) Counting the number of statements
d) Counting the kilobytes of algorithm
24
String Processing
25
String Processing
Commonly used string handling
functions are:
Strlen()
Strcpy()
Strcat()
Strcmp()
Strlwr()
Strupr()
26
Memory Allocation
27
Memory Allocation
Memory allocation has two core types:
1. Static Memory Allocation
2. Dynamic Memory Allocation
28
Memory Allocation
Static Memory Allocation
Dynamic Memory Allocation
29
Memory Allocation
Dynamic Memory Allocation
Dynamic memory allocation is when an
executing program requests that the operating
system give it a block of main memory.
It enables us to create data types and
structures of any size and length to suit our
programs need within the program.
Memory Fragmentation occurs when small
holes of memory are formed which cannot be
used to fulfil the dynamic requests.
30
Quiz/Assessment
10)What is string processing? List some string
handling functions.
11)State and explain how memory allocation
takes during program execution.
12)List and explain the advantages and
disadvantages of static memory allocation
and dynamic memory allocation.
13)Explain how the situation of memory
fragmentation arises in memory allocation.
31
32
33
Quiz/Assessment
14) Consider the following code
fragment:
1-> myvar = 35;
2-> foo = &myvar;
3-> bar = myvar;
Explain the significance of & operator in
line 2 of the code fragment and also
explain what happens in line 1 and line
3 of the code fragment when compared
with line 2 of the code fragment.
34
Quiz/Assessment
15)What is the role of & operator
in C?
16)What are pointers in C?
35
Activity
Description:
Divide the students into two
groups. Given selection sort
algorithm and insertion sort
algorithm to each of the
groups, students should
calculate time complexities for
both these algorithms.
36
Summary
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 are categorized into two types:
linear and nonlinear.
Linear data structures are the ones in which elements are
arranged in a sequence, nonlinear data structures are the
ones in which elements are not arranged sequentially.
37
E-References
Introduction to data structures
https://www.youtube.com/watch?
v=92S4zgXN17o&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P
Data Structures: List as abstract data type
https://www.youtube.com/watch?
v=HdFG8L1sajw&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P&index=2
Data Structures: Arrays vs Linked Lists
https://www.youtube.com/watch?
v=lCyYCOnN8Q&index=4&list=PL2_aWCzGMAwI3W_JlcBbtYTwiQSsOTa6P
Introduction to asymptotic notations
https://www.youtube.com/watch?
v=aGjL7YXI31Q&list=PLEbnTDJUr_IeHYw_sfBOJ6gk5pie0yP-0
38
E-References
Time complexity Analysis of iterative programs
https://www.youtube.com/watch?
v=FEnwMiDb2g&list=PLEbnTDJUr_IeHYw_sfBOJ6gk5pie0yP-0&index=2
Time analysis of recursive program
https://www.youtube.com/watch?
v=gCsfk2ei2R8&index=3&list=PLEbnTDJUr_IeHYw_sfBOJ6gk5pie0yP-0
Analysing Space complexity of iterative and recursive algorithms
https://www.youtube.com/watch?
v=HEjmH9wKiMo&list=PLEbnTDJUr_IeHYw_sfBOJ6gk5pie0yP-0&index=6
Memory Allocation
https://www.youtube.com/watch?v=Dml54J3Kwm4
https://www.cs.utexas.edu/users/djimenez/utsa/cs1723/lecture2.html
http://www.compsci.hunter.cuny.edu/~sweiss/resources/cstrings.pdf
39
External Resources
Data Structures and program
designing using C by Robert Kruse.
Data Structures and Algorithm
Analysis in C by Wiess
Data structures in C by D. Srivastava
40