Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: complete notes of data structure algorithum
Description: A data structure is a named location that can be used to store and organize data. And, an algorithm is a collection of steps to solve a particular problem. Learning data structures and algorithms allow us to write efficient and optimized computer programs.

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


Introduction to Data Structures & Algorithms
CodeWithHarry
This course is primarily for placement preparation and will be using C and
C++ for the algorithms and data structures
...
Data structures are essential
for developing efficient algorithms that arrange data in main memory for
optimal usage
...
C is a bare-bones programming language that
requires you to do everything yourself, but Java can also be used to
implement algorithms
...

Data structure is the arrangement of data in main memory, and the
concept of database, data warehouse, and big data will be covered in the
course
...

Although data warehousing is beyond the scope of this course, it's still
important to understand it
...

The concepts of stack and heap are essential in understanding how C
programs work, and space and time complexity will be covered in future
videos
...

know these three terms because big data is what we are talking about here

...
Alright
...
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 ( )
...


Time Complexity and Big O Notation (with notes)
CodeWithHarry
I want to tell you guys one story
...
I was so bored that I needed some entertainment
...
So he has a collection of games
...
And you can get every type of game from him
...
He also uses jio and we get just 1
Gb for one day
...
So for
me , what is the fastest way to take the game from this friend
...
This means that as the input size is
increasing like that The time required to send the file , That is also
increasing
...
You will go
on that bike
...
As the input size of algo2 increased like that what happened ? For
that , there was no change in the runtime
...
So
we say as the size of the input keeps on increasing , Similarly, what is the
effect of the algorithm on runtime
...

We are not studying algorithms, we are listening to a story
...
Big O is called a constant runtime algorithm
...
So this is
Big O of n to the power 0
...
My main time is required in that ok
...
If there is an SSD in your computer then it will open in 4 secs If you
are using a supercomputer then it can even open in 1 sec
...
Ok, so it takes a constant speed of your This is not equal
to
...
So here I will say that The most
difference that will be visible It will be because of this term
...
So this was of 2 lines but

this will become 10 lakhs
...
So I picked this
because in comparison with n to the power 0 it is big
...

Big O of n square
...
Linearly if your time scales with the input size
...
If your time runs in constant time, Big O is 1 ok
...
Industry definition is a minimum of this
...
When I use its
mathematical definition then I say Big O But when I give industry
definition Or I am answering any interview
...
But they are used
interchangeably
...
It does not
mean it is 1 's graph
...
This is the
graph of x=k
...
And this y=mx+c It can be somewhat distorted
...
we talked about order
...
We have primarily 3 types of asymptic notation big
O, big Theta (Θ ) and big Omega (Ω) big O is represented by capital (O),
which is in our English
...
Mathematically, mathematically this
function can be anything
...
G ( n) is your function which will come inside the big O
...
If you guys can find any such constant ( C ) and ( n ) -node ,
then f ( n) is O ( g ( n)" This is the mathematical definition of big O
...
This question is its own truth , it has
validity , it will remain valid
...
And along with that, I
've packed one more thing into this video : The definition of Log
...
1
...
7
...
If you know even a bit of maths, You 'll
know that it is in an ascending order
...
Suppose the value of A is 8
...
Meaning 1
...
Sorry, your answer will be no , because it is n't
there
...
It does n't have much of a brain
...
Is this the best way to do this work ? Obviously not
...
1 is lucky , He will get A=1
...

In one comparison only
...
This means that it does
n't depend on 'n '
...
It only has to make one comparison because
it is only searching for the first element in the array
...
Till now, he was fortunate ; But now he 's not so lucky anymore
...
the sum of the run time for the
total number of possibilities
...
Average Case is equal
...
The sum of all
...
times
divided
...
number of possible run time
...
't ' ; I 'll calculate ' O ' later
...
'n' possibilities is when
there is 1st element, 2nd element, 3rd element, 4th element, 5th element
and 6th element
...
1
...
3 comparisons
...
I removed this because this is different
...

AP is Arithmetic Progression and GP is a geometric progression
...
APs are made as well as GPs sometimes
...

The formula of Average Case Complexity is All possible run times divided
by the total number of possibilities
...
It can be asked for this type of
algorithm , A simple algorithm that compares all of these
...
Complexity ? O ( n )
...

Now we 'll see how many comparisons this will make
...
It will match the first and last element and match it first
...

It is making the same comparison for all sizes of array
...
After that we will do some set of
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
...
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 first
fragment turned out to be this one , with a little bit of initialization
...

I will go for ( n = 100 ) to determine whether i will be going for n = 1000
...
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
...

Then ( j=1) will become Then ( 0,2) Then (i=0 , and j=0 ) will then run for
Okay
...
When ( n) is running out, watch carefully , watch very closely
...
value of i will
be ( 1) , ( n ), it will be n-1 because I am taking the index ( i=0 ) then (i=n1) 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
...
And if
another loop is given inside it , then it will run ( n³ ) times
...
And I have also given
their programs to you
...
So it 's saying that Find the time complexity ( Func1 ) function
in the program shown in program1
...
Even if you come from
another programming language nothing is going to be change
...
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
...


Array as An Abstract
Structures(With Notes)

Data

Type

in

Data

CodeWithHarry
Abstract Data Type is a new data type upon which we have defined our set
of operations and values
...
So what have I done ? I 've made a OneNote Notebook
...
1' An integer is not an abstract data
type, it is a primitive data type
...
It must have a total size
...
And
after that, it must have an address , Base address
...
This My Array ADT that's being made The representation of the
set of values This is it
...
And I'll write here + , meaning the
set
...
Here I can define some operations
...
It 's my choice ;
whatever I choose to keep
...
So I have made a My
Array abstract data type
...
Stack is the static memory; Heap is the
dynamic memory
...
This is the
heap of my main function
...
Or I make an integer
pointer here
...

Okay ? In this manner, I can add some values to it 7,8,12,27,88
...
So in this way I can make this array
...
In which we will define the
total size , the use size , use size, the base address and after that , We will
define some of our operations on it
...
And here I 'll write ; this is the 'representation '
And after that, we 'll have 'operations ' So this is operations
...


An array is contiguous blocks of memory, i
...
The base address will be the address of that first element , That
the array is pointing towards So this is a pointer that will store its address
Whatever is my first element, the one with 0th index
...
But if I define the array as big as I can I might
have to make another completely new array
...
We can implement this in any programming language
...
In that , the updation and access are very fast
...
Assume there is a field
in which Starting from 1, at every kilometre , at every milestone there is
...
4
...
Okay ? Assume this is from Delhi
...
We 'll set up our coding environment And we
'll implement My Array on a structure
...
So in the next
video, we'll see its implementation and complete it
...

Please keep liking this video
...
If you do that then I 'll be able to make such videos and these
types of notes
...
It 'll never happen that you finished this course And you have to
watch these videos again after 6 months Because you'll have these notes
with you
...
The first primary
operation is called traversal
...

In traversal, every array element has to be visited once
...
If you 're confused
why 0, 1, 2, 3 etc
...
At home, do C language, 15 hours sleep a little
less one day and complete it
...
I
'm kidding, watch it in breaks whenever possible
...
So here , we 've seen traversal
...
In
traversal, we can use as many elements present
...
The capacity here will be 100
...
Size means how many elements you are using
...
If a pot can hold 10 liters and you store
only a liter in it, but you bought it to store more if needed in future
...

In school assembly, children used to stand in a line
...
If I
want 5 to be at index 2 , I 'll have to shift them first
...
You 'll make space first, add 15 blocks
...
After that, what did I do for insertion ? I
shifted the elements
...
All this is in the notes , nothing to worry
about
...
Zipping is for
your convenience, use a computer to unzip
...
Comment below what the best
case deletion run time is and what the worst case is
...
In worst case, the element order does
n't matter
...


If we reach 99 while adding elements, what to do ? We ca n't insert after
that , there 's only one option then
...
You 'll have to copy it then
...
You are breaking the array 's borders
...
If the array was sorted, you 'll use
binary search
...
And binary search, okay
...
Your mid is 2 , so you come to
it
...
Now you 'll
keep doing this till your array finishes or you find your element
...
When the array is not sorted, use
linear search
...
It 's
computationally cheaper , that is quicker and takes less space
...

You can do it if you know C and C ++ for obvious reasons which I stated
initially
...
too you can follow with those too as I said earlier
but again I 'm C , C++ here
...
So in coming videos we'll code these
...


Coding Insertion Operation in Array in Data Structures
in C language
CodeWithHarry
In today 's video, we 're going to talk about insertion
...
And what I 'll do here is , I hope you have accessed
this array operations PDF that I 've given you
...

So here I 'll make an int size=4; that shows that we are using 4 elements
...
If I want , in the future I
can add more elements
...
If the capacity of your tank is 100 litres,
and there are already 100 litres then the 101st litre can't fit in it ; no matter
how much it tries
...
Assume that
this is an array of 7,8,12,27 and 88
...
So for that, a for loop will be working
...
Then your insertion was n't
successful
...
The insertion was
...
successful here
...
Because there 's space in the array
...
So 88 will move ahead
...

My size is 5 i
...
And along with that ; I 'll
write arr here and either return the index or return 1
...
It 's
done ; we 've successfully done an insertion in your array
...
So many people have accessed the playlist
and I 'm so happy to see that
...
So here you guys can do one thing , There 's a quiz for you guys
and that is ; you have to modify this code Such that you should be able to
find out whether the insertion was successful or not
...
Otherwise, you will say
that 'insertion failed' and that will be enough
...
Download
them, study them and if you have any issues, you can watch the video
...
At the
same time we had seen how to
...
But the code of insertion code
of deletion was not seen by us
...
of deletion
...

There must be some shortcut in this one note so that you can go directly
to the previous pen
...

Find out and tell me if you can what will i do here now Let 's say 0 , 1, 1, 2,
3 and this 4
...
I put a colon ( ; ) here , you just think of it
as a rough code
...

In a new file 11_deletion
...
If it is beyond capacity, if you say do the deletion in 238
...
The index is large: Array ''s which
(capacity - 1 ) is So sorry you will not be able to do the insertion , print
something like this but what shall i do here I do n't want this capacity I just
want an index where I can perform my deletion
...
So do n't be confuse in size and capacity
...
If you are
doing only data structure preparation
...
And this one simple thing : I can even say this advance C
...
I hope this course has been helpful for you guys
...
Do n't forget to tag me if you are sharing this playlist please
tag me I share the story from the back , as many people have tagged so
far
...
In today 's video we are going to talk about : linear search and binary
search
...
Binary search is a smart algorithm named Binary Search what
does binary search do
...
The linear search is very simple , quite
a straight forward algorithm to find all the elements of the array one by
one : Where the element is found, it has to be said that the search is over
...
search
is
...
If the element could not be found, that 's the end , that's the end
...
get our element , ok You have been told that 238 page no
...
If you turned the
pages one by one, you would have to turn 238 pages
...
This pages
would have been stitched randomly
...
do 238 page
number so what is the first condition of binary search , the condition is ,
should be sorted array Okay
...

Array needs to be sorted this is its first condition
...
So I 'll keep track of three things here: Low,
High, and Mid
...
So
here I am making a table Low , High , and Mid , OK So I would say now my
mid is low And my high is what it is , okay And now I will calculate the new
mid
...
Linear vs Binary Search: For you guys Surely
everyone must read this, access this , Downloading from the description ,
you will get the link somewhere
...
I do everything according to

my own , right here And I try to do everything in time , put the video and
then after that here I have the notes
...
int searchindex = linear search
...
Otherwise, what will i do otherwise i will
return -1 So let 's see here whether it works or not
...
Otherwise what you do is -1 If we come to the end
while searching in this array then you return -1
...

The greatest integer will by default the ( C ) language
...
C
language Since it is an integer , the operation between 2 integers will be
an integer
...
5 point
something will not be this value for 5 and 6 This value will be 5 only
...
So I will do it ( mid+1
) because i do n't mean to take it inclusive , I know : not even here :
element Elements are from here to here right now , well, I know that So
from here till here my element is there
...
If I do n't get the element
then I will return -1
...
This means it needed to come out and return it means i did
n'get the element inside the array
...


Introduction to Linked List in Data Structures (With
Notes)
CodeWithHarry
with a very good example i will show what is linked list and why would you
like to use it
...
In every hospital each single
bed was utilized utilized utilized them so this is linked list
...
The
size of our array can be so large that we do n't know2 today these are 7
tomorrow these may be 7 lakhs even then if we want to allocate memory if
the array of 7 expands or if the capacity of array is low then it will be a
problem
...
This too will run like this and
point to the next node so here as you remember the example of the
hospital how did I gave the analogy that i just gave an example to explain
...

LinkedList is just like a chain it is a chain with hooks
...
If you would
have created an array you do n't get the luxury to remove this how will
you remove this element this is contiguous memory location you have to
move it only or else they wont be there
...
Let's see where which to use and which one will
give you advantage and when assume that if you want to access the
elements like this 4 element 8th or 9th element so you can access in
constant time do you have this pointer assume this pointer how much you
have to join to get the access the ptr
...
The drawbacks of array are the linklist shines over here have written the

thing completely short crisp and to the point are not lengthy notes at all
which means short crisp
...
In
array and linked list we have seen that the memory is the same
...
i
hope you all have got the idea of linked list and in next video i will explain
implementation implementation
...


Linked List Data Structure: Creation and Traversal in C
Language
CodeWithHarry
Friends, in this course of data structure , we had seen the linked list in the
previous video
...
After that we will
see that how the same linked list can be traversed
...
If its address is let 's say 788 , then 788
is stored inside it
...
Then I 'll declare the
end of this list here , okay
...
To
access the data of the struct pointer , you can use the arrow operators
...
Here as if this is your one node , after that it is
linked as if with some other node
...
and so on
until your null comes
...
A
14_LinkedListTraversal
...
The video number is going
to be 14
...
I create a file with the names of it, and
put a boiler plate in it
...
How can we make a
function of linked list traversal ? What do I do to make function of
traversal of linked lists? What will happen that with the help of this pointer
, I will print the elements inside the whole list one by one
...
head node
...


So to linked list traversal , I have given a pointer which is of type struct
Node * : I get one
...
And I 'll keep doing this until it becomes null until it points to
null
...
Head is a pointer, of struct Node *
type So over here this is , struct Node* ptr Okay So what will I do here , I
save it and run it
...
If it also had a fourth node if it also has a fourth, i
...
I
would put some data in the third node
...
So look , made the head made the second,
made the third and made the
...
This is the last element of the list
because the next one is pointing to NULL So here is the chain , it 's closed
Sometimes I had to add an element , can do it at any location
...
Relatively , very
few people have access to this playlist I would say by bookmark it and
save it
...
So far maximum 2-3 people must have done so if you do then
thank you so much
...


nsertion of a Node in a Linked List Data Structure
CodeWithHarry
The Insertion and Deletion all this is going to come in linked list , it 's all
very easy
...

What we are going to do is simple in a way to understand the problems of
C programming
...
I get access to linked list , with the help of head node
...
How do i have to do to do this , you think for yourself First of
all, what will I do to link it , something like this
...
No matter how
many elements you are ahead of here , it has not even seen the element
...

We can insert node at any one index
...
I 'll write a function named Insert
at index and what do i do inside it first i will create a node
...
Complexity of Insert in between will have
complexity O ( n ) O (n) : of our worst case complexity of insert in between
...
The complexity of Insert at
the end is O ( n ) - its complexity will always be O (n) Insert after a Node is
the worst case complexity
...
The last element of a linked list will
become the last element
...

O ( n) will explain the complexity of Insert after a Node in the comment
below
...
After this you have to insert an element
...
In
the next video, I will tell you how we can code all these four cases
...
And after that we

will print and see the list also
...
So don't miss the next
...
And if you haven't accessed this course of Data Structure
then do it
...
I have told you
the four types of insertion in the last video
...
Get the
link from description or can go directly on codewithharry
...
I am
creating a strategy here and will show you how our strategy looks if we
wants to insert in the beginning of the linked list so what thing should I
have ? one thing I need is head and other one is data that what you want
to insert
...
I am showing you in the video what I did I
wrote here PTR next is equal to head
...
Many people are beginners and weak in C
...
So , what
will I do here forward the video on that part where i explain you on this
case two coming on insert in between how this will happen
...

No chain will break but this chain connect to this PTR next is equal to PTR
...
This is the simplest the work
done so easily but what is head ? This is head , the function is absolute
right i hope it works let 's see it works
...
insert at end is so easy, what to
do in insert at the end ? I copied old function because lot of thing remains
similar I am changing it
...
7,11,41,66 and 56
comes at end why at end ? beacuse I run insert at end which is code by me
see I have only written code here nothing much is done and code will run
absolutely if you say something to computer then computer is very faithful
which I like about computer do whatever you tell it
...
In all the cases you have to do this only that join links like I tell
you in all the 4 cases which I break and join understand linked list like
chain that will do insertion in between deletion also have same trick that
we will see after
...
so atleast watch this last video first because I
have explain this in the video
...


Deletion in a Linked List | Deleting a node from Linked
List Data Structure
CodeWithHarry
After this video you 'll never ask how to do deletion of any node in linked
list because I am going to tell you in very clear way
...
When you delete
node of linked list will you leave this memory on hang ? no you have to
free it , It is dynamic memory you allocate this memory dynamically that is
allocated dynamically that 's why
...
I have a given index of it what I have is head and where is it
pointing ? with that I have given index so suppose I assume I assume that
it 's index is 0
...
If I write case 2 here like this I write
here deleting a node in between what to do for that ? deleting a nodes in
between , so see we have nodes in our linked list , I will erase this here I
told you here how you delete the first node
...
while loop
...
to run one time if your
...

is 3 then you have run one two times so you will see this after what to put
...
next that means where Q
...
s next will point
why ? I want that 8 's node to be deleted
...
I will show you all this thing in code how can we do ?
so there you will have more fun to watch so do one thing we will go in VS
code in next video till then what you do
...
If not then write it down with idea and I already tell about case 2
you have to do 3 and 4 I want that you write rough idea and we w ill meet
in next
...


Delete a Node from Linked List (C Code For Deletion
From Beginning, End, Specified Position & Key)
CodeWithHarry
There are 4 cases to delete a node in a linked list - first you can delete the
first node in the linked list
...
So first let 's
do this thing here First , i 'll see what video number is this This is video
number 18
...

The function is called delete First and it deletes the first element from the
list
...
a element at any index
...

It to the next of the head i have selected these 2 pointers one p is here ,
one q is here and i 'll keep moving forward both p and q
...
Then q will come to 8 , I
want to delete where q comes you guys can understand So why am I
doing this here , you will understand I 'll run a for loop
...
You guys
understand how this is happening here free what i have done here, free i
have
...
As soon as
your linked list reaches the last element, what you have to do is delete it
...
e
...

Link is a game of complete links, whose game is it ? Link 's game it is
...
Here we will see how it will look like if I delete the
last one
...
If you have reached the end of a linked list while searching for data,

what will you do now ? It may also happen that that data is not in the
linked list
...

I think I have told for the fifth time , no I will probably tell this for the
tenth time i told it 5 times in previous videos
...
Not everyone has accessed the
playlist and would like to say thank you to those people who have shared
the playlist on instagram
...
I am wishing that as I
make a video one by one , you guys enjoy watching it
...


Circular Linked List and Operations in Data Structures
(With Notes)
CodeWithHarry
circular linked list is one concept that people get confused about circular
linked lists
...
I am giving one
practical example if you have seen my jango
...
He showed you search , traversal
...
can do deletion , can
...
search and can do traversal we moving forward till when we do
...
If you
have watched my jango 's video so I have made an E-commerce website
and there I have shown you that how items can come like this
...
When you do like
this then item will turn and keep turning suppose after 4 , 5 is hiding so
suppose you clicked on this then this you can watch 5 from here
...
to null when eventually P will
reach here while moving so P will be equal to
...
so I can do is write it
after this while loop that print the
...
s data
...

If you want to search an element see search is same like traversal , you
return it when you find it that this is the pointer of that and here is data
search is done through traversal
...
There is
another presentation of circular linked list what happens in that ? create a
node like this there is one pointer and your real linked list starts from here
and this is only one head node you can not store data in this In this you
can point this only with another node and point that with next node
...
I want to make this course

crisp and to the point and after that I 'll add programs even If I made
another playlist named data structure practice
...

I hope that when you are watching this you can get the link in description
...
Sometimes it takes 5 to 8 to 10 hours to make notes
PDF after uploading the video or source code or etc
...


Circular Linked Lists: Operations in C Language
CodeWithHarry
In previous lecture we have seen that how does a circular linked list works ,
i think you all have accessed this playlist of data structures and you have
also seen this video of “ Circular linked list and it’s operations in data
structures
...
Lets create a linked
list so how i made my singly linked list , i 'll show you how i have created a
singly link list here and shown you so if i go at any one program of singly
list here we have one structure here
...
If i write something like this in while loop like , run while
( ptr ! = head ) Okay , After some loops ptr will be equal to head move ptr
forward
...
I 'll keep
moving my
...
If i do this, the traversal of this will
never start see if i show you by calling and running this function
...
A semi colon is must in do while if you know by the
way if you have n't watch C videos , i had posted 15 hrs video with notes
with notes
...
If you ever faced problem, this
is were you will face it that why i 'll show you how to do it rest all you can
do it by your own
...
you have to make
that equal to the data that i have to insert I 'm returning pointer of struct
Node * i have done head properly at here at here , insertAtFirst ( head , 80
) , and what i am doing here is explained by me in the previous video of
singly linked list
...
So i
connect a new link here as you can see , what i am doing here is so
this i am making p ''s next here equal to ptr
...
Blue blue will
indicate new connections here
...
I brought head to the ptr and then i returned the head so guys this
is working theoretically , Is this working practically or not ? Harry's playlist
is a collection of songs from his favourite artists
...
The music video was created
by Harry himself for his first time
...
Please share this video on instagram please do n't forget to tag
me for sharing
...
We have seen this here in the
linked list
...
In doing that , you will have to use the same concepts that you people
have in singly linked lists
...
At the same time, if you have a pointer to the last node then you
can walk in both this direction and in this direction
...
in it :
you have extra information in this , what is the node with your previous :
you can also know this
...
I hope you guys must be easy to
understand because you guys have accessed : This playlist If you have n't
done it then definitely you will have a little problem if you're a beginner
...
If I have
memory constraints or memory constraints i will be happy with my singly
link list
...
The best thing is that a pointer who is
traveling here : That can change his mood and start traveling here
...
I want you guys to write a function
that first traverses it in this direction then once your pointer reaches here
it comes back and traverses again that is , once a straight linked list is
being printed here
...
The person who is in realistic time can finish this course can finish
it
...
I am putting it in all the codes nowadays I have
taken the feedback very well : Thank you guys So let 's what we will do
now
...
We will talk about what
is stacks ? And the notes that I have made for you, I am going to give you
as a PDF download
...
If you are from India, here I am talking about Indian
railway
...
And even if
someone tries to come forcefully Then the thing that happens is called
stack overflow
...
Now, you ca n't add elements inside it ok
...
It is not at all recommended
...
4
...
So break number 4 It will come
...
And break
number 3 after it break number 2
...
come
out last
...
Along with LIFO it is
...
that went inside last that will be out first so it will be last out
...
Our second application of
stack is Infix in postfix conversion
...
But here
I will now want to talk about , our 3rd application Parenthesis matching
...
If one
mathematical expression is written, In which parenthesis are used , So is
that mathematical expression valid or not ? Parenthesis in it are matched
properly or not? In order to create a stack we need a pointer to the
topmost element along with other elements
...
We need a place to store those elements
...
But for
learning purpose Here we will use integer datatypes
...
So the operations
that I have defined in stack ADT Whoever will do implementation of my
stack by watching this ADT He is very clear what he wants to do
...
Which means I want to add a element to the

stack
...
And if I have to remove any
element out Then in this way I will pop out the element
...
So
I can easily remove it out
...

Stack can be implemented using an array or a linked list
...
If our stack is full Then it means we ca n't add more
elements to it
...
It
has no element inside
...
Those who have read it, tell to others also
...
Sadly very less people in fact
two people have shared playlist
...
So thank you from the bottom of my heart
...


Implementing Stack Using Array in Data Structures
CodeWithHarry
Moving forward with our data structure algorithm discussion we will see
how to implement stack with the help of array
...

and why we would want to use this type of data structure
...
Top is the value of index
...
Top 's default value will be -1 if there are no elements
...
Means my stack is filled
up till here
...
The top value will
be 0 if my stack is filled till here, 1 if till here and 2 if there is no element in
this and with that I 'll write s
...
The default value is -1 but
it will store the index of topmost element
...
Can create array then can set top and then my stack will be
ready
...
But we can create custom data types stack too
...
So I want to
ask you one thing that how will you pop and push an item ? Then what
you will do ? So which method will be best for me ? Most of the
operations are performed in O (1 ) Operation can be complicated too
...
operations here
...

operations are done in constant time
...
And I did my
push operation so we chose this and not this
...
To implement stack
with the help of array what I did first ? First of all I created a fixed size
array you can see here
...
Then I created stack and kept its size 80 so that if
I need to do a big number of push operations then my stack can handle it
without problem so this is how we implemented stack here
...


See in code
...
And we have choose this orientation because if I want to push
any element in this Then I would have difficulty to maintain all the indexes
and that would not be ideal
...
I hope this is clear and we will write its code
and then we will understand it 's operation in more depth
...
Now we will run
in code , i
...
in Visual Studio Code and we will write here how the stack is
made
...
I am going to do a little variation here and you guys
see what variation is going to happen I made a very simple stack here
...

The most talked about ones are push operations : one , and pop
operations : to insert an element inside the stack
...
what is push and pop? Is there any condition for them what
i mean to say here is can i push if stack is full : Or can I pop if the stack is
empty or not?
IsEmpty isEmpty checks if this stack is not empty or not
...
If my stack is empty, then I will write if (
ptr - > top == -1) ok, if i did like this I will return (1) What does (1 ) mean,
return ( 1 ) means true and i will do ( else ) return ( 0) Now I always prefer
to write my function in such a way that I am applying ( if ) also ( else)
because readability increases
...
Once
...
I
want Interact, comment below and I want the comment to be filled with
these answers
...
I will be very happy you guys will do this
and so many people have accessed this playlist
...
What are the topics here
...


Everything is lying on the site, all the source code , all your notes , I have
put all the notes
...


Push, Pop and Other Operations in Stack Implemented
Using an Array
CodeWithHarry
We have seen stack in our Data Structure course
...
Today with that
confidence we will move forward and talk about stack operations
...
If in an empty stack I want to fill something I will quickly shift to a
Red pen and from red pen I make operations from which I will do stack
push program
...
Now whatever I will write below this line will be with the help of
this stack
...
By anyway, you return a message that stack is
overflow
...
Everybody will write in comment that I know the meaning of stack
overflow
...

I want that you should try to implement pop operation yourself
...
And after
that I am showing you how you can implement pop
...
Instead you are going to return a value keep this in
mind and in push you don't need to return any value
...
We created push function then we created Pop
...
If I do stack * sp then I will get all the information of stack which
is pointed by sp
...
We will use semicolon
when we will code
...
If the stack is full you can do this by returning a big integer I just did
it by printing stack overflow
...
After that using the new value of top I inserted the val on that
index of array
...
If many people do this then I

'll start uploading 2 videos a day of DS
...
And if you liking the videos
please like the video it will not take much time
...
Today I show
you all this operation by coding and if you feel that stack concept is not
clear to you then if you watch today 's video till end , then you will
understand the stack properly that is my guarantee
...
I have to request actual space in the
memory where this size top and arr will come
...
Now we have to make
sp
...
I want element till the size of
sp
...
If PTR 's PTR top is -1 then your stack is
empty
...

Then in that case my stack is full
...
I hope everyone is clear now
...

As we have just created it , it is like an empty box
...
SP size is 10 so it can contain 10
sweets
...
But many people
forget that if you have read all 10 sweet then 11th one can not be inserted
...
And PTR top is the topmost
position which we have already updated here
...
Let 's check whether
push is working or not
...
The thing is that
...
If you look at the stack which is on your screen right now I
want to pop 15 from the stack
...


I hope you have understood stack easily and the source code you can see
on screen
...
All the code of data structure has been uploaded you
wo n't face any problem
...
com and access the data
structure course
...
If you
want to thank me virtually then take a screenshot and share on Instagram
...
You can tag me
...
No
one can say that I have not reshared and I hope you are enjoying the
course
...
I want
to give an answer to What happens when we pop things out of the stack
then we keep going down the top value that is from 2 to 1 , becoming 1 to
0
...
In terms of my position : , if I want to write index
then I will write Top I wrote Top here , ( -i +1 ) because this position : is
not an index So here 's how I came from And look , if you put the value of
(i ) as 1 then this formula will come all
...

do ( Top-1 ) You will do , as if the first position is taken by you , So you 'll
come one step down (Top-2 ) if you do then you will come down 2 steps
...
The video was kept : 15 hours with notes , watch it and you must
have seen yourself So far ( C ) language is well understood by everyone
...
This playlist is for you
...
I have made one of the
practice programs I made
...

And if you do dry run then you will understand
...


Have made a playlist for those people , I put videos in it , there are many
programs in it
...
There is no
shame in that You can easily make these 16 programs in very less time
...
The top would be 57,
then 64, then 3, 75, 99, 23 and then finally 1
...
A
practice program with logic playlist will be seen then will not come again
...
Tell me by commenting here below and feel very bad , telling
the truth from heart when people do n't comment and I read , most of the
comments are spam
...
I do not want to comment below that how is this
application , how
...

Visit this here that this will happen and make arrows and hands and like
that it will happen
...
We can
convert it into function
...
If I talk about stack
bottom Then it will be a big joke
...
And rest all you can do it later
...
Stack bottom is the zeroth element
...
In constant time I will access its constant
element
...
Just the name is dangerous
...
If I talk about stack
top So one array is getting accessed
...

Array is being accessed
...
I quietly want to increment my top And insert
the element
...
What will be the last element ? It will
size -1 of array
...
And I
will return 22
...

In constant time we did all work
...
Some big work is not being done
...
So this is our stack Here I told
stack top and stack bottom
...
And so
on it goes up 0,1,2,3
...
Now
lets see if the program is working or not ? Program is written by many
people
...
So we will do one thing , we will
comment it out Where simply here I will add a printf
...
printf I will
write , The topmost value of this stack is % d \n And here
...
And if you have n't clicked over here on bookmark
Then click right now
...


How to Implement Stack Using Linked List?
CodeWithHarry
We saw stack top, stack bottom and stack top and stack bottom
...
So I am making a linked list and I will add
some elements
...
So if we consider this
linked list We want it to work like a stack
...
We have to take it walking up to this
...
Then make the second last one null
...
And as always this data And this next node
...
When will be the stack empty And when will the
stack be full
...
When our head
pointer is null Then it means your stack is empty
...
When stack full
condition is very important
...

Stack will be full when heap memory is exhausted
...

This is how we can do stack implementation ? With the help of linked list
...
Tell me in
comments if you understand it or not
...
Tell me
how was this video ? And along with that the things that I have written
over here If you note down and make notes then it is a good thing
...
So as notes are getting done I am keep on
uploading And at one time all notes You will get on my site codewithharry
...


How to Implement Stack Using Linked List?
CodeWithHarry
We saw stack top, stack bottom and stack top and stack bottom
...
So I am making a linked list and I will add
some elements
...
So if we consider this
linked list We want it to work like a stack
...
We have to take it walking up to this
...
Then make the second last one null
...
And as always this data And this next node
...
When will be the stack empty And when will the
stack be full
...
When our head
pointer is null Then it means your stack is empty
...
When stack full
condition is very important
...

Stack will be full when heap memory is exhausted
...

This is how we can do stack implementation ? With the help of linked list
...
Tell me in
comments if you understand it or not
...
Tell me
how was this video ? And along with that the things that I have written
over here If you note down and make notes then it is a good thing
...
So as notes are getting done I am keep on
uploading And at one time all notes You will get on my site codewithharry
...


Implementing all the Stack Operations using Linked
List (With Code in C)
CodeWithHarry
We saw that stack can be easily implemented with the help of linked list
...
I am telling you
when will be a stack empty ? when will one stack be empty ? so I am
writing one pseudo code that 's code look like this
...
My second operation is what will be my
second operation , the second operation will be isfull
...
I will show you by code here what I will do to
push in this linked list
...
I'll print stark overflow here
...
stack overflow otherwise
what will you do ? else otherwise
...
For pop I
need to delete the element at index zero , it 's a simple thing
...
If your stack is not underflow, then you move
forward and say , else
...
This is my video number 30, so will create a file named
30_linked list stack stack
...
I will write struct node * N
which I made equal to top created one node to which my I made my
starting element point to it
...
After freeing the first node which I want to pop,
I will free N but I 'll make one int x which I make N 's data
...
I will create a linked list and stack or will do
one thing first of all , I will implement operations
...

and I made this null initially and that means my linked list is empty
...
So I will return 1
return 0 here
...
So if I am not able to allocate
memory dynamically that means it is full
...
Let 's do one thing I will
print it that if isfull then printf stack overflow
...
Our bottom most element is 78 and topmost element is 8
...
Pop an
element from this stack and tell me what it is
...
If You 're watching this directly
then it was fast and I will say your linked list is not clear
...
But when you are
sending top to pop then the changes you make in top are a pointer
variable If it is changing in function its value is changing
...
But here I will have to treat top as a pointer of a pointer
...
So here
it is showing pooped element is % d lets add \n too
...
And I have told you everything
here and How is this linked list working and representing stack that also I
have explained
...
So I am leaving this on you , you make functions for it
...
This was it for today 's video
...
And I will see you next time
...
Check out the latest video from iReport
...
m
...
Back to the page you came from
...
Today
we will discuss the remaining operations which were left
...
And then I can write 18 like this here and 15 like this and all these
are inside our stack
...
Top is nothing else but head but referring as top in
case of stack
...
PTR is not equal to null and I++ Inside this loop we will
increment our pointer
...
Stack bottom is
homework and you have to comment
...
31st_stackop2ll
...
Op2 is how peek
operation on stack of a linked list runs
...

The first operation was peek which is kind of important so looked carefully
...
So,
I 'll make a for loop and will use two conditions in it
...
at position % d is here I and I
...
So
it will be kind of traversal program which I wrote here
...
One more thing I can do while peek will not return I -1 till then
I will peek position
...


Parenthesis Matching Problem Using Stack Data
Structure (Applications of Stack)
CodeWithHarry
When I first saw a problem of parenthesis matching I was very scared ; I
thought that this was very difficult
...
So quickly, without wasting time, I
'll come to my OneNote notebook
...
the biggest
application of a stack is parenthesis matching
...

Regardless of which programming language it is, this thing is used widely
...
The first condition should be that
while popping , I 'll write this really well for you guys Because this is a very
important thing
...
uh '' If yes, '' '' Pop out of the stack
...
So 3 x 2 ; I'll show
you this step by step , whatever I told you
...
This means
it should not be so that the stack was empty and you tried to pop it
...
So these are the two conditions
that you need to satisfy
...
At the end of expression, your stack is n't empty , You
have two opening parentheses
...
I 'll write here , ``
It was unbalanced by 1
...
Then this will
come and you 'll try to push it into the stack again
...
I have nothing to do with 7 - 8 - 3 (7 )
...
I 'm writing two expressions here tell me
whether it 's balanaced or unbalanced
...
I want its worst and best case complexity of this procedure
...
If I have a stack that has 26 characters, The worst case will be
that all the 26 will just be parenthesis
...
So this was the implementation You will have to look after the pushpop You will traverse this , with the help of for loop You should traverse
this character array
...
When you have traversed the entire expression, you should
check whether the stack is empty of if it has something in it
...
But
at the end of expression , if the stack isn't empty then it 's unbalanced
...
If at any point the stack underflows, then
game over
...
point, the stack
...
over ; this
expression is n't balanced
...


Parenthesis Checking Using Stack in C Language
CodeWithHarry
In previous video we have seen that an expression is given to us to find
out parenthesis around it are balanced or not
...
That means
if your stack underflows then your expression is n't balanced and along
with the same you have spanned the whole expression
...
loop now what rule did i
made , my first rule was if there is opening parenthesis present so push it
to into the stack In this i have given you hand written notes and solved
practice sets are also there and also created 2 games
...
If you are facing problem in C
language which i can see many of you are , then what you all have to do is
listen to me and watch my 15 hour C video
...
I will
make it char * instead of int * and i have to make size of char
...
I am watching where
i am using arr before i was using int * now i will have to change it to char
*
...
If you come
out of this for loop then you have to check if your stack is empty
...
You should know to use copy
paste properly
...
Parenthesis more that 100 means an extremely huge
expression but again the computer systems you work on then who should

have no excuses that from where this much data came this can also
happen that your expression contains 10 crore opening parenthesis
...
The program does not tell about the validity of this
expression
...
i will provide all the source codes to you time to time and notes
will be uploaded soon
...
If talk about the parenthesis of this expression so
they are matching, so this program will tell me that if your parenthesis are
matching or not
...

Please share this playlist if possible on instagram
...
If we get
this type of parenthesis Then we will push in stack just like we used to
solve our single parenthesis problem
...
And with that there is one additional step which I will
show you
...
So , I did
push the same way I was doing
...
So is this
opening parenthesis is matching this if yes
...
I 'll
pop it
...
So, I pushed it
...
( 7-11+ { 22-8+2 } - [ 11+7 ] )
...
We just need to convert that code to logic
...

When I am popping, listen carefully , then I will take this in a character
...
So, I popped this
character and after that, that my popped character which I popped, and
the top element of my stack are matching or not
...
Match ( ) function returns either 0 or 1 if it
matches
...
or closing } or
closing ]
...
I am doing this
because my opening character will be stackTop one and closing will be
popped
...
I hope if
you understood this then you can do balance any parenthesis
...
This program tells you whether the parenthesis are

balanced
...
Yes,
lets save and run it
...

I will really feel good and do n't forget to tag me
...
And share course
on Instagram if possible
...
Use this video to help
you with your knowledge of the course in this week’s video
...


Infix, Prefix and Postfix Expressions
CodeWithHarry
In today 's lecture we are going to talk about what is infix ? what is prefix ?
and what is postfix ? So here I am going to explain in friendly way about
infix
...
What is prefix?
This is a way to write expression nothing more than this - I write a+B
...
Pre means write the sign first and then your numbers or
variables
...
If I write AB+, XY- PQ * are some examples of postfix
expression
...
So
everyone should have understood this
...
Now
I 'll tell you what it 's postfix is, ABC+ * D * and I do n't remember it from a
paper
...
If any 2 operators have same precedence like * and / then we
evaluate them left-to-right
...
How will
computer takes advantage of this postfix expression
...
Will start from here and will say , I got an operator here
...

The question is convert infix to postfix manually and, Infix to prefix
manually
...
So what we do here ? We will
do questions , and in that , we will convert
...
You can convert any
expression in prefix and postfix
...
Even in google interview they do n't give complicated expression,
because they want you to remember it
...
You never need to remember this you will
get this by yourself
...
When you program then somewhat you will remember it 's
precedence else
...
Can you convert it to
postfix
...


We saw infix , prefix and postfix
...
I said 2+2 or 22+ or +22 , that 's it nothing more
than that
...
Now, I have one more quick quiz for
you that convert this same expression to prefix
...
If you will
access the full course then it will be benefit to you
...
And do like this video too
...


Infix To Postfix Using Stack
CodeWithHarry
Today we are going to see how an infix is converted into postfix using
stack
...
And watch the video till end else you wo n't be able to
understand
...
So see - has what precedence ? It has
1 precedence
...
because it can not stay on top of king
...
and this has 2 so it
...
stay
...
So , what happened is
when I reached / it had 2 precedence so I pushed
...
stay on the top of /
...
top of it
...
So, what we will add this - here
...
We say infix to postfix expression manually
...

First of all, I will parenthesize it
...
Then I will write it here ( [ xyz/- ] ) - [ kd * ] and now
xyz/kd * - - X will come as it is , then + will go in stack
...
After that will write y here ,
then * can it be added above this
...
After practice you can see how conversions are done
...
Will make stack longer so can cut and pop elements
...
You will get help
in comparative programming , logic building will be good
...
So, you need to watch
...
And with that if you think this course is helpful , You
can take screenshot of it and share on Instagram
...



Title: complete notes of data structure algorithum
Description: A data structure is a named location that can be used to store and organize data. And, an algorithm is a collection of steps to solve a particular problem. Learning data structures and algorithms allow us to write efficient and optimized computer programs.