Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
CS-212 Data Structure and Algorithms BI – 3 2016CS-201 Data Structure and Algorithms BI – 3 -2016
Data Structure and Algorithms
RAMSHA SOHAIL
Lecturer,
Department of CS/IT
SSUET
Contact:
https://ramshasohail.wordpress.com/
Lecture # 1 - Introduction
CS-212 Data Structure and Algorithms BI – 3 2016
Your Responsibilities2
As a Student
Attend classes regularly – No Attendance shortage issue
Ask questions if you have any queries regarding course material or anything
Submit assignments in time
Don’t miss quizzes, assignments, mid term and final examinations – Can get
good result
No Plagiarism is allowed in any sort of a written material – Write in
your own words
CS-212 Data Structure and Algorithms BI – 3 2016
Course Policy3
Assignments Assignments are due at the beginning of class
Late assignments will not be accepted
All works have to be done independently except in case of group assignments
Students handing in similar assignments will receive a grade of 0 (ZERO) and face
possible disciplinary actions
Makeup Exams In accordance with university regulations, i.e. students should bring a valid excuse
authenticated through valid channels immediately within first week after the exam
Otherwise they will be considered absent and no makeup exam for them
Mobile Phones Cell phones are restricted during class. Cell phones must be turned off during the
lecture. If your cell phone rings during the class, you may be asked to leave
CS-212 Data Structure and Algorithms BI – 3 2016
Course Policy4
Attendance Students are expected to attend all classes
If a student misses 3 sessions from class or 10 hours in total without an acceptable
reason, the student will be barred from the final exams
Code of Conduct The assignments, quizzes and exams need to be done individually. Copying of
another student's work or code, even if changes are subsequently made, is
inappropriate, and such work or code will not be accepted
The University has very clear guidelines for academic misconduct, and they will be
enforced in this class
However, in case of group assignments, copying of another group’s work or code,
even if changes are subsequently made, is inappropriate, and such work or code will
not be accepted
CS-212 Data Structure and Algorithms BI – 3 2016
Marks Distribution5
Activities Marks
Quizzes + Assignment 10
Final Lab 20
Mid Term 20
Final Term 50
Total 100
CS-212 Data Structure and Algorithms BI – 3 2016
Recommended Books6
Text Book Data Structures and Algorithms in C++ by Adam Drozdek
Reference Books
Himanshu, D. P. (2014). Design and Analysis of Algorithms (2nd ed.). Pearson (New
Delhi).
Cormen, T. H. (2012). Introduction to Algorithms (3rd ed.). PHI Learning.
CS-212 Data Structure and Algorithms BI – 3 2016
Some initial concept and defination7
Data are values or a set of values
Data item refers to single unit of values
Data item Group item : Data item that can be subdivided into sub item.
Ex Name : First Name, Middle initial and Last Name
Elementary item: Data item that can not be sub divided into sub item
Ex : PAN card number / Bank Pass Book Number is treated as single item
CS-212 Data Structure and Algorithms BI – 3 2016
In Short 8
Collection of data are frequently organized into a hierarchy of fields,
records and files
CS-212 Data Structure and Algorithms BI – 3 2016
Some initial concept and definition (contd.)9
Entity : Something that has certain attributes or properties which may
be assigned values Values may be numeric or non-numeric.
Ex: The employee of an organization
Attributes Name Age Sex Employee Code
Values John 33 M 13472
Entity set : Entity with similar attributes ( e.g. all employees of an
organization) form an entity set Each attribute of an entity set has a range of values [ the set of
possible values that could be assigned to the particular attribute] Information: Data with given attribute or processed data
CS-212 Data Structure and Algorithms BI – 3 2016
Some initial concept and definition (contd.)10
Field: is a single elementary unit of information representing an attribute of an entity
Record: is the collection of field values of a given entity
File: is the collection of records of the entities in a given entity set
CS-212 Data Structure and Algorithms BI – 3 2016
What is Data structure11
When elements of data are organized together in terms of some relationships among the elements, the organization is called data structure.
A data structure is a set of data values along with the relationship between the data values in form of set of operations permitted on them.
Arrays, records, stacks, lists, graphs are the names of some of some of these basic data structures.
CS-212 Data Structure and Algorithms BI – 3 2016
In short 12
data structure is a logical way of storing data and it also define mechanism of retrieve data
CS-212 Data Structure and Algorithms BI – 3 2016
A data structure can be13
Transient
it is created when a program starts and is destroyed when the program ends.
Most data structures in main memory are transient, for example, an array of
data.
Permanent
it already exists when a program starts and is preserved when the program
ends. Most data structures on disk are permanent, for example, a file of data,
or a cross-linked data file collection (a database).
CS-212 Data Structure and Algorithms BI – 3 2016
Types of Data structure14
Data structure
Linear
Array Stack Queue Linked
list
Non linear
Tree Graph
CS-212 Data Structure and Algorithms BI – 3 2016
Data Structure Operation15
Traversing: Accessing each record exactly once so that certain item in the record may be processed.
Searching: finding the location of the record with a given key value .
Insertion : add a new record to the structure
Deletion : removing a record from the structure
CS-212 Data Structure and Algorithms BI – 3 2016
What is an Algorithms?16
An algorithm is a finite set of instructions which, when followed, accomplishes a particular task
An algorithm is a formula or set of steps for solving a particular problem. It’s set of rules must be unambiguous and have a clear stopping point.
CS-212 Data Structure and Algorithms BI – 3 2016
Its Characteristics17
Each instruction should be unique and concise
Each instruction should be relative in nature and should not be repeated infinitely.
Repetition of same task(s) should be avoided.
The result be available to the user after the algorithm terminates.
CS-212 Data Structure and Algorithms BI – 3 2016
Efficiency of Algorithms18
The performance of algorithms can be measured on the scales
Times
Space
CS-212 Data Structure and Algorithms BI – 3 2016
Space Complexity19
The amount of memory space required by the algorithm during the course of execution
Some of the reasons for space complexity are
If the program, is to run on multi-user system, it may be required to specify the
amount of memory to be allocated to the program
We may be interested to know in advance that whether sufficient memory is
available to run the program.
There may be several possible solutions with different space requirements .
CS-212 Data Structure and Algorithms BI – 3 2016
Space needed by Program Components20
Instruction Space – Space needed to store the executable version of the program and it is fixed.
Data Space – It is needed to store all constants, variable values
Environment Space – Space needed to store the information needed to resume the suspended functions.
CS-212 Data Structure and Algorithms BI – 3 2016
Time Complexity21
The amount of time needed to run to completion.
Some reasons for studying time complexity We may be interested to know in advance that whether a program will provide
satisfactory real time response.
There must be several possible solutions with different time requirements.
CS-212 Data Structure and Algorithms BI – 3 2016
Summary22
Class Activities Class Introduction
Course Description
Students’ Responsibilities
Course Policy
Marks Distribution
Recommended Books
Essential Background