SlideShare a Scribd company logo
Course Title: Data Structures and
Algorithms
Course code: CS211
Credit Hours: 4(3+1)
Prerequisite: Introduction to Computer
Programming
Course objectives:
Detailed study of the basic notions of the design of
algorithms and the underlying data structures.
Several measures of complexity are introduced.
Emphasis on the Algorithms development, Testing
complexity, and efficiency of algorithms.
Learning outcomes:
Fundamental algorithms design principles such as
Divide and Conquer, Different sorting and searching
algorithms are introduced and explored through case
studies to demonstrate the design of efficient
solutions to computational problems. On completion
of the module a student should be able to:
 Identify the fundamental strategies in algorithmic
design
 Distinguish which strategy is appropriate to solve
a given problem
 Classify different algorithmic strategies
 Analyze a given algorithm and assess its
efficiency
 Apply techniques of proof by induction to verify
certain properties of algorithms.
 Coursework will enhance a student's algorithm
design and program implementation skills.
Course Outlines :
Introduction to Data Structures and Algorithms;
Complexity Analysis; Arrays; Sorting Algorithms:
Insertion Sort, Selection Sort, Bubble Sort, Shell
Sort, Heap Sort, Quick Sort, Merge Sort, Radix Sort,
Bucket Sort; Linked Lists: Singly Linked Lists,
Doubly Linked Lists, Circular List; Stacks, Queues,
and Priority Queue; Recursion: Function call and
Recursion Implementation, Tail Recursion, Non-tail
Recursion, Indirect Recursion, Nested Recursion,
Backtracking. Trees: Binary Trees, Binary Heap,
Binary Search. Tree Traversal, Insertion, Deletion,
and Balancing a Tree; Heap; B-Tree; Spanning Tree,
Splay Trees; Graphs: Representation, Traversal,
Shortest Path, and Cycle Detection; Isomorphic
Graphs; Graph Traversal Algorithms; Hashing;
Memory Management and Garbage Collection.
LAB Work:
1 Write a program to search an element in a two
dimensional array
2 Using iteration and recursion concepts write
programs for finding the element in the array
using the Binary search method.
3 Write a program to perform following
operations on tables by user defined
functions: Addition, Subtraction,
Multiplication, and Transpose.
4 Write a program using iteration and recursion
concepts for quick sort.
5 Write a program to implement various
operations on strings.
6 Write a program for swapping two numbers
using call by value and call by reference
strategies.
7 Write a program to implement Binary search
tree.
8 Write a program to create a Linked List and
perform operations such as insert, delete,
update and reverse.
9 Write a program to simulate various sorting
and searching algorithms.
10 Write a program to simulate various Graph
traversing techniques.
11 Write a program to simulate various tree
traversal techniques.
12 Implement data structures in C++
Reference Materials (Latest Editions of the
following books):
1. Data Structures and Algorithm Analysis, Mark
Allen Weiss, Florida International University,
Addison-Wesley
2. Algorithms, Robert Sedgewick, Princeton
University Publisher: Addison- Wesley Professional
3. Data Structures: Abstraction and Design Using
Java, Koffman and Wolfgang, Wiley;
4. Data Structures and Algorithms in C++, Adam
Drozdek, Course Technology;
Grading Policy:
1.Assignment /Presentation/ Quizzes /Group
Discussions 15%
2.Attendance (Minimum class attendance 75% of
the total lectures ) 05%
3.Mid Term Examination
30%
4.Final Examination
50%
Data Structure:
Data :
• The collection of raw material or facts and
figures about any object is called data.
• e.g
• Student data
• Name, Age, Rno, Class, Section, Gender ,
Address, Phone no, Blood group,
Data Structure
• Organization of data into computer memory is
called data structure.
• Data structure deals with “How data is organized
in memory”.
• Data may be organized in many different ways:
• The logical or mathematical model of particular
organization of data is called a data structure.
• The choice of a particular data model depends
on two considerations.
• First it must be rich enough in structure to mirror
the actual relationships of the data in real world.
• The structure should be simple enough that one
.can effectively process the data when necessary.
Classification of Data Structure
• Linear
• Non linear
Linear
• The organization of data in which each node
except first and last have only one proceeding
and succeeding node is called linear data
structure
•
• Arrays
• Stacks
• Queues
• Lists, etc
Non Linear
• When the data is stored in the computer memory
in hierarchical way or in non linear form, then it
is called non linear data structure
• e.g
• Trees
• Files
• Graphs
Algorithms:
• An algorithm is any well-defined computational
procedure that takes some values, or set of
values, as input and produces some value, or set
of values, as output. An algorithm is thus a
sequence of computational steps that transform
the input into output.
• It can be described in a natural language,
pseudocode, a flow- chart, or even a
programming language.
Criteria/Characteristics of Algorithms
• Finiteness
• Definiteness - no ambiguity /unambiguous
• Input
• Output
• Effectiveness
• Efficient
• Concise and Compact
• Sequence No.
• Correctness
Finiteness
• An algorithm must terminate after a finite
number of steps and further each step must be
executable in finite amount of time.
• In order to establish a sequence of steps as an
algorithm, it should be established that it
terminates (in finite number of steps) on all
allowed inputs.
Definiteness (no ambiguity , clarity )
• Each steps of an algorithm must be precisely
defined and it should be unambiguous.
Inputs
• An algorithm must have input values from a
specified set.
• An algorithm has zero or more but only finite
number of inputs.
Output:
• An algorithm must produce some values called
output.
• An algorithm has one or more outputs.
• The requirement of at least one output is
obviously essential, because, otherwise we
cannot know the answer/ solution provided by
the algorithm.
• The outputs have specific relation to the inputs,
where the relation is defined by the algorithm.
Effectiveness
• Effectiveness is the capability of producing a
desired result.
• An algorithm should be effective/useful.
Efficient
• An algorithm should not use unnecessary
memory locations.
Concise and compact
• An algorithm should be concise and compact.
Sequence No.
• Each step of algorithm must have a sequence
number.
Correctness
• Each step of an algorithm must be correctly
defined.
Need for Data Structures
 Data structures organize data  more efficient
programs.
 More powerful computers  more complex
applications.
 More complex applications demand more
calculations.
Efficiency
 A solution is said to be efficient if it solves the
problem within its resource constraints.
– Space
– Time
– The cost of a solution is the amount of
resources that the solution consumes.
Selecting a Data Structure
Select a data structure as follows:
1.Analyze the problem to determine the resource
constraints a solution must meet.
2.Determine the basic operations that must be
supported. Quantify the resource constraints for
each operation.
3.Select the data structure that best meets these
requirements
Some Questions to Ask
• Are all data inserted into the data structure at the
beginning, or are insertions interspersed with
other operations?
• Can data be deleted?
• Are all data processed in some well-defined
order, or is random access allowed?
Data Structure Philosophy
 Each data structure has costs and benefits.
 Rarely is one data structure better than another
in all situations.
 A data structure requires:
– space for each data item it stores,
– time to perform each basic operation,
– programming effort.
Arrays:
 Elementary data structure that exists as built-in
in most programming languages.
An array is a collection of items stored at contiguous
memory locations. The idea is to store multiple items
of the same type together. This makes it easier to
calculate the position of each element by simply
adding an offset to a base value, i.e., the memory
location of the first element of the array (generally
denoted by the name of the array).
main( int argc, char** argv )
{
int x[6];
int j;
for(j=0; j < 6; j++)
x[j] = 2*j;
}
 Array declaration: int x[8];
 An array is collection of cells of the same type.
 The collection has the name ‘x’.
 The cells are numbered with consecutive
integers.
 To access a cell, use the array name and an
index:
x[0], x[1], x[2], x[3], x[4], x[5]
Array Layout
Array cells are contiguous in computer memory.
The memory can be thought of as an array.
X[0]
X[1]
X[2]
X[3]
X[4]
X[5]
X[6]
X[7]
What is Array Name?
 ‘x’ is an array name but there is no variable
x. ‘x’ is not an lvalue.
 For example, if we have the code
int a, b;
then we can write
b = 2;
a = b;
a = 5;
 But we cannot write
2 = a;
 ‘x’ is not an lvalue
int x[6];
int n;
x[0] = 5;
x[1] = 2;
x = 3; // not allowed
x = a + b; // not allowed
x = &n; // not allowed
Dynamic Arrays
 You would like to use an array data
structure but you do not know the size
of the array at compile time.
 You find out when the program
executes that you need an integer array
of size n=20.
 Allocate an array using the new
operator:
int* y = new int[20]; // or int* y = new
int[n]
y[0] = 10;
y[1] = 15; // use is the same
 ‘y’ is a lvalue; it is a pointer that holds
the address of 20 consecutive cells in
memory.
 It can be assigned a value. The new
operator returns as address that is
stored in y.
 We can write:
y = &x[0];
y = x; // x can appear on the
right
// y gets the address of
the
// first cell of the x array
 We must free the memory we got
using the new operator once we are
done with the y array.
delete[ ] y;

 We would not do this to the x array
because we did not use new to create
it.
There is a substantial difference
between declaring a normal array
and allocating dynamic memory
for a block of memory using new.
The most important difference is
that the size of a regular array
needs to be a constant
expression, and thus its size has
to be determined at the moment
of designing the program, before
it is run, whereas the dynamic
memory allocation performed
by new allows to assign memory
during runtime using any variable
value as size.
The LIST Data Structure
 The List is among the most generic of data
structures.
 Real life:
a.shopping list,
b.groceries list,
c.list of people to invite to dinner
d.List of presents to get
 A list is collection of items that are all of the
same type (grocery items, integers, names)
 The items, or elements of the list, are stored in
some particular order
 It is possible to insert new elements into various
positions in the list and remove any element of
the list
 List is a set of elements in a linear order.
For example, data values a1, a2, a3, a4 can be
arranged in a list:
(a3, a1, a2, a4)
In this list, a3, is the first element, a1 is the
second element, and so on
 The order is important here; this is not just a
random collection of elements, it is an ordered
collection
List Operations
Useful operations
• createList(): create a new list (presumably
empty)
• copy(): set one list to be a copy of another
• clear(); clear a list (remove all elments)
• insert(X, ?): Insert element X at a particular
position in the list
• remove(?): Remove element at some position in
the list
• get(?): Get element at a given position
• update(X, ?): replace the element at a given
position with X
• find(X): determine if the element X is in the list
• length(): return the length of the list.
List Operations
 We need to decide what is meant by “particular
position”; we have used “?” for this.
There are two possibilities:
1.Use the actual index of element: insert after
element 3, get element number 6. This
approach is taken by arrays
2.Use a “current” marker or pointer to refer to
a particular position in the list.
List Operations
 If we use the “current” marker, the following
four methods would be useful:
 start(): moves to “current” pointer to the
very first element.
 tail(): moves to “current” pointer to the very
last element.
 next(): move the current position forward
one element
 back(): move the current position backward
one element

More Related Content

Similar to Data structure and algorithm.

Data Structure Lec #1
Data Structure Lec #1Data Structure Lec #1
Data Structure Lec #1
University of Gujrat, Pakistan
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
example43
 
CS301-lec01.ppt
CS301-lec01.pptCS301-lec01.ppt
CS301-lec01.ppt
omair31
 
Introduction to Data Structures & Algorithms
Introduction to Data Structures & AlgorithmsIntroduction to Data Structures & Algorithms
Introduction to Data Structures & Algorithms
Afaq Mansoor Khan
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
data structures and its importance
 data structures and its importance  data structures and its importance
data structures and its importance
Anaya Zafar
 
Data structure
Data structureData structure
Data structure
Muhammad Farhan
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
SayedMohdAsim2
 
Data structure and algorithm with java by shikra
Data structure and algorithm  with java by shikraData structure and algorithm  with java by shikra
Data structure and algorithm with java by shikra
jateno3396
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
JohnStuart83
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Axmedcarb
 
Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & Algorithms
Akhil Kaushik
 
DSA 1- Introduction.pdf
DSA 1- Introduction.pdfDSA 1- Introduction.pdf
DSA 1- Introduction.pdf
AliyanAbbas1
 
UNIT_5_Data Wrangling.pptx
UNIT_5_Data Wrangling.pptxUNIT_5_Data Wrangling.pptx
UNIT_5_Data Wrangling.pptx
BhagyasriPatel2
 
computer notes - Data Structures - 1
computer notes - Data Structures - 1computer notes - Data Structures - 1
computer notes - Data Structures - 1ecomputernotes
 
Basic terminologies & asymptotic notations
Basic terminologies & asymptotic notationsBasic terminologies & asymptotic notations
Basic terminologies & asymptotic notations
Rajendran
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
classall
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
classall
 
b,Sc it data structure.ppt
b,Sc it data structure.pptb,Sc it data structure.ppt
b,Sc it data structure.ppt
classall
 

Similar to Data structure and algorithm. (20)

Data Structure Lec #1
Data Structure Lec #1Data Structure Lec #1
Data Structure Lec #1
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
 
CS301-lec01.ppt
CS301-lec01.pptCS301-lec01.ppt
CS301-lec01.ppt
 
Introduction to Data Structures & Algorithms
Introduction to Data Structures & AlgorithmsIntroduction to Data Structures & Algorithms
Introduction to Data Structures & Algorithms
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Unit 1 dsa
 
data structures and its importance
 data structures and its importance  data structures and its importance
data structures and its importance
 
Data structure
Data structureData structure
Data structure
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
 
Data structure and algorithm with java by shikra
Data structure and algorithm  with java by shikraData structure and algorithm  with java by shikra
Data structure and algorithm with java by shikra
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & Algorithms
 
DSA 1- Introduction.pdf
DSA 1- Introduction.pdfDSA 1- Introduction.pdf
DSA 1- Introduction.pdf
 
UNIT_5_Data Wrangling.pptx
UNIT_5_Data Wrangling.pptxUNIT_5_Data Wrangling.pptx
UNIT_5_Data Wrangling.pptx
 
computer notes - Data Structures - 1
computer notes - Data Structures - 1computer notes - Data Structures - 1
computer notes - Data Structures - 1
 
Basic terminologies & asymptotic notations
Basic terminologies & asymptotic notationsBasic terminologies & asymptotic notations
Basic terminologies & asymptotic notations
 
Lect1.pptx
Lect1.pptxLect1.pptx
Lect1.pptx
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
 
b,Sc it data structure.ppt
b,Sc it data structure.pptb,Sc it data structure.ppt
b,Sc it data structure.ppt
 

Recently uploaded

Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
tapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive datatapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive data
theahmadsaood
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
vcaxypu
 
Business update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMIBusiness update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMI
AlejandraGmez176757
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
ocavb
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
nscud
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
ukgaet
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
Tiktokethiodaily
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
Jpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization Sample
James Polillo
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
AbhimanyuSinha9
 
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdfSample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Linda486226
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
benishzehra469
 

Recently uploaded (20)

Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
tapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive datatapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive data
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
 
Business update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMIBusiness update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMI
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
Jpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization Sample
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
 
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdfSample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
 

Data structure and algorithm.

  • 1. Course Title: Data Structures and Algorithms Course code: CS211 Credit Hours: 4(3+1) Prerequisite: Introduction to Computer Programming Course objectives: Detailed study of the basic notions of the design of algorithms and the underlying data structures. Several measures of complexity are introduced. Emphasis on the Algorithms development, Testing complexity, and efficiency of algorithms. Learning outcomes: Fundamental algorithms design principles such as Divide and Conquer, Different sorting and searching algorithms are introduced and explored through case studies to demonstrate the design of efficient solutions to computational problems. On completion of the module a student should be able to:
  • 2.  Identify the fundamental strategies in algorithmic design  Distinguish which strategy is appropriate to solve a given problem  Classify different algorithmic strategies  Analyze a given algorithm and assess its efficiency  Apply techniques of proof by induction to verify certain properties of algorithms.  Coursework will enhance a student's algorithm design and program implementation skills. Course Outlines : Introduction to Data Structures and Algorithms; Complexity Analysis; Arrays; Sorting Algorithms: Insertion Sort, Selection Sort, Bubble Sort, Shell Sort, Heap Sort, Quick Sort, Merge Sort, Radix Sort, Bucket Sort; Linked Lists: Singly Linked Lists, Doubly Linked Lists, Circular List; Stacks, Queues, and Priority Queue; Recursion: Function call and Recursion Implementation, Tail Recursion, Non-tail Recursion, Indirect Recursion, Nested Recursion,
  • 3. Backtracking. Trees: Binary Trees, Binary Heap, Binary Search. Tree Traversal, Insertion, Deletion, and Balancing a Tree; Heap; B-Tree; Spanning Tree, Splay Trees; Graphs: Representation, Traversal, Shortest Path, and Cycle Detection; Isomorphic Graphs; Graph Traversal Algorithms; Hashing; Memory Management and Garbage Collection. LAB Work: 1 Write a program to search an element in a two dimensional array 2 Using iteration and recursion concepts write programs for finding the element in the array using the Binary search method. 3 Write a program to perform following operations on tables by user defined functions: Addition, Subtraction, Multiplication, and Transpose. 4 Write a program using iteration and recursion concepts for quick sort. 5 Write a program to implement various operations on strings. 6 Write a program for swapping two numbers using call by value and call by reference strategies. 7 Write a program to implement Binary search tree.
  • 4. 8 Write a program to create a Linked List and perform operations such as insert, delete, update and reverse. 9 Write a program to simulate various sorting and searching algorithms. 10 Write a program to simulate various Graph traversing techniques. 11 Write a program to simulate various tree traversal techniques. 12 Implement data structures in C++ Reference Materials (Latest Editions of the following books): 1. Data Structures and Algorithm Analysis, Mark Allen Weiss, Florida International University, Addison-Wesley 2. Algorithms, Robert Sedgewick, Princeton University Publisher: Addison- Wesley Professional 3. Data Structures: Abstraction and Design Using Java, Koffman and Wolfgang, Wiley; 4. Data Structures and Algorithms in C++, Adam Drozdek, Course Technology;
  • 5. Grading Policy: 1.Assignment /Presentation/ Quizzes /Group Discussions 15% 2.Attendance (Minimum class attendance 75% of the total lectures ) 05% 3.Mid Term Examination 30% 4.Final Examination 50% Data Structure: Data : • The collection of raw material or facts and figures about any object is called data. • e.g
  • 6. • Student data • Name, Age, Rno, Class, Section, Gender , Address, Phone no, Blood group, Data Structure • Organization of data into computer memory is called data structure. • Data structure deals with “How data is organized in memory”. • Data may be organized in many different ways: • The logical or mathematical model of particular organization of data is called a data structure. • The choice of a particular data model depends on two considerations. • First it must be rich enough in structure to mirror the actual relationships of the data in real world. • The structure should be simple enough that one .can effectively process the data when necessary. Classification of Data Structure
  • 7. • Linear • Non linear Linear • The organization of data in which each node except first and last have only one proceeding and succeeding node is called linear data structure • • Arrays • Stacks • Queues • Lists, etc Non Linear • When the data is stored in the computer memory in hierarchical way or in non linear form, then it is called non linear data structure • e.g • Trees
  • 8. • Files • Graphs Algorithms: • An algorithm is any well-defined computational procedure that takes some values, or set of values, as input and produces some value, or set of values, as output. An algorithm is thus a sequence of computational steps that transform the input into output. • It can be described in a natural language, pseudocode, a flow- chart, or even a programming language.
  • 9. Criteria/Characteristics of Algorithms • Finiteness • Definiteness - no ambiguity /unambiguous • Input • Output • Effectiveness • Efficient • Concise and Compact • Sequence No. • Correctness Finiteness • An algorithm must terminate after a finite number of steps and further each step must be executable in finite amount of time. • In order to establish a sequence of steps as an algorithm, it should be established that it terminates (in finite number of steps) on all allowed inputs.
  • 10. Definiteness (no ambiguity , clarity ) • Each steps of an algorithm must be precisely defined and it should be unambiguous. Inputs • An algorithm must have input values from a specified set. • An algorithm has zero or more but only finite number of inputs. Output: • An algorithm must produce some values called output. • An algorithm has one or more outputs. • The requirement of at least one output is obviously essential, because, otherwise we cannot know the answer/ solution provided by the algorithm. • The outputs have specific relation to the inputs, where the relation is defined by the algorithm.
  • 11. Effectiveness • Effectiveness is the capability of producing a desired result. • An algorithm should be effective/useful. Efficient • An algorithm should not use unnecessary memory locations. Concise and compact • An algorithm should be concise and compact. Sequence No. • Each step of algorithm must have a sequence number. Correctness • Each step of an algorithm must be correctly defined.
  • 12. Need for Data Structures  Data structures organize data  more efficient programs.  More powerful computers  more complex applications.  More complex applications demand more calculations. Efficiency  A solution is said to be efficient if it solves the problem within its resource constraints. – Space – Time – The cost of a solution is the amount of resources that the solution consumes.
  • 13. Selecting a Data Structure Select a data structure as follows: 1.Analyze the problem to determine the resource constraints a solution must meet. 2.Determine the basic operations that must be supported. Quantify the resource constraints for each operation. 3.Select the data structure that best meets these requirements Some Questions to Ask • Are all data inserted into the data structure at the beginning, or are insertions interspersed with other operations? • Can data be deleted? • Are all data processed in some well-defined order, or is random access allowed?
  • 14. Data Structure Philosophy  Each data structure has costs and benefits.  Rarely is one data structure better than another in all situations.  A data structure requires: – space for each data item it stores, – time to perform each basic operation, – programming effort.
  • 15. Arrays:  Elementary data structure that exists as built-in in most programming languages. An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array). main( int argc, char** argv ) { int x[6]; int j; for(j=0; j < 6; j++) x[j] = 2*j; }
  • 16.  Array declaration: int x[8];  An array is collection of cells of the same type.  The collection has the name ‘x’.  The cells are numbered with consecutive integers.  To access a cell, use the array name and an index: x[0], x[1], x[2], x[3], x[4], x[5] Array Layout Array cells are contiguous in computer memory. The memory can be thought of as an array. X[0] X[1] X[2] X[3]
  • 17. X[4] X[5] X[6] X[7] What is Array Name?  ‘x’ is an array name but there is no variable x. ‘x’ is not an lvalue.  For example, if we have the code int a, b; then we can write b = 2; a = b; a = 5;
  • 18.  But we cannot write 2 = a;  ‘x’ is not an lvalue int x[6]; int n; x[0] = 5; x[1] = 2; x = 3; // not allowed x = a + b; // not allowed x = &n; // not allowed
  • 19. Dynamic Arrays  You would like to use an array data structure but you do not know the size of the array at compile time.  You find out when the program executes that you need an integer array of size n=20.  Allocate an array using the new operator: int* y = new int[20]; // or int* y = new int[n] y[0] = 10; y[1] = 15; // use is the same
  • 20.  ‘y’ is a lvalue; it is a pointer that holds the address of 20 consecutive cells in memory.  It can be assigned a value. The new operator returns as address that is stored in y.  We can write: y = &x[0]; y = x; // x can appear on the right // y gets the address of the // first cell of the x array  We must free the memory we got using the new operator once we are done with the y array. delete[ ] y; 
  • 21.  We would not do this to the x array because we did not use new to create it. There is a substantial difference between declaring a normal array and allocating dynamic memory for a block of memory using new. The most important difference is that the size of a regular array needs to be a constant expression, and thus its size has to be determined at the moment of designing the program, before it is run, whereas the dynamic memory allocation performed by new allows to assign memory during runtime using any variable value as size.
  • 22. The LIST Data Structure  The List is among the most generic of data structures.  Real life: a.shopping list, b.groceries list, c.list of people to invite to dinner d.List of presents to get  A list is collection of items that are all of the same type (grocery items, integers, names)  The items, or elements of the list, are stored in some particular order  It is possible to insert new elements into various positions in the list and remove any element of the list  List is a set of elements in a linear order. For example, data values a1, a2, a3, a4 can be arranged in a list: (a3, a1, a2, a4)
  • 23. In this list, a3, is the first element, a1 is the second element, and so on  The order is important here; this is not just a random collection of elements, it is an ordered collection List Operations Useful operations • createList(): create a new list (presumably empty) • copy(): set one list to be a copy of another • clear(); clear a list (remove all elments) • insert(X, ?): Insert element X at a particular position in the list • remove(?): Remove element at some position in the list • get(?): Get element at a given position • update(X, ?): replace the element at a given position with X • find(X): determine if the element X is in the list • length(): return the length of the list. List Operations
  • 24.  We need to decide what is meant by “particular position”; we have used “?” for this. There are two possibilities: 1.Use the actual index of element: insert after element 3, get element number 6. This approach is taken by arrays 2.Use a “current” marker or pointer to refer to a particular position in the list. List Operations  If we use the “current” marker, the following four methods would be useful:  start(): moves to “current” pointer to the very first element.  tail(): moves to “current” pointer to the very last element.  next(): move the current position forward one element  back(): move the current position backward one element