1
2
Syllabus 
3 Prof. A. Syed Mustafa (Ph.D)
Syllabus 
4 Prof. A. Syed Mustafa (Ph.D)
Syllabus 
5 Prof. A. Syed Mustafa (Ph.D)
Syllabus 
6 Prof. A. Syed Mustafa (Ph.D)
7 
Evaluation 
•Grade Percentage 
–FCD : 70% and above 
–FC : 60% -69% 
–SC : 35% -59% 
–FL : less than 35% 
•Syllabus Coverage Schedule 
–1stIA Test : 30% [ Portion-first 2.5 Units ] 
–2ndIA Test : 30% [ Portion-next 2.5 Units ] 
–3rdIA Test : 40% [ Portion-Last 3 Units ]
8 
Evaluation 
•Assignments 
–Total : 3 
–Each Assignment to be submitted before the IA test 
begins 
•Attendance 
–Class Participation: 85% 
•You may get detained if you miss (more than) ¼of the whole classes 
•Academic dishonesty (e.g. cheating, copying, late coming and etc.) will be taken seriously
9 
Announcement 
•Class Website 
•The link for the CMS portal is: 
–Intranet link: http:172.17.0.2moodle 
–Internet link: http:61.8.153.222moodle 
–http://gg.gg/hkbkis 
•Class information such as lecture notes can be accessible through this website 
•We will also use Moodle for online test
10 
Announcement 
•Programming Assignments 
–We encourage to study and discuss together for doing programming assignments. 
–However, you must do programming YOURSELF. 
–You must not share any of source code with other students. 
–Any kind of academic dishonesty will be viewed very seriously.
Unit -1 
11 Prof. A. Syed Mustafa (Ph.D) 
Basic concepts
12 Prof. A. Syed Mustafa (Ph.D) 
Basic Concepts 
Topics : 
Pointers and Dynamic Memory Allocation 
Algorithm Specification 
Data Abstraction 
Performance Analysis 
Performance Measurement
13 Prof. A. Syed Mustafa (Ph.D) 
Basic Concepts 
Objectives 
Understanding core concepts of memory management, performance analysis. 
Applying the pointer concepts to actual programming 
managing memory efficiently 
Improve the performance.
14 Prof. A. Syed Mustafa (Ph.D) 
Basic Concepts 
Course Outcome: 
Able to apply the pointer concepts to actual programming 
Able to use memory efficiently 
Able to increase the performance of the program.
15 Prof. A. Syed Mustafa (Ph.D) 
Basic ConceptsSystem Life Cycle 
•Large-Scaleprogramcontainsmanycomplexinteractingparts. 
•Programsundergoadevelopmentprocesscalledthesystemlifecycle. 
•Solidfoundationin 
1.dataabstraction 
2.algorithmspecification 
3.performanceanalysisandmeasurement 
providesnecessarymethodology.
16 Prof. A. Syed Mustafa (Ph.D) 
Basic ConceptsSystem Life Cycle 
5phasesofsystemlifecycle: 
1.Requirements:Beginswithdefiningpurposeoftheproject. Whatinputs(needs),outputs(results) 
2.Analysis:Breaktheproblemdownintomanageablepieces. bottom-upvs.top-down,divideandconquer 
3.Design:dataobjectsandoperationscreationofabstractdatatypes,thespecificationofalgorithmsandalgorithmdesignstrategies,ignorecodingdetails. 
4.Refinement&coding:chooserepresentationsforourdataobjectsandwritealgorithmsforeachoperationonthem. 
weshouldwritethosealgorithmsthatareindependentofthedataobjectsfirst.
17 Prof. A. Syed Mustafa (Ph.D) 
Basic ConceptsSystem Life Cycle 
5.Verification:consistsofdevelopingcorrectnessproofsfortheprogram,testingtheprogramwithavarietyofinputdataandremovingerrors. 
Correctnessproofs:proofsareverytime-consuminganddifficulttodevelopforlargeprojects.Schedulingconstraintspreventthedevelopmentofacompletesetofproofsforalargesystem. 
Testing:beforeandduringthecodingphase.testingisusedatkeycheckpointsintheoverallprocesstodeterminewhetherobjectivesarebeingmet. 
ErrorRemoval:systemtestswillindicateerroneouscode. Errorscanberemoveddependingonthedesign&codingdecisionsmadeearlier.
18 
•ForanytypeTinCthereisacorrespondingtypepointer-to-T. 
•Theactualvalueofapointertypeisanaddressofmemory. 
–&theaddressoperator. 
–*thedereferencing(orindirection)operator. 
–Declaration 
•inti,*ip;//iisanintegervariableandipisapointertoaninteger. 
•ip=&i; 
then&ireturnstheaddressofiandassignsitasthevalueofpi. Basic ConceptsPointers 
Prof. A. Syed Mustafa (Ph.D)
19 
Basic ConceptsPointers 
•i=10or*ip=10; 
Inbothcasestheinteger10isstoredasthevalueofi. 
Insecondcase,the*infrontofthepointeripcausesittobedereferenced, 
bywhichwemeanthatinsteadofstoring10intothepointer,10isstoredintothelocationpointedatbythepointerip. 
Prof. A. Syed Mustafa (Ph.D)
20 
Basic ConceptsPointers 
Thesizeofapointercanbedifferentondifferentcomputers. 
Thesizeofapointertoacharcanbelongerthanapointertoafloat. 
TestforthenullpointerinC 
if(ip==NULL)orif(ip==0)orif(!ip)
21 
Basic ConceptsPointers 
Thenullpointerpointstonoobjectorfunction. 
Thenullpointerisrepresentedbytheintegeras0anincharacteras‘0’.TheASCIIvalueforNULLis0. 
Thenullpointerisinterpretedasfalseinrelationalexpressions. 
Prof. A. Syed Mustafa (Ph.D)
22 
Basic ConceptsDynamic Memory Allocation 
•Whenwewriteprogram,wemaynotknowhow 
muchspacewemayneed,tostoredata. 
•Cprovidesamechanismcalledaheap,for 
allocatingstorageatrun-time. 
•Thefunctionmalloc()isusedtoallocateanew 
areaofmemory. 
Prof. A. Syed Mustafa (Ph.D)
23 
Basic ConceptsDynamic Memory Allocation 
malloc() 
Syntax 
void *malloc(size_tsize) 
Parameters 
•size--This is the size of the memory block, in bytes. 
Return Value 
•This function returns a pointer to the allocated memory, or NULLif the request fails 
Prof. A. Syed Mustafa (Ph.D)
24 
Basic ConceptsDynamic Memory Allocation 
malloc() 
•The name mallocstands for "memory allocation". 
•Thefunctionmalloc()reservesablockofmemoryofspecifiedsizeandreturnapointeroftypevoidwhichcanbecastedintopointerofanyform. 
Prof. A. Syed Mustafa (Ph.D)
25 
Basic ConceptsDynamic Memory Allocation 
•Whenmemoryisnolongerneeded,wemayfreeitbycallingfree()function. 
•Thecalltomalloc()determinessizeofstoragerequiredtoholdintorthefloat. 
•Thenotations(int*)and(float*)aretypecastexpressions. 
Prof. A. Syed Mustafa (Ph.D)
26 
Basic ConceptsDynamic Memory Allocation 
•Theresultisapointertothefirstbyteofastorageareaofthepropersize. 
•Thereturnvalueofthemalloc()isvoid*. 
•Acalltomalloc()mayfailforlackofsufficientmemory 
Prof. A. Syed Mustafa (Ph.D)
27 
Basic ConceptsDynamic Memory Allocation 
Example: 
int*pi; float *pf; 
pi = (int*) malloc(sizeof(int)); 
pf = (float *) malloc(sizeof(float)); 
*pi=1024; *pf=3.124; 
printf(“an integer = %d, a float = %fn”,*pi,*pf); 
free(pi); free(pf); 
Prof. A. Syed Mustafa (Ph.D)
28 
Basic ConceptsDynamic Memory Allocation 
•WhenprogramminginCitisawisepracticetosetallpointerstoNULLwhentheyarenotpointingtoanobject. 
•Useexplicittypecastswhenconvertingbetweenpointertypes: 
pi=malloc(sizeof(int));/*assigntopiapointertoint*/ 
pf=(float*)pi;/*castsanintpointertofloatpointer*/ 
•Inmanysystems,pointershavethesamesizeastypeint.intisthedefaulttypespecifier. 
Prof. A. Syed Mustafa (Ph.D)
29 
Basic ConceptsDynamic Memory Allocation 
calloc() 
•The name callocstands for "contiguous memory allocation“ or ‘c’for cleared. 
•Thefunctioncalloc()allocatesablockofmemoryforanarrayofnumelements,eachofthemsizebyteslong,andinitializesallitsbitstozero.
30 
Basic ConceptsDynamic Memory Allocation 
calloc() 
Syntax 
void* calloc(size_tnum, size_tsize); 
Parameters 
•num--Number of elements to allocate. 
•size--Size of each element 
•size_tis an unsigned integral type. 
Return Value 
•On success, a pointerto the memory block allocated by the function. 
•The type of this pointer is alwaysvoid*, which can be cast to the desired type of data pointer in order to be dereferenceable. 
• If the function failed to allocate the requested block of memory, anull pointeris returned. 
Prof. A. Syed Mustafa (Ph.D)
31 
Basic ConceptsDynamic Memory Allocation 
calloc() 
Example 
int*ptr1,*ptr2; 
ptr1 = (int*)calloc(10, sizeof(int)); 
ptr2=(int*)calloc(20,sizeof(float)); 
Prof. A. Syed Mustafa (Ph.D)
32 
Basic ConceptsDynamic Memory Allocation 
malloc() & calloc() 
Differrence 
Theonlydifferencebetweenmalloc()andcalloc()isthat,malloc()allocatessingleblockofmemorywhereascalloc()allocatesmultipleblocksofmemoryeachofsamesizeandsetsallbytestozero. Prof. A. Syed Mustafa (Ph.D)
33 
Basic ConceptsDynamic Memory Allocation 
malloc() & calloc() 
Differrence 
mallocfunction,whereastheareareservedtothestatesthatareundefined,theareaallocatedbythecallocfunctioncontainsa0. 
Infact,thecallocfunctionisinternallymaybeafunctionthatcallsmalloc.Aftersecuringfunctionbymalloc,theareaisfilledwith0. 
Prof. A. Syed Mustafa (Ph.D)
34 
Basic ConceptsDynamic Memory Allocation 
free() 
Syntax 
void free(void *ptr) 
Parameters 
•ptr--Pointer to a memory block previously allocated withmalloc(), calloc() or realloc(). 
Return Value 
•None 
Note: 
If the memeoryis not freed , then Dangling pointer arises which leads to garbagecollection. 
Prof. A. Syed Mustafa (Ph.D)
35 
Basic ConceptsDynamic Memory Allocation 
Prof. A. Syed Mustafa (Ph.D)
36 
Basic ConceptsDynamic Memory Allocation 
Prof. A. Syed Mustafa (Ph.D)
37 
Basic ConceptsDynamic Memory Allocation 
Prof. A. Syed Mustafa (Ph.D)
38 
Basic ConceptsDynamic Memory Allocation 
Prof. A. Syed Mustafa (Ph.D)
39 
Basic ConceptsDynamic Memory Allocation 
realloc() -Reallocate memory block 
void*realloc(void*ptr,size_tsize) 
•TheClibraryfunctionattemptstoresizethememoryblockpointedtobyptrthatwaspreviouslyallocatedwithacalltomallocorcallocorrealloc 
Parameters 
ptr--Thisisthepointertoamemoryblockpreviouslyallocatedwithmalloc,callocorrealloctobereallocated.IfthisisNULL,anewblockisallocatedandapointertoitisreturnedbythefunction 
•size--Thisisthenewsizeforthememoryblock,inbytes.Ifitis0andptrpointstoanexistingblockofmemory,thememoryblockpointedbyptrisdeallocatedandaNULLpointerisreturned. 
ReturnValue 
Thisfunctionreturnsapointertothenewlyallocatedmemory,orNULLiftherequestfails. 
Prof. A. Syed Mustafa (Ph.D)
40 
Basic ConceptsDynamic Memory Allocation 
realloc() -Reallocate memory block 
•Thefunctionrealloc()reallocatesamemoryblockwithaspecificnewsize. 
•Ifwecallrealloc()thesizeofthememoryblockpointedtobythepointerischangedtothegivensizeinbytes. 
•Thiswayweareabletoexpandandreducetheamountofmemoryyouwanttouse(ifavailableofcourse.) 
•Itispossiblethatthefunctionmovesthememoryblocktoanewlocation, inwhichwaythefunctionwillreturnthisnewlocation. 
•Ifthesizeoftherequestedblockislargerthenthepreviousblockthenthevalueofthenewportionisindeterminate. 
Prof. A. Syed Mustafa (Ph.D)
41 
Basic ConceptsDynamic Memory Allocation 
realloc() -Reallocate memory block 
•Thereturnvalueisapointertothereallocatedmemoryblock,whichmaybeeitherthesameasptroranewlocation. 
•Thetypeofreturnpointerisvoid*,whichcanbecasttothedesiredtypeofdatapointerinordertobedereferenceable 
•IfthepointerisNULLthenthefunctionwillbehaveexactlylikethefunctionmalloc().Itwillassignanewblockofasizeinbytesandwillreturnapointertoit. 
•Ifthesizeis0thenthememorythatwaspreviouslyallocatedisfreedasifacallofthefunctionfree()wasgiven.ItwillreturnaNULLpointerinthatcase. 
Prof. A. Syed Mustafa (Ph.D)
42 
•. 
#include<stdlib.h> 
#include<stdio.h> 
intmain() 
{char*str; 
str=(char*)malloc(4);/* Initial memory allocation */ 
strcpy(str,“data"); 
printf("String = %s, Address = %pn",str,str); 
/* Reallocating memory */ 
str=(char*)realloc(str,13); 
strcat(str,“structure"); 
printf("String = %s, Address = %pn",str,str); 
free(str); 
return(0); 
} Basic ConceptsDynamic Memory Allocation 
Prof. A. Syed Mustafa (Ph.D)
43 
Basic ConceptsDynamic Memory Allocation 
free() 
•Deallocatememory block 
•A block of memory previously allocated by a call to malloc(), calloc() or realloc() is deallocated, making it available again for further allocations. Ifptrdoes not point to a block of memory allocated with the above functions, it causesundefined behavior. Ifptris anull pointer, the function does nothing. This function does not change the value ofptritself, hence it still points to the same (now invalid) location. 
Prof. A. Syed Mustafa (Ph.D)
44 
Basic ConceptsDynamic Memory Allocation 
free() 
/* example */ 
#include <stdlib.h> /* malloc, calloc, realloc, free */ 
intmain () 
{ 
int* i1, * i2, * i3; 
i1 = (int*) malloc(100*sizeof(int)); 
i2 = (int*) calloc(100,sizeof(int)); 
i3 = (int*) realloc(i2,500*sizeof(int)); 
free (i1); 
free (i3); 
return 0; 
} 
Prof. A. Syed Mustafa (Ph.D)
45 
Basic ConceptsAlgorithm Specification 
Analgorithmisafinitesetofinstructionsthat,iffollowed,accomplishesaparticulartask. 
Algorithmsmustsatisfyfollowingcriteria: 
Input:therearezeroormorequantitiesthatareexternallysupplied. 
Output:atleastonequantityisproduced. 
Definiteness:Eachinstructionisclearandunambiguous. 
Finiteness:forallcases,thealgorithmterminatesafterafinitenumberofsteps. 
Effectiveness:Everyinstructionmustbebasicenoughtobecarriedout,itmustalsobefeasible. Prof. A. Syed Mustafa (Ph.D)
46 
Basic ConceptsAlgorithm Specification 
•Differencebetweenanalgorithmandaprogram: 
Theprogramdoesnothavetosatisfythefourthcondition(Finiteness). 
•Describinganalgorithm: 
NaturallanguagesuchasEnglishcanbeused.Makesureresultinginstructionsaredefinite. 
•Flowchart: 
workwellonlyforalgorithm,smallandsimple. 
Prof. A. Syed Mustafa (Ph.D)
47 
Basic ConceptsAlgorithm Specification 
•Differencebetweenanalgorithmandaprogram: 
Theprogramdoesnothavetosatisfythefourthcondition(Finiteness). 
•Describinganalgorithm: 
NaturallanguagesuchasEnglishcanbeused.Makesureresultinginstructionsaredefinite. 
•Flowchart: 
workwellonlyforalgorithm,smallandsimple. 
Prof. A. Syed Mustafa (Ph.D)
48 
Basic ConceptsAlgorithm Specification 
Translating a Problem into an Algorithm 
Example-SelectionSort 
Deviseaprogramthatsortsasetofnintegers, wheren>=1,fromsmallesttolargest. 
SolutionI: 
Fromthoseintegersthatarecurrentlyunsorted, findthesmallestandplaceitnextinthesortedlist 
. Prof. A. Syed Mustafa (Ph.D)
49 
Basic ConceptsAlgorithm Specification 
Translating a Problem into an Algorithm 
Describessortingtechnique,butitisnotanalgorithm 
Problems: 
1.Does not describe where and how the integers are initially sorted. 
2.Does not indicate where to place the result. 
. 
Prof. A. Syed Mustafa (Ph.D)
50 
Basic ConceptsAlgorithm Specification 
Translating a Problem into an Algorithm 
SolutionII:SelectionSort 
Analgorithm,writteninpartiallyCandEnglish 
for(i=0;i<n;i++) 
{ 
Examinelist[i]tolist[n-1]andsupposethat 
thesmallestintegerislist[min]; 
Interchangelist[i]andlist[min]; 
} 
.
51 
Basic ConceptsAlgorithm Specification 
Selection Sort 
-find the smallest integer 
-interchange or swap 
-we can solve the problem using a function or macro 
void swap(int*x, int*y) // both arguments are pointers 
{ 
inttemp= *x; 
*x= *y; 
*y= temp; 
} 
Prof. A. Syed Mustafa (Ph.D)
52 
Basic ConceptsAlgorithm Specification 
Selection Sort 
#define swap(x,y,t)((t)= (x), (x)= (y), (y)= (t)) 
void sort(intlist[ ], intn) 
{ 
inti, j, min, temp; 
for (i= 0; i< n-1; i++){ 
min= i; 
for (j= i+1; j< n; j++){ 
if (list[j]< list[min]) min= j; 
} 
swap(list[i], list[min], temp); 
} 
Prof. A. Syed Mustafa (Ph.D)
53 
Basic ConceptsAlgorithm Specification 
Theorem 1.1: 
sort(a, n) correctly sorts a set of n≥ 1 integers; the result remains in a[0] … a[n-1] such that 
a[0] ≤ a[1] ≤ … ≤ a[n–1]. 
Prof. A. Syed Mustafa (Ph.D)
54 
Basic ConceptsAlgorithm Specification 
Example: Binary Search 
Assumethatwehaven≥1distinctintegersthatarealreadysortedandstoredinthearraya[0]…a[n-1]. Ourtaskistodetermineiftheintegerxispresentandifsotoreturnjsuchthatx=a[j];otherwisereturn-1. 
Prof. A. Syed Mustafa (Ph.D)
55 
Basic ConceptsAlgorithm Specification 
Example: Binary Search 
1.Let leftand right, respectively, denote the left and right ends of the list to be searched. 
2.Initially, left = 0 and right = n –1. 
3.Let middle = (left +right) / 2 be the middle position in the list. 
4.If we compare a[middle]with x, we obtain one of the three results. 
Prof. A. Syed Mustafa (Ph.D)
56 
Basic ConceptsAlgorithm Specification 
Example: Binary Search 
1.x < a[middle] 
In this case, if xis present, it must be in the positions between 0 and middle–1. Therefore, we set right to middle–1. 
2.x== a[middle] 
In this case, we return middle. 
3. x> a[middle] 
Inthiscase,ifxispresent,itmustbeinthepositionsbetweenmiddle+1andn-1.So,wesetlefttomiddle+1. 
Prof. A. Syed Mustafa (Ph.D)
57 
Basic ConceptsAlgorithm Specification 
Binary Search. 
Prof. A. Syed Mustafa (Ph.D)
58 
Basic ConceptsAlgorithm Specification 
Binary Search. 
intcompare(intx, inty) 
{ 
if(x < y) return-1; 
else if( x == y) return0; 
else return1; 
} // end of compare 
Macro 
#define compare(x, y) ( ( (x) < (y) ) ? -1: ( (x) == (y) ) ? 0 : 1 ) 
Prof. A. Syed Mustafa (Ph.D)
59 
Basic ConceptsAlgorithm Specification 
Algorithms are implemented as functions in C. 
Functions divide the programs into manageable pieces. 
They make program easier to read. 
Functions can be tested separately. 
Declare function first then define it later. 
Prof. A. Syed Mustafa (Ph.D)
60 
Basic ConceptsAlgorithm Specification 
Recursive algorithm 
Therearemainlytwoapproachesforrepetitive 
approach. 
1.Iteration 
2.Recursion 
Recursionisarepetitiveprocessinwhichanalgorithmcallsitself. 
Prof. A. Syed Mustafa (Ph.D)
61 
Basic ConceptsAlgorithm Specification 
Recursive algorithm 
The following Figure 1 and Figure 2 portrayed the typical pictorial examples for recursive calling. 
Prof. A. Syed Mustafa (Ph.D)
62 
Basic ConceptsAlgorithm Specification 
Recursive algorithm 
The following Figure2 portrayed the typical pictorial examples for recursive calling. 
Prof. A. Syed Mustafa (Ph.D)
63 
Basic ConceptsAlgorithm Specification 
Recursive algorithm 
The following Figure portrayed the typical pictorial examples for recursive calling. 
Prof. A. Syed Mustafa (Ph.D)
64 
Basic ConceptsAlgorithm Specification 
Recursive algorithm 
Recursionisaprogrammingtechniqueinwhichamethodcancallitselftosolveaproblem. 
TwoTypes: 
1.DirectRecursion 
2.Indirectrecursion 
Prof. A. Syed Mustafa (Ph.D)
65 
Basic ConceptsAlgorithm Specification 
Recursive algorithm 
1.DirectRecursion 
Functionscallsthemselves 
2.Indirectrecursion 
Functions calls other function that invoke the 
calling function again. 
Any function that we can write using assignment, if- else and while statements can be written recursively. 
Prof. A. Syed Mustafa (Ph.D)
66 
Basic ConceptsAlgorithm Specification 
Value of Recursion 
This is well suited an alternative concept in the following situations 
1. Recursion can be used to replace loop 
2. A recursive procedure is mathematically more elegant than 
one using loops 
3. Sometime procedure that would tricky to write a loop are 
straightforward to using recursion. 
4. Recursively defined data structure, like list, are very well suited to processing by recursive procedures and functions 
Prof. A. Syed Mustafa (Ph.D)
67 
Basic ConceptsAlgorithm Specification 
Prof. A. Syed Mustafa (Ph.D)
68 
Basic ConceptsAlgorithm Specification 
Prof. A. Syed Mustafa (Ph.D)
69 
Basic ConceptsAlgorithm Specification 
Algorithm to compute factorial using recursive method: 
Factorial (N) 
1. Receive N 
2. if N > 1 return 
Factorial(N-1) * N 
else 
return 1 
Prof. A. Syed Mustafa (Ph.D)
70 
Basic ConceptsAlgorithm Specification 
program to compute factorial using recursive function: 
#include<stdio.h> 
longfactorial(int); 
intmain() 
{intn;longf; 
printf("Enter an integer to find factorialn"); 
scanf("%d",&n); 
if(n <0)printf("Negative integers are not allowedn"); 
else{f =factorial(n);printf("%d! = %ldn",n,f);} 
return0;} 
longfactorial(intn) 
{if (n ==0)return 1; 
else return(n*factorial(n-1)); 
} 
Prof. A. Syed Mustafa (Ph.D)
71 
Basic ConceptsAlgorithm Specification 
program to compute factorial using recursive function: 
Prof. A. Syed Mustafa (Ph.D)
72 
Basic ConceptsAlgorithm Specification 
program to compute factorial using recursive function: 
Prof. A. Syed Mustafa (Ph.D)
73 
Basic ConceptsAlgorithm Specification 
program to compute factorial using recursive function: 
Prof. A. Syed Mustafa (Ph.D)
74 
Basic ConceptsAlgorithm Specification 
program to compute factorial using recursive function: 
Prof. A. Syed Mustafa (Ph.D)
75 
Basic ConceptsAlgorithm Specification 
program to compute factorial using recursive function: 
Prof. A. Syed Mustafa (Ph.D)
76 
Basic ConceptsAlgorithm Specification 
Prof. A. Syed Mustafa (Ph.D)
77 
Basic ConceptsAlgorithm Specification 
Prof. A. Syed Mustafa (Ph.D)
78 
Basic ConceptsAlgorithm Specification 
Prof. A. Syed Mustafa (Ph.D)
79 
Basic ConceptsAlgorithm Specification 
Recursive program: Fibonacci 
intmain() 
{ 
intn=10; 
printf(“%d”, rfib(n)); 
} 
intrfib(intn) 
{ 
if (n==1 || n==2) return 1; 
return rfib(n1) + rfib(n2); 
} 
Prof. A. Syed Mustafa (Ph.D)
80 
Basic ConceptsAlgorithm Specification 
Recursive program: Fibonacci 
Prof. A. Syed Mustafa (Ph.D)
81 
Basic ConceptsAlgorithm Specification 
Recursive program: Fibonacci 
Prof. A. Syed Mustafa (Ph.D)
82 
Basic ConceptsAlgorithm Specification 
Recursive program: Fibonacci 
Prof. A. Syed Mustafa (Ph.D)
83 
Basic ConceptsAlgorithm Specification 
Recursive algorithm: Greatest Common Divisor(x, y) 
Prof. A. Syed Mustafa (Ph.D)
84 
Basic ConceptsAlgorithm Specification 
/* PROGRAM TO FIND GCD OF TWO NUMBER USING RECURSION EUCLIDS*/ #include<stdio.h> #include<conio.h> intgcd(int,int); intmain() {inta,b; clrscr(); printf("n Enter two number:" ); scanf("%d %d",&a,&b); printf("GCD of two number : %d" ,gcd(a,b)); getch(); return(0); } 
Prof. A. Syed Mustafa (Ph.D)
85 
Basic ConceptsAlgorithm Specification 
/* PROGRAM TO FIND GCD OF TWO NUMBER USING RECURSION 
intgcd(intm, intn) { if(m==0) return n; if(n==0) return m; return gcd(n,m%n); } 
Prof. A. Syed Mustafa (Ph.D)
86 
Basic ConceptsAlgorithm Specification 
/* PROGRAM TO FIND GCD OF TWO NUMBER USING RECURSION 
intgcd(inta,intb) 
{ 
if(a !=b) 
{ 
if(a >b) 
returngcd(a -b,b); 
else 
returngcd(a,b -a); 
} 
returna; 
} Prof. A. Syed Mustafa (Ph.D)
87 
Basic ConceptsAlgorithm Specification 
Recursive algorithm: Greatest Common Divisor(x, y) 
Prof. A. Syed Mustafa (Ph.D)
88 
Basic ConceptsAlgorithm Specification 
Recursive algorithm 
Prof. A. Syed Mustafa (Ph.D)
89 
Basic ConceptsAlgorithm Specification 
Recursive algorithm 
Prof. A. Syed Mustafa (Ph.D) 
C(n, k) = C(n-1, k-1) + C(n-1, k) 
C(n, 0) = C(n, n) = 1
90 
Basic ConceptsAlgorithm Specification 
Recursive algorithm-Binomial Coefficient 
Prof. A. Syed Mustafa (Ph.D) 
intbinomialCoeff(intn, intk)// Returns value of Binomial Coefficient C(n, k) 
{ 
if (k==0 || k==n)// Base Cases 
return 1; 
return binomialCoeff(n-1, k-1) + binomialCoeff(n-1, k);// Recur 
} 
intmain()/* program to test above function*/ 
{ 
intn = 5, k = 2; 
printf("Value of C(%d, %d) is %d ", n, k, binomialCoeff(n, k)); // C(5,2) is 10 
return 0; 
}
91 
Basic ConceptsAlgorithm Specification 
Recursive algorithm -Binomial Coefficient 
Prof. A. Syed Mustafa (Ph.D)
92 
Basic ConceptsAlgorithm Specification 
Recursive algorithm: Towers of Hanoi 
Prof. A. Syed Mustafa (Ph.D)
93 
Basic ConceptsAlgorithm Specification 
Recursive algorithm: Towers of Hanoi 
Prof. A. Syed Mustafa (Ph.D) 
•Label the stands Src, Intr,Dest. 
•Letnbe the total number of discs. 
•Number the discs from 1 (smallest, topmost) ton(largest, bottommost). 
To move n discs from stand Srcto stand Dest: 
1.Move n-1 plates from Srcto Intr. This leaves plate #n alone on plate Src. 
2.Move plate #n from SrctoDest. 
3.Move n-1 plates from Intrto Destso they sit on plate #n.
94 
Basic ConceptsAlgorithm Specification 
Recursive algorithm: Towers of Hanoi 
Prof. A. Syed Mustafa (Ph.D)
95 
Basic ConceptsAlgorithm Specification 
Recursive algorithm: Towers of Hanoi 
Prof. A. Syed Mustafa (Ph.D) 
FUNCTION MoveTower(disk, source, dest, inter) 
IF disk== 1,THEN: 
move diskfrom sourceto dest 
ELSE: 
MoveTower(disk-1, source, inter, dest) // Step 1 above 
move diskfrom sourceto dest// Step 2 above 
MoveTower(disk-1, inter, dest, source) // Step 3 above END IF
96 
Basic ConceptsAlgorithm Specification 
Recursive algorithm: Towers of Hanoi 
Prof. A. Syed Mustafa (Ph.D)
97 
Basic ConceptsAlgorithm Specification 
Recursive algorithm: Towers of Hanoi 
Prof. A. Syed Mustafa (Ph.D)
98 
Basic ConceptsAlgorithm Specification 
Recursive algorithm: Towers of Hanoi 
Prof. A. Syed Mustafa (Ph.D)
99 
Basic ConceptsAlgorithm Specification 
Limitations of Recursion 
Recursion should not be used if the answer to any of the following questions is no: 
Is the algorithm or data structure naturally suited to recursion (tree is the first choice) ? 
Is the recursive solution shorter and more understandable? 
Does the recursive solution run within acceptable time and space limits ? 
As a general rule, recursive algorithms should be effectively used only when their efficiency is logarithmic. 
Prof. A. Syed Mustafa (Ph.D)
100 
Basic ConceptsData Abstraction 
Abstractionistheprocessbywhichdataandprogramsaredefinedwitharepresentationsimilartoitsmeaning(semantics),whilehidingawaytheimplementationdetails. 
Prof. A. Syed Mustafa (Ph.D)
101 
Basic ConceptsData Abstraction 
Abstractiontriestoreduceandfactoroutdetailssothattheprogrammercanfocusonafewconceptsatatime.Asystemcanhaveseveralabstractionlayerswherebydifferentmeaningsandamountsofdetailareexposedtotheprogrammer. 
Forexample,low-levelabstractionlayersexposedetailsofthehardwarewheretheprogramisrun,whilehigh- levellayersdealwiththebusinesslogicoftheprogram. 
Prof. A. Syed Mustafa (Ph.D)
102 
Basic ConceptsData Abstraction 
Prof. A. Syed Mustafa (Ph.D)
103 
Basic ConceptsData Abstraction 
Prof. A. Syed Mustafa (Ph.D)
104 
Basic ConceptsData Abstraction 
Prof. A. Syed Mustafa (Ph.D)
105 
Basic ConceptsData Abstraction 
Prof. A. Syed Mustafa (Ph.D)
106 
Basic ConceptsData Abstraction 
Prof. A. Syed Mustafa (Ph.D)
107 
Basic ConceptsData Abstraction 
Prof. A. Syed Mustafa (Ph.D)
108 
Basic ConceptsData Abstraction 
Prof. A. Syed Mustafa (Ph.D)
109 
Basic ConceptsData Abstraction 
Prof. A. Syed Mustafa (Ph.D)
110 
Basic ConceptsData Abstraction 
Prof. A. Syed Mustafa (Ph.D)
111 
Basic ConceptsData Abstraction 
Prof. A. Syed Mustafa (Ph.D)
112 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
113 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D) 
Space & Time 
Does the program efficiently use primary and secondary storage ? 
Is the program’s running time acceptable for the task ?
114 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
115 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D) 
The space complexity of a program is the amount of memory that it needs to run to completion. 
The time complexity of a program is the amount of computer time that it needs to run to completion
116 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
117 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
118 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
119 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
120 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
121 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
122 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
123 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
124 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
125 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
126 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D) 
TP(n) = CaADD(n)+ CsSUB(n)+CLLDA(n)+CstSTA(n) 
n –Instance Characteristic 
Ca, Cs , CL , Cst–constants-time needed to perorm 
each operation 
ADD -No of additions 
SUB -No of Subtraction 
LDA –No of Loads 
STA –No of Stores 
Performed when the program is run with instance characteristic n.
127 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
128 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
129 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
130 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
131 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
132 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D) 
General statements in a C program 
Step count 
1.Comments 0 
2.Declarative statements0 
3.Expressions and assignment statements1 
4.Iteration statementsN 
5.Switch statementN 
6.If-else statementN 
7.Function invocation1 or N 
8.Memory management statements1 or N 
9.Function statements0 
10.Jump statements1 or N
133 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D) 
Notethatastepcountdoesnotnecessarilyreflectthecomplexityofthestatement. 
Step per execution (s/e): 
Thes/eofastatementistheamountbywhichcountchangesasaresultoftheexecutionofthatstatement.
134 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
135 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
136 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
137 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
138 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
139 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
140 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
141 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
142 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
143 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
144 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
145 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
146 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
147 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
148 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
149 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
150 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
151 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
152 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
153 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
154 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
155 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
156 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
157 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
158 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
159 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
160 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
161 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
162 
Basic ConceptsPerformance Analysis 
Prof. A. Syed Mustafa (Ph.D)
Prof. A. Syed Mustafa (Ph.D) 163

Data Structure with C

  • 1.
  • 2.
  • 3.
    Syllabus 3 Prof.A. Syed Mustafa (Ph.D)
  • 4.
    Syllabus 4 Prof.A. Syed Mustafa (Ph.D)
  • 5.
    Syllabus 5 Prof.A. Syed Mustafa (Ph.D)
  • 6.
    Syllabus 6 Prof.A. Syed Mustafa (Ph.D)
  • 7.
    7 Evaluation •GradePercentage –FCD : 70% and above –FC : 60% -69% –SC : 35% -59% –FL : less than 35% •Syllabus Coverage Schedule –1stIA Test : 30% [ Portion-first 2.5 Units ] –2ndIA Test : 30% [ Portion-next 2.5 Units ] –3rdIA Test : 40% [ Portion-Last 3 Units ]
  • 8.
    8 Evaluation •Assignments –Total : 3 –Each Assignment to be submitted before the IA test begins •Attendance –Class Participation: 85% •You may get detained if you miss (more than) ¼of the whole classes •Academic dishonesty (e.g. cheating, copying, late coming and etc.) will be taken seriously
  • 9.
    9 Announcement •ClassWebsite •The link for the CMS portal is: –Intranet link: http:172.17.0.2moodle –Internet link: http:61.8.153.222moodle –http://gg.gg/hkbkis •Class information such as lecture notes can be accessible through this website •We will also use Moodle for online test
  • 10.
    10 Announcement •ProgrammingAssignments –We encourage to study and discuss together for doing programming assignments. –However, you must do programming YOURSELF. –You must not share any of source code with other students. –Any kind of academic dishonesty will be viewed very seriously.
  • 11.
    Unit -1 11Prof. A. Syed Mustafa (Ph.D) Basic concepts
  • 12.
    12 Prof. A.Syed Mustafa (Ph.D) Basic Concepts Topics : Pointers and Dynamic Memory Allocation Algorithm Specification Data Abstraction Performance Analysis Performance Measurement
  • 13.
    13 Prof. A.Syed Mustafa (Ph.D) Basic Concepts Objectives Understanding core concepts of memory management, performance analysis. Applying the pointer concepts to actual programming managing memory efficiently Improve the performance.
  • 14.
    14 Prof. A.Syed Mustafa (Ph.D) Basic Concepts Course Outcome: Able to apply the pointer concepts to actual programming Able to use memory efficiently Able to increase the performance of the program.
  • 15.
    15 Prof. A.Syed Mustafa (Ph.D) Basic ConceptsSystem Life Cycle •Large-Scaleprogramcontainsmanycomplexinteractingparts. •Programsundergoadevelopmentprocesscalledthesystemlifecycle. •Solidfoundationin 1.dataabstraction 2.algorithmspecification 3.performanceanalysisandmeasurement providesnecessarymethodology.
  • 16.
    16 Prof. A.Syed Mustafa (Ph.D) Basic ConceptsSystem Life Cycle 5phasesofsystemlifecycle: 1.Requirements:Beginswithdefiningpurposeoftheproject. Whatinputs(needs),outputs(results) 2.Analysis:Breaktheproblemdownintomanageablepieces. bottom-upvs.top-down,divideandconquer 3.Design:dataobjectsandoperationscreationofabstractdatatypes,thespecificationofalgorithmsandalgorithmdesignstrategies,ignorecodingdetails. 4.Refinement&coding:chooserepresentationsforourdataobjectsandwritealgorithmsforeachoperationonthem. weshouldwritethosealgorithmsthatareindependentofthedataobjectsfirst.
  • 17.
    17 Prof. A.Syed Mustafa (Ph.D) Basic ConceptsSystem Life Cycle 5.Verification:consistsofdevelopingcorrectnessproofsfortheprogram,testingtheprogramwithavarietyofinputdataandremovingerrors. Correctnessproofs:proofsareverytime-consuminganddifficulttodevelopforlargeprojects.Schedulingconstraintspreventthedevelopmentofacompletesetofproofsforalargesystem. Testing:beforeandduringthecodingphase.testingisusedatkeycheckpointsintheoverallprocesstodeterminewhetherobjectivesarebeingmet. ErrorRemoval:systemtestswillindicateerroneouscode. Errorscanberemoveddependingonthedesign&codingdecisionsmadeearlier.
  • 18.
    18 •ForanytypeTinCthereisacorrespondingtypepointer-to-T. •Theactualvalueofapointertypeisanaddressofmemory. –&theaddressoperator. –*thedereferencing(orindirection)operator. –Declaration •inti,*ip;//iisanintegervariableandipisapointertoaninteger. •ip=&i; then&ireturnstheaddressofiandassignsitasthevalueofpi. Basic ConceptsPointers Prof. A. Syed Mustafa (Ph.D)
  • 19.
    19 Basic ConceptsPointers •i=10or*ip=10; Inbothcasestheinteger10isstoredasthevalueofi. Insecondcase,the*infrontofthepointeripcausesittobedereferenced, bywhichwemeanthatinsteadofstoring10intothepointer,10isstoredintothelocationpointedatbythepointerip. Prof. A. Syed Mustafa (Ph.D)
  • 20.
    20 Basic ConceptsPointers Thesizeofapointercanbedifferentondifferentcomputers. Thesizeofapointertoacharcanbelongerthanapointertoafloat. TestforthenullpointerinC if(ip==NULL)orif(ip==0)orif(!ip)
  • 21.
    21 Basic ConceptsPointers Thenullpointerpointstonoobjectorfunction. Thenullpointerisrepresentedbytheintegeras0anincharacteras‘0’.TheASCIIvalueforNULLis0. Thenullpointerisinterpretedasfalseinrelationalexpressions. Prof. A. Syed Mustafa (Ph.D)
  • 22.
    22 Basic ConceptsDynamicMemory Allocation •Whenwewriteprogram,wemaynotknowhow muchspacewemayneed,tostoredata. •Cprovidesamechanismcalledaheap,for allocatingstorageatrun-time. •Thefunctionmalloc()isusedtoallocateanew areaofmemory. Prof. A. Syed Mustafa (Ph.D)
  • 23.
    23 Basic ConceptsDynamicMemory Allocation malloc() Syntax void *malloc(size_tsize) Parameters •size--This is the size of the memory block, in bytes. Return Value •This function returns a pointer to the allocated memory, or NULLif the request fails Prof. A. Syed Mustafa (Ph.D)
  • 24.
    24 Basic ConceptsDynamicMemory Allocation malloc() •The name mallocstands for "memory allocation". •Thefunctionmalloc()reservesablockofmemoryofspecifiedsizeandreturnapointeroftypevoidwhichcanbecastedintopointerofanyform. Prof. A. Syed Mustafa (Ph.D)
  • 25.
    25 Basic ConceptsDynamicMemory Allocation •Whenmemoryisnolongerneeded,wemayfreeitbycallingfree()function. •Thecalltomalloc()determinessizeofstoragerequiredtoholdintorthefloat. •Thenotations(int*)and(float*)aretypecastexpressions. Prof. A. Syed Mustafa (Ph.D)
  • 26.
    26 Basic ConceptsDynamicMemory Allocation •Theresultisapointertothefirstbyteofastorageareaofthepropersize. •Thereturnvalueofthemalloc()isvoid*. •Acalltomalloc()mayfailforlackofsufficientmemory Prof. A. Syed Mustafa (Ph.D)
  • 27.
    27 Basic ConceptsDynamicMemory Allocation Example: int*pi; float *pf; pi = (int*) malloc(sizeof(int)); pf = (float *) malloc(sizeof(float)); *pi=1024; *pf=3.124; printf(“an integer = %d, a float = %fn”,*pi,*pf); free(pi); free(pf); Prof. A. Syed Mustafa (Ph.D)
  • 28.
    28 Basic ConceptsDynamicMemory Allocation •WhenprogramminginCitisawisepracticetosetallpointerstoNULLwhentheyarenotpointingtoanobject. •Useexplicittypecastswhenconvertingbetweenpointertypes: pi=malloc(sizeof(int));/*assigntopiapointertoint*/ pf=(float*)pi;/*castsanintpointertofloatpointer*/ •Inmanysystems,pointershavethesamesizeastypeint.intisthedefaulttypespecifier. Prof. A. Syed Mustafa (Ph.D)
  • 29.
    29 Basic ConceptsDynamicMemory Allocation calloc() •The name callocstands for "contiguous memory allocation“ or ‘c’for cleared. •Thefunctioncalloc()allocatesablockofmemoryforanarrayofnumelements,eachofthemsizebyteslong,andinitializesallitsbitstozero.
  • 30.
    30 Basic ConceptsDynamicMemory Allocation calloc() Syntax void* calloc(size_tnum, size_tsize); Parameters •num--Number of elements to allocate. •size--Size of each element •size_tis an unsigned integral type. Return Value •On success, a pointerto the memory block allocated by the function. •The type of this pointer is alwaysvoid*, which can be cast to the desired type of data pointer in order to be dereferenceable. • If the function failed to allocate the requested block of memory, anull pointeris returned. Prof. A. Syed Mustafa (Ph.D)
  • 31.
    31 Basic ConceptsDynamicMemory Allocation calloc() Example int*ptr1,*ptr2; ptr1 = (int*)calloc(10, sizeof(int)); ptr2=(int*)calloc(20,sizeof(float)); Prof. A. Syed Mustafa (Ph.D)
  • 32.
    32 Basic ConceptsDynamicMemory Allocation malloc() & calloc() Differrence Theonlydifferencebetweenmalloc()andcalloc()isthat,malloc()allocatessingleblockofmemorywhereascalloc()allocatesmultipleblocksofmemoryeachofsamesizeandsetsallbytestozero. Prof. A. Syed Mustafa (Ph.D)
  • 33.
    33 Basic ConceptsDynamicMemory Allocation malloc() & calloc() Differrence mallocfunction,whereastheareareservedtothestatesthatareundefined,theareaallocatedbythecallocfunctioncontainsa0. Infact,thecallocfunctionisinternallymaybeafunctionthatcallsmalloc.Aftersecuringfunctionbymalloc,theareaisfilledwith0. Prof. A. Syed Mustafa (Ph.D)
  • 34.
    34 Basic ConceptsDynamicMemory Allocation free() Syntax void free(void *ptr) Parameters •ptr--Pointer to a memory block previously allocated withmalloc(), calloc() or realloc(). Return Value •None Note: If the memeoryis not freed , then Dangling pointer arises which leads to garbagecollection. Prof. A. Syed Mustafa (Ph.D)
  • 35.
    35 Basic ConceptsDynamicMemory Allocation Prof. A. Syed Mustafa (Ph.D)
  • 36.
    36 Basic ConceptsDynamicMemory Allocation Prof. A. Syed Mustafa (Ph.D)
  • 37.
    37 Basic ConceptsDynamicMemory Allocation Prof. A. Syed Mustafa (Ph.D)
  • 38.
    38 Basic ConceptsDynamicMemory Allocation Prof. A. Syed Mustafa (Ph.D)
  • 39.
    39 Basic ConceptsDynamicMemory Allocation realloc() -Reallocate memory block void*realloc(void*ptr,size_tsize) •TheClibraryfunctionattemptstoresizethememoryblockpointedtobyptrthatwaspreviouslyallocatedwithacalltomallocorcallocorrealloc Parameters ptr--Thisisthepointertoamemoryblockpreviouslyallocatedwithmalloc,callocorrealloctobereallocated.IfthisisNULL,anewblockisallocatedandapointertoitisreturnedbythefunction •size--Thisisthenewsizeforthememoryblock,inbytes.Ifitis0andptrpointstoanexistingblockofmemory,thememoryblockpointedbyptrisdeallocatedandaNULLpointerisreturned. ReturnValue Thisfunctionreturnsapointertothenewlyallocatedmemory,orNULLiftherequestfails. Prof. A. Syed Mustafa (Ph.D)
  • 40.
    40 Basic ConceptsDynamicMemory Allocation realloc() -Reallocate memory block •Thefunctionrealloc()reallocatesamemoryblockwithaspecificnewsize. •Ifwecallrealloc()thesizeofthememoryblockpointedtobythepointerischangedtothegivensizeinbytes. •Thiswayweareabletoexpandandreducetheamountofmemoryyouwanttouse(ifavailableofcourse.) •Itispossiblethatthefunctionmovesthememoryblocktoanewlocation, inwhichwaythefunctionwillreturnthisnewlocation. •Ifthesizeoftherequestedblockislargerthenthepreviousblockthenthevalueofthenewportionisindeterminate. Prof. A. Syed Mustafa (Ph.D)
  • 41.
    41 Basic ConceptsDynamicMemory Allocation realloc() -Reallocate memory block •Thereturnvalueisapointertothereallocatedmemoryblock,whichmaybeeitherthesameasptroranewlocation. •Thetypeofreturnpointerisvoid*,whichcanbecasttothedesiredtypeofdatapointerinordertobedereferenceable •IfthepointerisNULLthenthefunctionwillbehaveexactlylikethefunctionmalloc().Itwillassignanewblockofasizeinbytesandwillreturnapointertoit. •Ifthesizeis0thenthememorythatwaspreviouslyallocatedisfreedasifacallofthefunctionfree()wasgiven.ItwillreturnaNULLpointerinthatcase. Prof. A. Syed Mustafa (Ph.D)
  • 42.
    42 •. #include<stdlib.h> #include<stdio.h> intmain() {char*str; str=(char*)malloc(4);/* Initial memory allocation */ strcpy(str,“data"); printf("String = %s, Address = %pn",str,str); /* Reallocating memory */ str=(char*)realloc(str,13); strcat(str,“structure"); printf("String = %s, Address = %pn",str,str); free(str); return(0); } Basic ConceptsDynamic Memory Allocation Prof. A. Syed Mustafa (Ph.D)
  • 43.
    43 Basic ConceptsDynamicMemory Allocation free() •Deallocatememory block •A block of memory previously allocated by a call to malloc(), calloc() or realloc() is deallocated, making it available again for further allocations. Ifptrdoes not point to a block of memory allocated with the above functions, it causesundefined behavior. Ifptris anull pointer, the function does nothing. This function does not change the value ofptritself, hence it still points to the same (now invalid) location. Prof. A. Syed Mustafa (Ph.D)
  • 44.
    44 Basic ConceptsDynamicMemory Allocation free() /* example */ #include <stdlib.h> /* malloc, calloc, realloc, free */ intmain () { int* i1, * i2, * i3; i1 = (int*) malloc(100*sizeof(int)); i2 = (int*) calloc(100,sizeof(int)); i3 = (int*) realloc(i2,500*sizeof(int)); free (i1); free (i3); return 0; } Prof. A. Syed Mustafa (Ph.D)
  • 45.
    45 Basic ConceptsAlgorithmSpecification Analgorithmisafinitesetofinstructionsthat,iffollowed,accomplishesaparticulartask. Algorithmsmustsatisfyfollowingcriteria: Input:therearezeroormorequantitiesthatareexternallysupplied. Output:atleastonequantityisproduced. Definiteness:Eachinstructionisclearandunambiguous. Finiteness:forallcases,thealgorithmterminatesafterafinitenumberofsteps. Effectiveness:Everyinstructionmustbebasicenoughtobecarriedout,itmustalsobefeasible. Prof. A. Syed Mustafa (Ph.D)
  • 46.
    46 Basic ConceptsAlgorithmSpecification •Differencebetweenanalgorithmandaprogram: Theprogramdoesnothavetosatisfythefourthcondition(Finiteness). •Describinganalgorithm: NaturallanguagesuchasEnglishcanbeused.Makesureresultinginstructionsaredefinite. •Flowchart: workwellonlyforalgorithm,smallandsimple. Prof. A. Syed Mustafa (Ph.D)
  • 47.
    47 Basic ConceptsAlgorithmSpecification •Differencebetweenanalgorithmandaprogram: Theprogramdoesnothavetosatisfythefourthcondition(Finiteness). •Describinganalgorithm: NaturallanguagesuchasEnglishcanbeused.Makesureresultinginstructionsaredefinite. •Flowchart: workwellonlyforalgorithm,smallandsimple. Prof. A. Syed Mustafa (Ph.D)
  • 48.
    48 Basic ConceptsAlgorithmSpecification Translating a Problem into an Algorithm Example-SelectionSort Deviseaprogramthatsortsasetofnintegers, wheren>=1,fromsmallesttolargest. SolutionI: Fromthoseintegersthatarecurrentlyunsorted, findthesmallestandplaceitnextinthesortedlist . Prof. A. Syed Mustafa (Ph.D)
  • 49.
    49 Basic ConceptsAlgorithmSpecification Translating a Problem into an Algorithm Describessortingtechnique,butitisnotanalgorithm Problems: 1.Does not describe where and how the integers are initially sorted. 2.Does not indicate where to place the result. . Prof. A. Syed Mustafa (Ph.D)
  • 50.
    50 Basic ConceptsAlgorithmSpecification Translating a Problem into an Algorithm SolutionII:SelectionSort Analgorithm,writteninpartiallyCandEnglish for(i=0;i<n;i++) { Examinelist[i]tolist[n-1]andsupposethat thesmallestintegerislist[min]; Interchangelist[i]andlist[min]; } .
  • 51.
    51 Basic ConceptsAlgorithmSpecification Selection Sort -find the smallest integer -interchange or swap -we can solve the problem using a function or macro void swap(int*x, int*y) // both arguments are pointers { inttemp= *x; *x= *y; *y= temp; } Prof. A. Syed Mustafa (Ph.D)
  • 52.
    52 Basic ConceptsAlgorithmSpecification Selection Sort #define swap(x,y,t)((t)= (x), (x)= (y), (y)= (t)) void sort(intlist[ ], intn) { inti, j, min, temp; for (i= 0; i< n-1; i++){ min= i; for (j= i+1; j< n; j++){ if (list[j]< list[min]) min= j; } swap(list[i], list[min], temp); } Prof. A. Syed Mustafa (Ph.D)
  • 53.
    53 Basic ConceptsAlgorithmSpecification Theorem 1.1: sort(a, n) correctly sorts a set of n≥ 1 integers; the result remains in a[0] … a[n-1] such that a[0] ≤ a[1] ≤ … ≤ a[n–1]. Prof. A. Syed Mustafa (Ph.D)
  • 54.
    54 Basic ConceptsAlgorithmSpecification Example: Binary Search Assumethatwehaven≥1distinctintegersthatarealreadysortedandstoredinthearraya[0]…a[n-1]. Ourtaskistodetermineiftheintegerxispresentandifsotoreturnjsuchthatx=a[j];otherwisereturn-1. Prof. A. Syed Mustafa (Ph.D)
  • 55.
    55 Basic ConceptsAlgorithmSpecification Example: Binary Search 1.Let leftand right, respectively, denote the left and right ends of the list to be searched. 2.Initially, left = 0 and right = n –1. 3.Let middle = (left +right) / 2 be the middle position in the list. 4.If we compare a[middle]with x, we obtain one of the three results. Prof. A. Syed Mustafa (Ph.D)
  • 56.
    56 Basic ConceptsAlgorithmSpecification Example: Binary Search 1.x < a[middle] In this case, if xis present, it must be in the positions between 0 and middle–1. Therefore, we set right to middle–1. 2.x== a[middle] In this case, we return middle. 3. x> a[middle] Inthiscase,ifxispresent,itmustbeinthepositionsbetweenmiddle+1andn-1.So,wesetlefttomiddle+1. Prof. A. Syed Mustafa (Ph.D)
  • 57.
    57 Basic ConceptsAlgorithmSpecification Binary Search. Prof. A. Syed Mustafa (Ph.D)
  • 58.
    58 Basic ConceptsAlgorithmSpecification Binary Search. intcompare(intx, inty) { if(x < y) return-1; else if( x == y) return0; else return1; } // end of compare Macro #define compare(x, y) ( ( (x) < (y) ) ? -1: ( (x) == (y) ) ? 0 : 1 ) Prof. A. Syed Mustafa (Ph.D)
  • 59.
    59 Basic ConceptsAlgorithmSpecification Algorithms are implemented as functions in C. Functions divide the programs into manageable pieces. They make program easier to read. Functions can be tested separately. Declare function first then define it later. Prof. A. Syed Mustafa (Ph.D)
  • 60.
    60 Basic ConceptsAlgorithmSpecification Recursive algorithm Therearemainlytwoapproachesforrepetitive approach. 1.Iteration 2.Recursion Recursionisarepetitiveprocessinwhichanalgorithmcallsitself. Prof. A. Syed Mustafa (Ph.D)
  • 61.
    61 Basic ConceptsAlgorithmSpecification Recursive algorithm The following Figure 1 and Figure 2 portrayed the typical pictorial examples for recursive calling. Prof. A. Syed Mustafa (Ph.D)
  • 62.
    62 Basic ConceptsAlgorithmSpecification Recursive algorithm The following Figure2 portrayed the typical pictorial examples for recursive calling. Prof. A. Syed Mustafa (Ph.D)
  • 63.
    63 Basic ConceptsAlgorithmSpecification Recursive algorithm The following Figure portrayed the typical pictorial examples for recursive calling. Prof. A. Syed Mustafa (Ph.D)
  • 64.
    64 Basic ConceptsAlgorithmSpecification Recursive algorithm Recursionisaprogrammingtechniqueinwhichamethodcancallitselftosolveaproblem. TwoTypes: 1.DirectRecursion 2.Indirectrecursion Prof. A. Syed Mustafa (Ph.D)
  • 65.
    65 Basic ConceptsAlgorithmSpecification Recursive algorithm 1.DirectRecursion Functionscallsthemselves 2.Indirectrecursion Functions calls other function that invoke the calling function again. Any function that we can write using assignment, if- else and while statements can be written recursively. Prof. A. Syed Mustafa (Ph.D)
  • 66.
    66 Basic ConceptsAlgorithmSpecification Value of Recursion This is well suited an alternative concept in the following situations 1. Recursion can be used to replace loop 2. A recursive procedure is mathematically more elegant than one using loops 3. Sometime procedure that would tricky to write a loop are straightforward to using recursion. 4. Recursively defined data structure, like list, are very well suited to processing by recursive procedures and functions Prof. A. Syed Mustafa (Ph.D)
  • 67.
    67 Basic ConceptsAlgorithmSpecification Prof. A. Syed Mustafa (Ph.D)
  • 68.
    68 Basic ConceptsAlgorithmSpecification Prof. A. Syed Mustafa (Ph.D)
  • 69.
    69 Basic ConceptsAlgorithmSpecification Algorithm to compute factorial using recursive method: Factorial (N) 1. Receive N 2. if N > 1 return Factorial(N-1) * N else return 1 Prof. A. Syed Mustafa (Ph.D)
  • 70.
    70 Basic ConceptsAlgorithmSpecification program to compute factorial using recursive function: #include<stdio.h> longfactorial(int); intmain() {intn;longf; printf("Enter an integer to find factorialn"); scanf("%d",&n); if(n <0)printf("Negative integers are not allowedn"); else{f =factorial(n);printf("%d! = %ldn",n,f);} return0;} longfactorial(intn) {if (n ==0)return 1; else return(n*factorial(n-1)); } Prof. A. Syed Mustafa (Ph.D)
  • 71.
    71 Basic ConceptsAlgorithmSpecification program to compute factorial using recursive function: Prof. A. Syed Mustafa (Ph.D)
  • 72.
    72 Basic ConceptsAlgorithmSpecification program to compute factorial using recursive function: Prof. A. Syed Mustafa (Ph.D)
  • 73.
    73 Basic ConceptsAlgorithmSpecification program to compute factorial using recursive function: Prof. A. Syed Mustafa (Ph.D)
  • 74.
    74 Basic ConceptsAlgorithmSpecification program to compute factorial using recursive function: Prof. A. Syed Mustafa (Ph.D)
  • 75.
    75 Basic ConceptsAlgorithmSpecification program to compute factorial using recursive function: Prof. A. Syed Mustafa (Ph.D)
  • 76.
    76 Basic ConceptsAlgorithmSpecification Prof. A. Syed Mustafa (Ph.D)
  • 77.
    77 Basic ConceptsAlgorithmSpecification Prof. A. Syed Mustafa (Ph.D)
  • 78.
    78 Basic ConceptsAlgorithmSpecification Prof. A. Syed Mustafa (Ph.D)
  • 79.
    79 Basic ConceptsAlgorithmSpecification Recursive program: Fibonacci intmain() { intn=10; printf(“%d”, rfib(n)); } intrfib(intn) { if (n==1 || n==2) return 1; return rfib(n1) + rfib(n2); } Prof. A. Syed Mustafa (Ph.D)
  • 80.
    80 Basic ConceptsAlgorithmSpecification Recursive program: Fibonacci Prof. A. Syed Mustafa (Ph.D)
  • 81.
    81 Basic ConceptsAlgorithmSpecification Recursive program: Fibonacci Prof. A. Syed Mustafa (Ph.D)
  • 82.
    82 Basic ConceptsAlgorithmSpecification Recursive program: Fibonacci Prof. A. Syed Mustafa (Ph.D)
  • 83.
    83 Basic ConceptsAlgorithmSpecification Recursive algorithm: Greatest Common Divisor(x, y) Prof. A. Syed Mustafa (Ph.D)
  • 84.
    84 Basic ConceptsAlgorithmSpecification /* PROGRAM TO FIND GCD OF TWO NUMBER USING RECURSION EUCLIDS*/ #include<stdio.h> #include<conio.h> intgcd(int,int); intmain() {inta,b; clrscr(); printf("n Enter two number:" ); scanf("%d %d",&a,&b); printf("GCD of two number : %d" ,gcd(a,b)); getch(); return(0); } Prof. A. Syed Mustafa (Ph.D)
  • 85.
    85 Basic ConceptsAlgorithmSpecification /* PROGRAM TO FIND GCD OF TWO NUMBER USING RECURSION intgcd(intm, intn) { if(m==0) return n; if(n==0) return m; return gcd(n,m%n); } Prof. A. Syed Mustafa (Ph.D)
  • 86.
    86 Basic ConceptsAlgorithmSpecification /* PROGRAM TO FIND GCD OF TWO NUMBER USING RECURSION intgcd(inta,intb) { if(a !=b) { if(a >b) returngcd(a -b,b); else returngcd(a,b -a); } returna; } Prof. A. Syed Mustafa (Ph.D)
  • 87.
    87 Basic ConceptsAlgorithmSpecification Recursive algorithm: Greatest Common Divisor(x, y) Prof. A. Syed Mustafa (Ph.D)
  • 88.
    88 Basic ConceptsAlgorithmSpecification Recursive algorithm Prof. A. Syed Mustafa (Ph.D)
  • 89.
    89 Basic ConceptsAlgorithmSpecification Recursive algorithm Prof. A. Syed Mustafa (Ph.D) C(n, k) = C(n-1, k-1) + C(n-1, k) C(n, 0) = C(n, n) = 1
  • 90.
    90 Basic ConceptsAlgorithmSpecification Recursive algorithm-Binomial Coefficient Prof. A. Syed Mustafa (Ph.D) intbinomialCoeff(intn, intk)// Returns value of Binomial Coefficient C(n, k) { if (k==0 || k==n)// Base Cases return 1; return binomialCoeff(n-1, k-1) + binomialCoeff(n-1, k);// Recur } intmain()/* program to test above function*/ { intn = 5, k = 2; printf("Value of C(%d, %d) is %d ", n, k, binomialCoeff(n, k)); // C(5,2) is 10 return 0; }
  • 91.
    91 Basic ConceptsAlgorithmSpecification Recursive algorithm -Binomial Coefficient Prof. A. Syed Mustafa (Ph.D)
  • 92.
    92 Basic ConceptsAlgorithmSpecification Recursive algorithm: Towers of Hanoi Prof. A. Syed Mustafa (Ph.D)
  • 93.
    93 Basic ConceptsAlgorithmSpecification Recursive algorithm: Towers of Hanoi Prof. A. Syed Mustafa (Ph.D) •Label the stands Src, Intr,Dest. •Letnbe the total number of discs. •Number the discs from 1 (smallest, topmost) ton(largest, bottommost). To move n discs from stand Srcto stand Dest: 1.Move n-1 plates from Srcto Intr. This leaves plate #n alone on plate Src. 2.Move plate #n from SrctoDest. 3.Move n-1 plates from Intrto Destso they sit on plate #n.
  • 94.
    94 Basic ConceptsAlgorithmSpecification Recursive algorithm: Towers of Hanoi Prof. A. Syed Mustafa (Ph.D)
  • 95.
    95 Basic ConceptsAlgorithmSpecification Recursive algorithm: Towers of Hanoi Prof. A. Syed Mustafa (Ph.D) FUNCTION MoveTower(disk, source, dest, inter) IF disk== 1,THEN: move diskfrom sourceto dest ELSE: MoveTower(disk-1, source, inter, dest) // Step 1 above move diskfrom sourceto dest// Step 2 above MoveTower(disk-1, inter, dest, source) // Step 3 above END IF
  • 96.
    96 Basic ConceptsAlgorithmSpecification Recursive algorithm: Towers of Hanoi Prof. A. Syed Mustafa (Ph.D)
  • 97.
    97 Basic ConceptsAlgorithmSpecification Recursive algorithm: Towers of Hanoi Prof. A. Syed Mustafa (Ph.D)
  • 98.
    98 Basic ConceptsAlgorithmSpecification Recursive algorithm: Towers of Hanoi Prof. A. Syed Mustafa (Ph.D)
  • 99.
    99 Basic ConceptsAlgorithmSpecification Limitations of Recursion Recursion should not be used if the answer to any of the following questions is no: Is the algorithm or data structure naturally suited to recursion (tree is the first choice) ? Is the recursive solution shorter and more understandable? Does the recursive solution run within acceptable time and space limits ? As a general rule, recursive algorithms should be effectively used only when their efficiency is logarithmic. Prof. A. Syed Mustafa (Ph.D)
  • 100.
    100 Basic ConceptsDataAbstraction Abstractionistheprocessbywhichdataandprogramsaredefinedwitharepresentationsimilartoitsmeaning(semantics),whilehidingawaytheimplementationdetails. Prof. A. Syed Mustafa (Ph.D)
  • 101.
    101 Basic ConceptsDataAbstraction Abstractiontriestoreduceandfactoroutdetailssothattheprogrammercanfocusonafewconceptsatatime.Asystemcanhaveseveralabstractionlayerswherebydifferentmeaningsandamountsofdetailareexposedtotheprogrammer. Forexample,low-levelabstractionlayersexposedetailsofthehardwarewheretheprogramisrun,whilehigh- levellayersdealwiththebusinesslogicoftheprogram. Prof. A. Syed Mustafa (Ph.D)
  • 102.
    102 Basic ConceptsDataAbstraction Prof. A. Syed Mustafa (Ph.D)
  • 103.
    103 Basic ConceptsDataAbstraction Prof. A. Syed Mustafa (Ph.D)
  • 104.
    104 Basic ConceptsDataAbstraction Prof. A. Syed Mustafa (Ph.D)
  • 105.
    105 Basic ConceptsDataAbstraction Prof. A. Syed Mustafa (Ph.D)
  • 106.
    106 Basic ConceptsDataAbstraction Prof. A. Syed Mustafa (Ph.D)
  • 107.
    107 Basic ConceptsDataAbstraction Prof. A. Syed Mustafa (Ph.D)
  • 108.
    108 Basic ConceptsDataAbstraction Prof. A. Syed Mustafa (Ph.D)
  • 109.
    109 Basic ConceptsDataAbstraction Prof. A. Syed Mustafa (Ph.D)
  • 110.
    110 Basic ConceptsDataAbstraction Prof. A. Syed Mustafa (Ph.D)
  • 111.
    111 Basic ConceptsDataAbstraction Prof. A. Syed Mustafa (Ph.D)
  • 112.
    112 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 113.
    113 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D) Space & Time Does the program efficiently use primary and secondary storage ? Is the program’s running time acceptable for the task ?
  • 114.
    114 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 115.
    115 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D) The space complexity of a program is the amount of memory that it needs to run to completion. The time complexity of a program is the amount of computer time that it needs to run to completion
  • 116.
    116 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 117.
    117 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 118.
    118 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 119.
    119 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 120.
    120 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 121.
    121 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 122.
    122 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 123.
    123 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 124.
    124 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 125.
    125 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 126.
    126 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D) TP(n) = CaADD(n)+ CsSUB(n)+CLLDA(n)+CstSTA(n) n –Instance Characteristic Ca, Cs , CL , Cst–constants-time needed to perorm each operation ADD -No of additions SUB -No of Subtraction LDA –No of Loads STA –No of Stores Performed when the program is run with instance characteristic n.
  • 127.
    127 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 128.
    128 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 129.
    129 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 130.
    130 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 131.
    131 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 132.
    132 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D) General statements in a C program Step count 1.Comments 0 2.Declarative statements0 3.Expressions and assignment statements1 4.Iteration statementsN 5.Switch statementN 6.If-else statementN 7.Function invocation1 or N 8.Memory management statements1 or N 9.Function statements0 10.Jump statements1 or N
  • 133.
    133 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D) Notethatastepcountdoesnotnecessarilyreflectthecomplexityofthestatement. Step per execution (s/e): Thes/eofastatementistheamountbywhichcountchangesasaresultoftheexecutionofthatstatement.
  • 134.
    134 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 135.
    135 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 136.
    136 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 137.
    137 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 138.
    138 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 139.
    139 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 140.
    140 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 141.
    141 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 142.
    142 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 143.
    143 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 144.
    144 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 145.
    145 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 146.
    146 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 147.
    147 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 148.
    148 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 149.
    149 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 150.
    150 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 151.
    151 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 152.
    152 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 153.
    153 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 154.
    154 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 155.
    155 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 156.
    156 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 157.
    157 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 158.
    158 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 159.
    159 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 160.
    160 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 161.
    161 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 162.
    162 Basic ConceptsPerformanceAnalysis Prof. A. Syed Mustafa (Ph.D)
  • 163.
    Prof. A. SyedMustafa (Ph.D) 163