COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
Schedule for meeting(Other than class)
BSE 3A,BCS 3B,3C
Only BCS 3C
BSE 3A,BCS 3B,3C
BSE 3A,BCS 3B,3C
Not Allowed hours
Allowed hours
Note(If you have any issue regarding Data Structure course then yo
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
DATA
STRUCTURE
AND ITS TYPES
Data Structure
It is a logical way of storing data
and it also define mechanism of
retrieve data.
Types of Data
Structure
DATA
STRUCTURE
LINEAR
NON LINEAR
Linear Data Stru
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
Growth Rates
Algorithms analysis is all about understanding growth rates. That is as the amount of data gets
bigger, how much more resource will my algorithm require? Typically, we describe the resour
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
AlgorithmsandData
Structures
Salahuddin Swati
Department of Computer
Science
DCS
COMSATS Institute of
Information Technology
TreeDataStructures
Thereareanumberofapplicationswherelinear
datastructuresa
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
Lab No. 26: Insertion Sort
Objective:
The purpose of this lab is to demonstrate Insrtion Sort.
Scope:
Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
Lab No 24: Linear Search
Objective:
The objective of this lab is to implement linear search algorithm.
Scope:
Linear search or sequential search is algorithm which will traverse the whole data structu
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
2.1
Insertion sort
Our rst algorithm, insertion sort, solves the sorting problem
Input: A sequence of n numbers ha1 ; a2 ; : : : ; an i.
Output: A permutation (reordering) ha10 ; a20 ; : : : ; an0 i o
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
194
8.2
Chapter 8 Sorting in Linear Time
Counting sort
Counting sort assumes that each of the n input elements is an integer in the range
0 to k, for some integer k. When k D O.n/, the sort runs in .n
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
2.3 Designing algorithms
29
2.3 Designing algorithms
We can choose from a wide range of algorithm design techniques. For insertion
sort, we used an incremental approach: having sorted the subarray A1
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
COMSATS Institute of Information Technology Abbottabad
Introduction to Data Structures
Data Structure is a way of collecting and organizing data in such a way that we can perform
operations on these d
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
class StackGeneric<E> cfw_
private final int size;
private int top;
private E[] elements;
public StackGeneric() cfw_
this(10);
public StackGeneric(int s) cfw_
size = s > 0 ? s : 10;
top = 1
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
COMSATS Institute of Information Technology Abbottabad
What is Algorithm?
An algorithm is a finite set of instructions or logic, written in order, to accomplish a certain
predefined task. In other wor
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
AlgorithmsandData
Structures
Salahuddin Swati
Department of Computer
Science
DCS
COMSATS Institute of
Information Technology
Degenerate Binary Search Tree
BST for 14, 15, 4, 9, 7, 18, 3, 5, 16, 20, 17
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
Pseudocode Examples
An algorithm is a procedure for solving a problem in terms of the actions to be executed and the order in
which those actions are to be executed. An algorithm is merely the sequenc
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
Linear Search
Linear Search algrorithm
LinearSearch(A,v)
for i1 to lengthA
do if A[i]=v
return i
return NIL
Where A=Array, and v is the element to search
Linear Search Example #1
23
97
18
21
5
86
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
COMSATS Institute of Information Technology Abbottabad
Multidimensional Arrays
1. Array having more than one subscript variable is called multidimensional array.
2. Multidimensional array is also call
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
Lab No. 13: Queue (Array Based)
The objective of this lab is to implement queue using array.
Scope:
An array of a given size will be declared and used as a queue data structure. The operations of
inse
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
INTRODUCTION TO GRAPHS
INTRODUCTION:
Graph theory plays an important role in several areas of computer
science such as:
switching theory and logical design
artificial intelligence
formal languages
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools  Templates
* and open the template in the editor.
*/
/package Test;
COMSATS Institute of Information Technology, Abbottabad
dATA STRUCTURE
CS C 112

Spring 2016
Data
Structure
Lab Work
B.S.Geophysics (V)
M.Imran Hafeez Abbasi
Lab # 01
Project # 01
int[]
mia = new int[5] cfw_2,4,6,8,10;
Console.WriteLine(" \n The Numbers are \t cfw_0",mia[0]);
Console.WriteLin