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
Class notes

Introduction to Data Structure

Rating
-
Sold
-
Pages
54
Uploaded on
06-03-2023
Written in
2022/2023

This algorithm and data structures courses will teach you everything you need to prepare for placements,interviews and logic building. This notes will teach you how to create optimal solution to your real world problems.We will cover a wide variety data structures and algorithms in this course

Show more Read less
Institution
Course

Content preview

Playlist of Dsa

Introduction to Data Structures & Algorithms
CodeWithHarry

should be able to use it in your work or in your projects or in your courses or in
your projects that you are doing in the future or in your work that you are doing
right now so if you want to use something then you should be able to use it in your
work or in your projects or in your courses or in your future work or in your
projects that you are doing right now . So data structures and algorithms are
things that help us in our work or in our projects or in our courses or in our
future projects or in our work or in our projects that we are doing right now so if
you want to use something then you should be able to use it in your work or in your
projects or in your courses or in your future work or in your projects that you are
doing right nowwater in a pot and you put the tea bag in the cup and you make the
coffee Now what is the difference between data structures and algorithms?
Algorithms are specific steps that need to be taken in order to solve a problem.I
have been in the industry for a long time now and I have seen a lot of people
learning C , C++ and when they start to learn it they get very lost & confused &
they don't know what they are doing & they don't know how to use the language
properly & eventually they stop learning it & they end up becoming a beginner again
& that is not good for the industry & it is not good for the learners either so I
would say learn C , C++ & don't get lost in the language learning process
a break for a while I understand that you are very busy for the next few days and I
understand that you are very busy for the next few weeks and I understand that you
have a lot of questions so I 'll just stop now and I 'll come back to you in a few
days and we will start the next video where we will talk about algorithms and data
structures and then we will talk about interviews and then finally we will talk
about the final exam and you can ask me any questions that you have in your mind so
that 's all for now I 'll come back to you in a few days and we will start the next
videowhat is the data structure of chrome so now we see that the data structure is
called RAM so the data structure of a database is called RAM because when the
program starts it will load into RAM the data structure of the database which is
called RAM . And then you will get to hear this and it is asked in the interviews,
"tell me, what is this?" So now let's understand database, data warehouse, and big
data here we have understood the data structure that when your program starts in
RAM, it will load into the random access memory.I want to keep the data in a
different database so what I have to do is I have to create a new database and I
have to name it `` legacyData '' I have to create a new table in that database and
I have to add the following column in the table `` Birthday `` I have to add the
following column in the table `` Year `` Now I have to run the program and I will
get the following result in the console `` Facebook 2020 `` Facebook 2021 ``
Facebook 2009 `` `` Facebook 2020 `` Facebook 2021 `` Facebook 2009 `` `` Facebook
2009 `` You retrieve and read the data from hard disk drive and update it.
know these three terms because big data is what we are talking about here .memory
location where the C program stores the data that is to be processed next and the
heap is a memory location where the C program stores the data that is to be
processed next but the data that is to be processed next is not always stored in
the same location as the data that is to be processed next because the C program
can keep data in different memory locations depending on the situation and this is
why it is important for you to understand the stack and heap because you will be
able to understand the C program better and be able to ask more questions on the C
program. Alright ... I 'm talking about C program that 's why I say that you get a
good picture of memory with the help of C programming therefore , data structures
and algorithms is best learned from C and C++ Now here I am dividing it into
segments so there is thing called code segment let 's say this is my code let 's
say there is a code with the name `` harry.c '' now this code will be first loaded
into my main memory I told you what is the first thing that happens ?then it will
come to this line it will come to fun1 ( ) , it will execute fun1 ( ) . fun2 ( ) is

,calling inside fun1 ( ) now the variables that I had created inside it will be
created here let 's say I have created `` k '' & `` l '' let me write here :
initialize k and l and after that I 'm calling fun2 ( ) so as soon as fun2 ( ) will
be called it will say to fun1 ( ) that you wait for a while , I call fun2 ( ) and
be back by fetching the value whatever it will return fun1 ( ) replied that you go
and get it call fun2 ( ) and get its value .
me where do I give the milk to the milkman because the pointer will store the
address of the malloced memory so the milkman will get the milk from the pointer
and the pointer will stay there until you return the function or until you delete
it.it will say to fun1 ( ) that you 're coming back and now you can start your
execution again . If anyone asks you this question, that why heap is used, it can
also be done from stack. So that thing is done here with the help of dynamic memory
because when does the stack of a function end it ends when the function is
returned. I just come back with the value you just wait here. You go and get it and
then what will happen, fun function will be called.
this video we will focus on linked list & binary search tree so if you want to know
more about these then you should go ahead and watch the video and learn more about
these things . If you still think that you want to do all of these things with
Python, then I am saying that when you will go for an interview, the person in
front of you will expect C, C++, or Java from you. If you don't know C properly,
then I have made a 15-hour long video of C with notes.

Time Complexity and Big O Notation (with notes)
CodeWithHarry

So the input size didn't increase and the runtime of the algorithms didn't increase
either .No , it doesn't depend on the size of the input . When we ask questions
like as the input will increase, Then the runtime will change as per what? And
after that Now you will go to aunty's house You will be treated. Consider there are
different routes to come and go.
is the algorithm that runs in constant time . K1 n to the power 0+k2+k3+k4 This
time is required in algo 2 .The sentence is: Run time of it, there are some things
that we will recite. Because we won't constantly use our brains again and again, as
we see Big O of 1 it is constant. Now, come here and listen to another story. If we
do an analysis of the first algorithm, If I do T algo1 Then what will happen here?
And along with consider that game is of L3 kb. If the game is of N kb then how much
time will you need? The sentence is: Run time of it, there are some things that we
will recite.There are polynomial algorithms and there are exponential algorithms
and there are logarithmic algorithms and there are exponential functions and there
are logarithmic functions. There are also algorithms that are not linear in time.

Asymptotic Notations: Big O, Big Omega and Big Theta Explained (With Notes)
CodeWithHarry

This passage discusses the complexity of an algorithm, which is measured in terms
of the size of its big O graph. THe author states that the complexity of an
algorithm is automatically O(n^5.), O(n^30), and O(n^100).& G ( n ) is intersecting
with f ( n ). So you will get some complex function Alright so this is the solution
to the problem So. What we have done is WE have taken a big function and we have
made it so that it is always below the original function and that's what [UNK]
means THe definition of [UNK] for a function. F(n) is the largest value of G(n)
that is bigger than f(n)..

Best Case, Worst Case and Average Case Analysis of an Algorithm (With Notes)
CodeWithHarry

K is an integer ) SO now I 'll write it like this K n ( K is an integer ) So now I
'll write it Like this K n ( K is an integer ) So now I 'll write it like this. K n
( K is an integer ) And now what will happen? The value of 'k ' will become very

,large And so 2n will be going down. The graph of ( n^2+n ) ; graph of n ; graph of
( N^2+n ) will go below 2n. THe Average Case Complexity for a given algorithm is
the time it takes to run through all possible cases, divided by the total number of
possibilities..?" This passage discusses Algo 2, which is a cunning person who is
smart. Birbal. Algo 2 says that he will not make useless comparisons, and provides
an example. An example of how he does this.. Algo 2 first takes the first and last
element of an array, and then compares them. IF. They match, Algo 2 is good; if
they don't match., Algo 2 will find the mid--point of the array and be okay..
The stack do at a particular time point?? SO. The stack will have a value of
factorial 3 at a particular time point. SO it will go up to factorial 4 at that
point in time, And then it will go back down to factorial 3. OKay? And that is how
the space complexity works for a function when it calls itself recursively..
algorithm will take time X on a computer with processor Y. I can only say that the
algorithm will take time y on a computer with processor X. SO. In this particular
case,, my algorithm is running in 2 seconds on my computer with an i9 processor.
But. It might run in 10 seconds on a computer with an i7 processor. SO that is why
I say the space complexity is O ( N ). The passage. space complexity is O ( n ).
The passage discusses the space complexity of the factorial function. IT states
that the space complexity of the algorithm is O ( N ), where n is the size of the
input.. THe space complexity is measured in stack frames, and it is observed that
no matter how large an input's factorial, there will be a corresponding number of
activation records.. This means that at any given time, the algorithm will be able
to fit in a maximum of three stack frames.. This passage provides insights into the
algorithm's computation complexity.. The algorithm calculates in 10 seconds, and as
input grows, so does the time it takes to calculate. This is why the algorithm
measures growth in terms of asymptotic analysis..

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 , let me correct it I wrote
fine above also , find this man , this is find Never mind , these small mistakes
are made. If you look carefully above it is written ( n ) times, if you write 1 for
( n times as ( 1+1+1 +1 + n) So what will happen if I write (n²) so it is done O
( n²) So anytime you see the double for loop , and it 's going to [ 0, n ] , [ 0 ,
n ] and [ 0 n ] i. e. for 0 , ( n) times it will run OK , so this will run 0 for
(n) times, then 1 for n times then it will again 2 for n. times. And there is some
constant work going on inside it so it means The average processing time is T ( n )
so T ( 6 ) is a small number. If I directly solve for T (6 ) I will try to solve
the problem directly for T. only. And if this is a simple problem, then the
expression of T (n ) can also come out.


Arrays and Abstract Data Type in Data Structure (With Notes)
CodeWithHarry

So I have a friend that wanted to build a PC So he approached me and asked '' Harry
, can you give me a blueprint to build PC ? '' '' So that with that blueprint I can
make someone build PC? '' '' I want to do gaming and streaming. '' So I gave him
this blueprint. I told him all the main components of a PC. And even if he makes a
mistake , It wo n't be a big deal. We will study array ADT. Array as an Abstract
Data Type. Arrays as an abstract data type. In that , I will give you MRF. Not MRF
tyres, nor the bat one ; I 'll give you minimal. . . minimal Required
functionalities. And some operations , that you can define later on your own. Let
us understand this with the example of an array. Arrays can be found in a lot of
programming languages. Arrays are found in C, C++, Java and Java. In Python, they
are called 'lists' and in Java, they're called lists. There are some minimal
required functionalities in arrays. For example, Get is done , Set is done. Along
with that there can be a resize functionality.
An array is a collection of elements. Accessible by an index. The memory layout of
the C programme is a code section. Inside the stack, there are local variations of
a function. Inside a function is a stack. Inside an array is the heap. The kernel
is the kernel of the kernels. In most programming languages, the index of an array
starts at 0 It has a reason ; when we start from 0 , We get a certain advantage but
I wo n't go there. But, you can search on the internet There 's a paper by jee-
stars. In that they 've explained what will happen if it starts from 1 or 0. How
calculations will become easy. If you say that you do n't want 38 , you want a
greater one Then you wo n't get it. When you requested a memory till 38, then it is
possible that some other application was given some memory by the compiler. It will
be doing its job with this memory. Otherwise in the same programme It must have
allocated a variable in correspondence with that memory. So you 're saying that you
want to increase it So you can not make it larger in this array. You can increase
it in the linked list, we 'll talk about that ahead. If you skip the practice set

Written for

Course

Document information

Uploaded on
March 6, 2023
Number of pages
54
Written in
2022/2023
Type
Class notes
Professor(s)
Code with harry
Contains
All classes

Subjects

$10.09
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
muhammadabdullah4

Get to know the seller

Seller avatar
muhammadabdullah4 University of sialkot
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
1
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