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

DSA - Week 1

The document outlines the Data Structures course (CSC-212) for the 3rd semester of BS in Computer Science, detailing course objectives, prerequisites, and assessment breakdown. It covers fundamental concepts of data structures, their operations, and the importance of using appropriate data structures for efficient programming. Additionally, it provides examples of various data structures and their operations such as insertion, deletion, searching, and sorting.

Uploaded by

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

DSA - Week 1

The document outlines the Data Structures course (CSC-212) for the 3rd semester of BS in Computer Science, detailing course objectives, prerequisites, and assessment breakdown. It covers fundamental concepts of data structures, their operations, and the importance of using appropriate data structures for efficient programming. Additionally, it provides examples of various data structures and their operations such as insertion, deletion, searching, and sorting.

Uploaded by

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

DATA STRUCTURE

(COURSE CODE: CSC-212)

Week 1
(Lecture 1 – 3)
BS(Computer Science)
3rd Semester
Lecturer: Mah Gul Bizanjo
[email protected]
Computer Systems Engineering & Sciences Department
LECTURE OUTLINE
Course Learning outcome
Course Details
Introduction to Data Structure
Why Do We Study DSA?
Illustration of DS
Data Structure Operations
Examples and Applications
COURSE LEARNING OUTCOMES
(THEORY + PRACTICAL)

Source: Higher Education Commission Pakistan. (2023). Revised curriculum of Higher Education Pakistan
2023 https://nceac.org.pk/Documents/Curriculums/BS%20Curriculm%20Computing%20Disciplines-2023.pdf
COURSE DETAILS
▪ Course Title: Data Structures
▪ Pre-requisites: Programming Fundamentals
▪ Course Code: CSC-212
▪ Semester: 3rd BS(Computer Science)
▪ Credit Hours (Theory): 03
▪ Lab Credit Hours (Lab) : 01
▪ Total Credit Hours : 3+1 = 04
MARKS BREAKDOWN

Mid-Term Final Term Sessional Practical Total

20 Marks 50 Marks 10 Marks 20 Marks 100 Marks


Data structure is the way of
organizing data in the computer
memory (cache, main, secondary)
so that the computer memory can
be used efficiently in terms of both
time and space.
Some Examples of Data Structures are:
▪ Array / List
▪ Linked List DATA STRUCTURE
▪ Tree
▪ Graph
▪ Stack
▪ Queue

**Note: A combination of different data structures


can be used to form a hybrid data structure, which
can better organize the storage of a system as per
user need.
WHY DO WE STUDY DATA STRUCTURES?
• The ultimate goal of studying data structures is to create most efficient technology to
solve a problem.
• For software development, it begins with developing a best algorithm.
• Then by using the best data structures and applying the code instructions (algorithm)
over it, we can convert it in to the most efficient program.
Data Structure + Algorithm = Program

The goal is not to code only, but the goal is to code efficiently
Efficiency of a program:
✓ A program which takes least time to execute
✓ Which occupies minimum memory
✓ How much battery consumption it has?
✓ How much use of system buses ? etc.
ILLUSTRATION OF
DATA STRUCTURES
▪ For building a home you need
certain building blocks, wooden
planks and other raw material. On
the top of that you apply building
instructions and you get a home.
▪ Similarly, to build a software, you
need raw building blocks (Data
Structures) like array, linked list
graphs. On the top of that you
apply code instructions, which
operates on those data structures
and as result you get a software
application.
To be a good programmer, it’s a
compulsion to have a good
understanding of DS.
To build a window, you need
wooden planks but not bricks.
Similarly for a particular
program requirement, you need
the right type of data structure.
“USE THE RIGHT DATA
STRUCTURE FOR THE RIGHT
PROBLEM”
DATA STRUCTURE SPECIFIES
THE FOLLOWING FOUR THINGS:
1. Organization of data
2. Accessing methods of data
3. Degree of association
4. Processing methods
DATA STRUCTURE OPERATION
▪ The data appearing in our data structures are processed by means of
certain operations.
▪ There are multiple kinds of operations, among them most common
are given below basic operations:

1. Data Traversal
2. Data Searching
3. Data Insertion
4. Data Deletion
5. Data Sorting
6. Data Merging
7. Data Indexing
8. Concatenation
9. Finding Length
10. Etc.
DATA TRAVERSAL
Accessing or visiting each element of a data structure is called data traversal.

Purpose: Data traversal operation ensures that every item or element is visited,
enabling operations like searching, sorting, or modifying/updating data.

Example: 0 1 2 3

A 10 20 30 40

Find the SUM of all elements of array A.


Answer = 100
DATA INSERTION/ADDITION
Adding a new element into a data structure is called data insertion. Every
data structure has a different process of data insertion.
Example: 0 1 2 3

A 10 20 30 40

INSERT 55 at index 2 of Array A


0 1 2 3 4

A 10 20 55 30 40
DATA DELETION
Removing or erasing an element from a data structure is called data
deletion
Example: 0 1 2 3

A 10 20 30 40

DELETE the data element from index 2 of Array A

0 1 2

10 20 40
A
DATA SEARCHING
Finding the location of the desired node with a given key value, is called
data searching.

Example: 0 1 2 3

A 10 20 30 40

SEARCH the Value of A[2] in Array A?


Answer = 30
DATA SORTING
Arranging of data elements in a particular order, specifically in ascending
or descending order is called data sorting.
There are various algorithms for data sorting e.g. bubble sort, selection
sort, merge sort, quick sort etc.
Example:

0 1 2 3
Unsorted Array/List : A 60 80 10 50

0 1 2 3
Sorted Array/List: 10 50 60 80
A
(Ascending order)
DATA MERGING
Combining two or more datasets of same type together into a single
unified data structure is called merging operation.
Two sorted arrays can be merged into a single sorted array using a two-
pointer approach.
Example:
A 10 20 30 40 B 60 50 70 80

0 1 2 3 0 1 2 3

MERGE array A and B into a single Array C


0 1 2 3 4 5 6 7

C 10 20 30 40 50 60 70 80
REVIEW STRINGS

I am reading alphabets I am reading words


In computer programming In computer programming
single alphabets are known words are known as string
as character
▪ Finite sequence of zero or
more character is called string.
▪ The string with zero character
is called empty string or null
string.
▪ String denoted by enclosing
their characters in double or
STRING AND
single quotation (“ ” , ‘ ‘) OPERATION
marks.
▪ String operations:
✓ Length of String
✓ Substring
✓ Data Indexing
✓ Data Concatenation
FINDING THE LENGTH OF STRING
The number of characters in a string is called the length of string.
Formula: Length(“string”)

Example:
Length(“BUETK”)
Answer = 5

Length(“BALOCHISTAN”)
Answer = ?
Answer = 11
String

SUBSTRING
A substring is a small part of a string. It
can be accessed from a given string, by
using the substring operation.
Formula:
SUBSTRING=(string, initial position,
length)

Example:
Str = “diversification”
Substring(Str, 4, 9)
Answer = ? Sub Strings
DATA INDEXING
Finding the position of a substring in a sting is called data indexing. It locates the
starting position of the substring first, then locates the complete substring
concatenated with it.
Just like a book-index helps locate topics quickly,
Formula: INDEX(Text, Pattern) string indexing helps access characters efficiently
in programming

Example:
String1 = “University”
Find the index of substring “sity”

Solution:
INDEX (String1, “sity”)
Returned value = 7
DATA CONCATENATION
Joining two or more strings (or other
data structures), together, end-to-
end, without altering their internal
order, is called concatenation. It is
primarily used in strings.

Example:
String1 = “Happy”
String2 = “Learning”
Result= “HappyLearning”
CLASS TASK
Suppose T is the Text: “WeAreGoodStudents”,
Apply the following String operations on T.

1. SUBSTRING(T,1,4) = ?

2. LENGTH(SUBSTRING(T,1,4)) = ?

3.INDEX(T,”Good”) ?
EXAMPLE
A company contains employee file in
which each record contain the data for
a given employee. [Name, Address,
age, gender]. Write the operation
name for the following statement.
▪ Suppose a new person joins the
company.
▪ Suppose an employee dies.
▪ Suppose the company wants to
announce bonus for employees
greater than 40 years old.
THANK YOU

Lecturer:
Mah Gul Bizanjo
[email protected]

You might also like