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
datastructuresarenotappropriate.
Consideragenealogytreeofafamily.
Moha
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 resource
growth rate of a piece of code in terms of a functio
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 Structure
A linear data structure traverse the data
sequent
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 data in an effective way. Data Structures is about rende
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;
elements = (E[]) new Object[size]; / create array
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 words, its a representation of an idea. Algorithm is not t
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;
import java.util.ArrayList;
import java.util.Scanner;
/
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
computer graphics
operating systems
compiler writing
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
insertion at the front end and deletion from the rear end w
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 called as matrix.
Consider the Two dimensional array
1. Two
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
64
0
37
element
Searching for 86.
Search Lesson
CS131
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 sequence of steps taken to solve a
problem. The steps are norm
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
14
4
15
3
9
7
5
Department of Computer Science
18
16
2
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 you are required to read this):
Every one of you are allo