Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

ANALYSIS OF DATA STRUCTURES

Rating
-
Sold
-
Pages
2
Uploaded on
04-04-2023
Written in
2022/2023

This Algorithms and Data Structures course will teach you everything you need to prepare for placements, interviews and logic building. This playlist will teach you how to create optimal solutions to your real world problems. We will cover a wide variety of data structures and algorithms in this course. Make sure to access the notes I have provided along with the course.

Show more Read less
Institution
Course

Content preview

How to Calculate Time Complexity of an Algorithm + Solved Questions (With
Notes)
CodeWithHarry
Before Solving Some Questions of Time Complexity I will tell you some
tricks to get rid of time complexity. After that we will do some set of
questions. which will make you a very good grasp in such questions. due
to the time complexity of any algorithm when you have to find it so what
is the first step that you do and at the same time how to approach this
problem. In this way, whatever instructions are going on here , it is
taking almost ( k ) time. We believe that these operations are all (k )
time consuming This for loop , that is , how much time is being taken for
this fragment It seems ( kn ) , okay So before this ( int i ) would have
been written here, ( int k=0 ) would be written here. The third technique
that I want to tell you is this : That break the code into fragments. The
first fragment turned out to be this one , with a little bit of
initialization. It took constant time because it is not such that if the
value of ( n ) increases, then its time will increases.


I will go for ( n = 100 ) to determine whether i will be going for n =
1000. I will accept it in ( k4) and ( n * k4 ) I will do it in k4 and (n*
k4), and it will happen O (n²) If you do it ( k=0 ) , ( k < n ) and if
you look at it , it will come out O ( n²) Okay, it will not (N²) ok
remember you this thing. There will be some code on it which will take (
k1 ) Now I have become so smart, by doing questions , and you will be
done too That (k1) it is will going to be non-dominant , if constant is
being added then we will remove it. So once the value of ( i ) will be
zero (0) and then the value of ( j ) will run for. Then ( j=1) will
become Then ( 0,2) Then (i=0 , and j=0 ) will then run for Okay. The
value of ( i ) will be zero ( 0 ) for ( n ) times running then the value
of (i ) will become ( 1 ) , it will run again (n ) times then it will go
on till n. When ( n) is running out, watch carefully , watch very
closely. Then later I will ask the question, then I am telling if it is
not done. value of i will be ( 1) , ( n ), it will be n-1 because I am
taking the index ( i=0 ) then (i=n-1) will be and here is ( n- 1 )


I told you guys If it 's not clear to you why it will work ( n² ) times
So I 'd say let 's go look at it for 3 and 3 and print here (i , j ) and
make a count variable and count it , how many times it is running You
write ( c ) program , write in Python, write in Java, write in Python and
write in the Java. But when there are 2 loops inside one , then that will
run for n² times. And if another loop is given inside it , then it will
run ( n³ ) times. If there is a double for loop, then it becomes straight
(n² ) I have handpicked some questions which I am going to give to you
guys here. And I have also given their programs to you. So you see here I
have opened this folder in visual studio code. So it 's saying that Find
the time complexity ( Func1 ) function in the program shown in program1.
c as follows. Even if you come from another programming language nothing
is going to be change. The time of (F1+F2+F3) will be that I will take as
the overall time of the whole function. The time is not depending on
Array 's length so i 'll accept it ( k1 ) and I can not accept ( F2 ) as
( k ) , i will accept it as k2 * n. So now if I find a total time
complexity that is , if I T ( n ) come out , then what will it be ? T (n
) will be done as T (N) =F1 +F2 +F3.


The answer is O (length) The algorithm it is talking in terms of length
over here. The time complexity of the Func function in the program from
program2. c as follows. Find the , find the , I have written fine here ,

Written for

Course

Document information

Uploaded on
April 4, 2023
Number of pages
2
Written in
2022/2023
Type
OTHER
Person
Unknown

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
muhammadharoon3

Also available in package deal

Get to know the seller

Seller avatar
muhammadharoon3 Exam Questions
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
7
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions