0% found this document useful (0 votes)
23 views

Assignment 1

Uploaded by

Engr Sameer Hani
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Assignment 1

Uploaded by

Engr Sameer Hani
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment # 1

SE-305 Analysis of Algorithms

Section (Alpha and Omega)

Due Date and Time: 25 September, 2023 Marks: 110

Instructions:

 Late assignment will not be accepted.


 Follow the question sequence in your solution.

COURSE LEARNING OUTCOME (CLO) PROGRAM LEARNING OUTCOME (PLO)


1. Identify the basic techniques for designing 1
algorithms.
2. Express the concept of Time and Space complexity. 2
3. Apply the algorithms design techniques on different 3
kinds of problems by using C++ or Java.
Question 1: [20 Marks]
Programming problem:
Consider the following :
unsigned long A←0;
for(i← 1;i<=n;i++)
for(j ←1;j<=n;j++)
for(k← i;k<=n;k++)
A←A+1;
a) Code the program segment in a programming language of your choice.
b) Calculate the execution time for the program in part a for values of
n=500,1000,1500,2000,2500,3000,3500,4000…,8000 and create a table for T(N) as shown in Hint sample
Table. Note: (This task will take a lot of time, be patient).
Hint: Sample Table

c) From part b, find experimentally the efficiency of this algorithm.


d) Find A as a function of n?
e) Approximate the speed of your computer in performing the addition (take the average of 5 values of the
table in part b, then use the function of part d to calculate the speed).
Note: To find the time execution of any program you have to use the internal clock of your system, to do
that use:
In C/C++: The function clock() which is define in either time.h or ctime its return an approximation the
number of CPU “clock ticks” used upon to the point of calling, to convert it to second use the constant
CLOCKS_PER_SEC which define also in time.h or ctime. Like the following:
#include<time.h>
#include<ctime>
int main(){
double time;
clock_t start,finish;
start=clock();
// Put your program here
finish=clock();
time=(((finish-start)/(double)CLOCKS_PER_SEC));
return 0;}
In JAVA: use the function currentTimeMillis() define in the System class.
long start =System.currentTimeMillis();
//put Your program here
long finish=System.currentTimeMillis();
double time = (finish-start)/(double)1000;
Question 2. Asymptotic Growth [30 Marks]

Sort all the functions below in increasing order of asymptotic (big-O) growth. If some have the same
asymptotic growth, then be sure to indicate that. As usual, lg means base 2

12.
13.
14.
15.

Question 3 . Solving Recurrence [30 Marks]


Solve by using any recursive method [iterative/Tree/ Master]
Question 4 . Compute the sums [30 Marks]

You might also like