Lab 2
Lab 2
Checked on:
Signature:
Objective
The objective of this course is to provide the knowledge of basic data structures and their implementations.
Equipment and Component
Component Description Value Quantity
Computer Available in lab 1
Conduct of Lab
1. Students are required to perform this experiment individually.
2. In case the lab experiment is not understood, the students are advised to seek help from the
course instructor, lab engineers, assigned teaching assistants (TA) and lab attendants.
Time Complexity is a type of computational complexity that describes the time required to execute an
algorithm. The time complexity of an algorithm is the amount of time it takes for each statement to complete.
As a result, it is highly dependent on the size of the processed data. How much time does mean:
How fast is your computer? Are we running other programs simultaneously? Which programming languages
you are using etc.
It is basically how the time taken to execute the program increases with the increase in input size. There are
three types of measurements such as: Best Case, Average Case, Worst Case. Rules for calculating complexity:
1. Find the fastest growing term (dominating term) & ignore low order terms.
2. Take out the coefficient (ignore constant).
Tasks
Task 1: Accept the assignment posted in Google Classroom and after accepting clone the repository to your
computer for this ensure you have logged into github app with your account.
Task 2: Solve the given problems written after task instructions, write code through IDE like CLion
Task 4: Commit and Push the changes through the Github App
Task A
Find the time and space complexities of the following expression & codes and express it in terms of big
O:
a) x = 15 – (35/7);
x = 15 – (35/7); 1 1 1
b) x = 15 – (35/7);
cout<<x;
y = 5*9;
cout<<y;
x = 15 – (35/7); 1 1 1
cout<<x; 1 1 1
y=5*9; 1 1 1
cout<<y; 1 1 1
i=1 1 n n
i++ 1 n n
cout<<”Enter value 1 1 1
of n”;
cin>>n; 1 1 1
i=1 1 n n
i<=n 1 n n
i++ 1 n n
x=1; 1 n n
x<=n; 1 n n
y=1; 1 n n
y<=n; 1 n n
x=5*9; 1 1 1
i=1; 1 1 1
i<n; 1 n n
cout<<i; 1 n n
x=1; 1 1 1
x<=n; 1 n n
y=1; 1 n n
y<=n; 1 n n
1)
int sum, i, j; 1 1 1
sum=0; 1 1 1
i=0; 1 1 1
++i; 1 n n
sum++; 1 n n
int sum, i; 1 1 1
sum=0; 1 1 1
i=1; 1 1 1
int sum, i, j; 1 1 1
sum=0; 1 1 1
i=1; 1 1 1
i<=n; 1 n n
j=0; 1 n n
int sum, i, j; 1 1 1
sum=0; 1 1 1
i=1; 1 1 1
j=0; 1 n n
int sum, i, j; 1 1 1
sum=0; 1 1 1
i=1; 1 1 1
i<=n; 1 n n
i=i*2; 1 n n
j=0; 1 n n
int sum, i, j; 1 1 1
sum=0; 1 1 1
i=1; 1 1 1
i<=n; 1 n n
i=i*2; 1 n n
j=0; 1 n n
Performance metric Able to complete the task Able to complete the Able to complete the
CLO Marks
over 80% (4-5) task 50-80% (2-3) task below 50% (0-1)
Executes without errors, Does not execute due
Executes without errors
user prompts are to syntax errors,
excellent user prompts,
understandable, runtime errors, user
good use of symbols,
1. Realization of minimum use of symbols prompts are
1 spacing in output.
experiment or spacing in output. misleading or non-
Through testing has been Some testing has been existent. No testing
completed. completed. has been completed.