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: Data Structure Lab, SE Computer Engineering 2nd year
Description: 2nd year Data Structure Lab, SE Computer Engineering short notes made briefly focusing on the important points

Document Preview

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


Introduction | Data Structure Lab | SE Computer Engg | SPPU
Aledutron
The new series in which we will be discussing some questions from this cycle by fully pune
University
...
In this video
...
we would need a text editor to set up the things we would need in the next
video,
and then we can directly jump on to the questions
...
I am here at the
Linux mint home page so you can download the things and setup
...
The second thing is
the main home page for the sublime text software
...
If you
are getting some errors
...
what we can do is
...
So include iostream choosing namespace Http int main see out Hello
world then return 0
...
after selecting, you
can again use control B or tools and build so both would work fine so now why
to build and how this is all working so let 's just see the underlying process behind this thing
...
hexadecimal format
...
CPp file into an a dot out file
...
so what we are doing
...
So this all thing is
automatically done using this sublime text
...
This
works like this
...

So this is an package which you will be using for taking inputs directly in our sublime
...
If
you have not installed you will get an option to install the package control
So then you can click this and here you can put install so we have to install something so
package control install package
...
At last you will see new build system click on
that then clear all the constraints of this paste the thing which you have copied and
type the thing
...
We can again execute this thing while true and print zero so
we can execute this so here you can see this is going going on executing so to stop what
you can do is control plus break
...
we can use the shortcut
key to stop the execution so go to tools and click here cancel build so it will execute
...
Just used the basic setup and see how the things work so now We can directly
head on to the questions and discuss the questions
...

a video on that so that would be all for this introduction and setup video
...
a video of the question will be shown in the next video
...

write a Python program using functions to compute
...
number of students who play neither
cricket nor Minton and fourth number of students
...
in mathematics, it is called as intersection so basically
we have to find the intersection on these two sets so let 's see how we can do this
...
then we will go to next element and check whether it is
...

list called resultant, which will store the list of students who play both the things as we are
finding the intersection
...

So let 's just create an empty thing, then what we will do is
...
we can directly use the in operator or the membership operator to check
whether student is present in the second list or not
...

we have to remove 2, 3, 6 and 7 the intersection elements
...
we have to loop through each student in list L1 and then if student is not present,
then we will append this student to the main result thing
...
the question second list of student who either play 10 this 9
and 10 play badminton or cricket 145 but not both so these players not play both
the games so this
...
instead of copying the second
list, we are just create starting with an empty list
...
If that student is not present in L2, then we will append the
result
...
Let 's just execute yeah for a and we will set end equal to space
...

We are getting 2, 3, 6 7 B is 9, 10, one, four, five, nine and ten
...
we have to calculate same things or use the things which we have
calculated before so let 's just reduce the size and keep it so how would we do so either
what we can do is
...
The football
...


Cricket and fitball but not badminton, so what we can do is
...
So the players who play the football and then remove the
batman 10 players
...
Then we have to remove B
elements the elements from the set B
...
Now we are getting 8 and 12 same answer
...

Can now see the question is also printed automatically because we have used the docs
string so here is the question
...

You can modify this and play around with this and then the answer for this thing a b, c and d,
so let 's just put a new line here Now this looks fine
...
please email us at ireport
...


Question 2 | Group A | Data Structure Lab | SE Computer Engg | SPPU
Aledutron
We have to write a Python program to store marks scored in fundamental of data structure
by N students in the class write a function to compute the following first of all
average score of the class highest score
...
first of all
...
Instead of sum
...
We can directly use
the mark list
...
the average score of the class
...
What will happen If min underscore value is greater
than mark means what is happening We have set some minimum value
...

And we can use this simple single for loop so here just remove this command and put here
and then let 's just take this before this so if we keep this as it is what will happen
...
So they are called and used here, but they will not
find any reference
...
if mark is equal equal to none absent
student plus equals 1 means we are incrementing the value
...

Similarly absent student would be required to be declared before that so let 's just remove
this thing and declare here
...

we need a for loop again so for I
...

The question D they have set to display the marks with highest frequency
...
We first calculate the frequency, then for each key value in the frequency
...
For example,, 10 27 has a frequency 1 94 has 2, 20 has
4, 67, 1, 89, 1 and other all is one so like this, we can count the frequency
...
We can check if frequency of mark means we are accessing that element using
the key value
...
So like
this we will get highest frequency so let 's just print highest frequency
...

automatically
...

It considers this as a doc string so document string
...
We have n't added anything
...
display books in ascending order based on the cost of books
...
a function would take a name
and cost and depending on this
...
So this is same
as the list
...
so what we have
...
Our unique list would be
fine
...
if this book is in the unique list, we will not add
...
we have to inverse this thing so whenever
this thing returns true, the knot would inverse that value and it will create that false
...
So let 's just take some random numbers and this would be our books or the
cost of the books
...
We have to convert this element into this thing so what we can do
so Whenever I would have this list what I can do is
...
So here the minimum would
be one
...
instead of using this for
loop
...
will go one index ahead
...
3, then for 7, then for 1 and then for 4
...
the minimum value in this list is 1
...

Now is swap these two things
...
So swap we can directly
use the tuples unboxing to swap the things so what I can do is a of 0
...

Book list index out of range error error
...
index out of index error
...
index index index out out of number of elements
...

index out of the index error, So there ca n't be any index 7
...

we are looping on each of the elements of this list and going to each element
such as 2, 5, 3, 7, 1, and 4
...
directly checking with the mean value
so instead of checking with an index
...
Now we can see one two, three, four, five, seven,
...

We can say that list is sorted
...

Because after 7 there is no element present
...
We can index this and we can take the first element of this thing
...
So simply we have to add the
square bracket and one for each of the case
...
here we
basically check for the minimum element and put it at the first position
...
When we will discuss the main concept of sorting searching
...
To filter this according to some value I can directly
provide this value in this function and it should return me
...

Why because 300 400, 500 and this all elements so similarly
...

A class is used for creating a structure for the class book
...
to access the properties
...
This is a magic function given by the Python
...
It would take these two parameters name and cost and create an object
...
list so if I execute this here you can see main underscore underscore underscore
...
So here some address each
book has a unique address
...

instead of book list
...
return a list
...

So this is more readable as we are using object-oriented programming, but yeah so this
should work fine because we are printing the cost directly
...

This is the transaction lock for format D100 W200, so withdrawal is not allowed
...
Write a function for withdraw and deposit D means deposit while
W means withdraw
...
Then we have to take the input or else yeah, so
we will take input variable or what we can do is transaction lock So transaction lock equal to
input so we 'll directly take input from the console, and we will print a message
enter the transaction log transaction transaction log
...
What we can do is? We can store this entry in some
another variable, or we can put this into a list so let 's just create an entry list
...
on a new line
...

After the for loop completes we have to add the entry into entry list so entry list Eq not equal
to append so enter release dot dot dot append entry
...
We receive a comma
...
Let 's just give the 10 10 and again W10 so here now we can
see the same output which we have calculated using the for loop
...
After every comma we are going to get
a space
...
Add space as a deeliminator
...
that so as we can here see uh the list after splitting would have two elements
...
just
create a comment for now because we have n't created any deposit function
...

what we can do is if and only if the bank balance is greater than or equal to the amount then
we will reduce so bank underscore balance minus equals amount
...

the changes which we made here we changed the amount it was not reflecting in the original
bank balance so therefore it was having an issue so let 's just remove this
...

Question 8 | Group A | Data Structure Lab | SE Computer Engg | SPPU
Aledutron
A new question question number eight is to write a Python program that determines the
location of a saddle point of a matrix
...
I can store each smallest
value of row
...
there are n't any other saddle point
...
So let 's just take 4 and 9 so here the maximum was 3
...

Here maximum is 9 and in this row the minimum is 2
...
What will I do is calculate
the minimum value and insert it in that row minimum list
...
Should we check
for
column so what would have UH what would we have to do is basically
...
So now i will be the row count
...
So column underscore list equals empty list
...
of list
...
So I will create a column list where all the columns will be
stored
...
for i in let 's just implement a for loop and check
whether it is column common or not so for I in Roman list
...
for an m cross m matrix is said to have a saddle point
...

so first of
...
So we 'll print a message enter row
count and then he will enter that so column would also require the same so in input enter
column count
...
There means we are checking for columns
...
This would be all and we
will come with a new question in our next session
...

We will answer in the next session
...
This was the main program how to do this
...
So here we can give any elements
such as 1, 2, 3 4
...
This is one of the matrix and here
...
matrices can be of any
size
...
a single row can be stored as an
list so what we can do is
...
So in Python we
can call this as list in which this will be
...
would be 4 Comma 5
...
If I somehow
means if I somehow manages to traverse like this so first this element then this element
...
I can just go on adding this M1 plus m2s that index value
...

If you want to make this a bit UH useful and user friendly, then what we can do is
...
So let 's ask the row value so row equal to input
...

So input enter row value
...
If n is equal equal equal to 0
...
So here we don't know will m1 come or m2 come so what we can
do is
...
here we
should give
a colon and space so here what I will give is one, then two and three then again one two
three
...
I can look through each row at first just make it as
column in,
but how would I make so that I 's the question so let 's take the notation form so here I can
see we have to convert each row into column, but how we will do that so what is basically so
a simple thing
...
we will modify that so in transpose what we will do is
let's just

copy this thing only and we will modify it so yeah let me just paste this space transport copy
paste it here
...
multiplication in matrices is a bit complex
...
we have to consider the row of the first matrix and multiply it with the
column
...

Basically, how do we do this thing? So let 's just remove this at first and make some space
for some things and see
...
So here If I know these two are constant, so what I can do is
...

So let 's just say this is I and this is g
...
what I have to do is change this k depending on the number of uh columns so basically
Uh
...
for I in range
...
So first matrix we were using row, so we 'll use
the
row then for j it would be in column
...
I take the length so we would need the length
...
This is the row number so I can
directly take row so which are We can take the value so then what we can do is
...
I will take the answer matrix so first of all we
would need to also update that answer matrix
...
So why do we use plus equals Because first of all we store only this value 2 into 3 we
store into answer then what we do we plus
...
So like this we are doing
similarly, then four twos are eight eight eight plus this thing
...
It 's a
40 then again 4 into 3
...


Question 11 | Group B | Data Structure Lab | SE Computer Engg | SPPU
Aledutron
question number 11 states that we have to write a python program to store role numbers of a
student in an area who attended a training program random in random order
...
we would need a
student 's array in which we would store all the role numbers so let 's just create one i will
create
a student list and i will put the elements 10 40 45 45 67 89 34 56 78 73 90 1 and 37 so these
are the values i would take so as you can see these are in random order they are not sorted
so

basically we will see what is sorting
...
if index equal equal
equal to 1 means we can say student is not present
...
We require to check similarly, if we consider about
the maximum case what would be it, so it would be the first condition which we saw the
number does
N't exist
...
In this case do n't use the for
loop use
while loop so we will see this difference a bit later but for now just try to understand what this
internal search says so just remove the last element of the list and append some your key
...
If we are by using while loop we require condition that that condition
should be
...
both loops work same so here let 's just deeply analyze the how we how the for loop
works
...
at first,
I will be assigned to one so we will assign i equal to one
...

So again
...
Sorry
...

time complexities or time complexity is 2 n plus 3
...
So in this we again consider this if case and maybe plus 4 no
...
If basically this 2n plus 3 is the actual linear search
time complexity
...
Then again i plus
plus
increments and we get 10
...
If we assume it would happen, it would take one unit of time
...
So let 's
just again go to our sentinel search
...
The same condition which we saw at the first zeroth case
...
If l is equal
...
to key
...

element is present
...
Because i will also paint point
...
So this is why we learn the time
complexity and thing to see which of the algorithm would be best for us
...
internal
search
...
we can use linear search as well as this
antenna search to
find or search an element in a list so this would be all for this thing and let 's just meet in our
next video
...


Question 12 | Group A | Data Structure Lab | SE Computer Engg | SPPU
Aledutron
Question number 12 from Group B, which is to write a python program to store names and
mobile numbers of your friend in sorted order on names search your friend from list using
binary search
...
If not present in the phone book Basically we have to search that person if he
is not present
...
we use sorted sorting
algorithms
to sort sorted algorithms to do this so now this should be covered in future lectures How the
sorting works but for now let 's just understand that we have given a sorted list so what we
have to do
is basically or instead of just taking this complex number what we can do is just take very
simple numbers so one two three, four, five, six, seven eight
...
Let me just remove this example so here we have to
perform something similar so here what I am doing is basically
...
So here it starts with 0, 1, 2, 3, 4, 5, 6, 7
...
5 and in the list we ca n't take any value
...

6 plus 7 gives me 13 13 by 2
...
Now my middle point is 6
...
if a of mid means the middle element is less than the key means it will always exist
in the right part, so what
I have to do is
...
so what will I do is now I
will calculate the mid-value so mid is equal to l plus h 0 plus 6 which is 6 divided by 2
...

So first mate is 3
...
I will check whether key is same or not pi and 4
not same key is less than 5
...

So Yeah! Basically this will be implemented inside the loop because we are doing the same
thing again and again and when this loop will stop at this condition, so L should be always
less than H so Yeah
let 's just go back to our text editor
...
What is recursion
...
Return mid and L is equal to my plus 1
...
we 'll just
modify this function
so that we can use this binary search on this name send mobile of number list so instead of
storing each individual value what we have to do is
...
write a python program to store names and mobile numbers of your friend in
sorted order on names
...
So for
numbers can be anything and this
should be anything
...

have to create a tuple e-value sorry for the a key and the mobile number
...
Similarly here also
instead of returning 1 we can add that
...
then we have to display the top five scores in this
percentage area of percentage
...
Similarly, each position will be changed and our list will get
sorted
...

the algorithm is called as this selection sort algorithm
...
we have to go for each index up to
...

we can say if n minus one elements are sorted, then automatically the last element is also
sorted, so last element will be automatically sorted
...
here currently we are at the zeroth index so we 'll start from
zero, but after zero
...
Because left part is
sorted
...
we select a minimum element
and then arrange its
position and then we can separate out which part is sorted
...
we'll check the first element
is less than the

second element or not
...
we are getting the maximum element at the
last position
...
So what we have to do is
swap so let 's just copy this thing and do the further step in the next page
...

from 0 and up to length of a, but here in the last condition, the length of the a is let 's just first
implement so what we have to do
...
of a
...
let 's just discuss the time complexity of these functions
...
The bigger complexity for the
worst case is n square for selection sort why because internal for loop if we consider for
worst case,
it will check for each of the elements and it would take n iterations
...
Typically
punctuation, capitalization and spaces are ignored
...
We have to use this stack data structure
and
then reverse the original string
...
This is an array of some specific size up to which a stack can
accommodate so
then i can add 5, then 4, then 3, then 2
...
This should be in the reverse case, so 2, then
3, 4 and 5
...

and removal or extraction is called as pop
...
we have two
operations push and pop so at start
...
While starting
...
Similarly if again push I will modify this
thing and then add the element
...
the top pointer would point at
the index and currently it would be 1 so then we would have our two functions void push and
int pop which would return it should directly return the last element
...

there is no assurance that the elements would be present in the full stack means the stack
would be full always so there may be one element or two elements so for going up to that we
can traverse up to the top index
...


representing
...
So class should have a semicolon
and then size invalid use of nonstatic data member
...
So this variable should be a static variable
...

A B, k and k was removed and no errors means kind of this is working fine
...

starting from i equal to 0 up to user underscore input dot size so i should be less than user
input size and what we have to do I plus plus
...
only
the characters Uh lower or upper case would be considered so here or what we can do is we
can convert each letter into lower case
...
so we can pause this display
...
Now we have to print the reverse
string so what we can do is
...

Just first check whether it is capital or not and then we will modify it accordingly, so if the
character is capital, then what we will do is, we will push directly
...
After this if what will happen each lowercase letter will
be converted into uppercase
...
We can check each character of the
original as well as the reverse string whether they are same or not
...
So bull is underscore
palindrome equal to true
...
using stack
using stack, so we first of all implemented
...
So both the strings were stored
...
So this was the basic question question number 25
...
synthesis errors occur when the brackets are closed
parenthesis or closing curly brackets or square brackets write a C plus plus program using
stack to check whether the given expression is well parenthesis
...
They have
said that you have to use a stack itself
...
whatever element is used last is accessed last so accessed at the last we will
get some value
...
Let's say this is unbalanced
...
Here would be the last element string is empty, but we still have
something value in the stack
...

the size should be constant and static because the size not size should not change
...
the code will be the basic pseudo-code that is used to implement this
so basically
...
let 's
just create our main function into main and what we have to do is create a stack stack
...
If this is not the case we insert it
...
we have to first of all check the value from the stack and the
current s of i so yeah let 's just take
...
after getting this
value
...
at last after for loop completes what we must
check is music
...
if top is
equal equal equal to minus 1, it is empty, so return 0
...
we have
to basically set is balanced equal to true, so what is the case that it may become false
...
Still some values is present
...
Then what is not the case
...
We can
see out
...
Whenever we try the brackets
...
what we have to do is basically
...
to check
whether the bracket is
...
we can we meet with the
new question in our next session
...
if the operating system does not use priorities, then
the job are processed in the order they are entered in the system, so we have to write a C
plus program for simulating this job
...
to implement this structure what we can do is we can consider a array of
elements and this should also be some fixed size
...
We used a single pointer
to denote the top or the ending of the stack
...
So kind of
first is start and second
...
We would have
RQ
...
a class queue and then public
...

If we consider this example, we have 5 and 8 in a stack, so what would happen If we start
from 0
...
As per our understanding, so there
may be some garbage value, but for now as we are considering there is
...
so kind of area of start
...
instead of
starting from the start pointer
...
So if we now execute this should work fine 10 67

45 89
...
This is the basic implementation of
queue
...
110 hundred and
thousand is added and it is displayed so kind of why was that happening because a copy of
queue was passed in this function and that copy was being modified and it was lost because
we are not reading anything
Title: Data Structure Lab, SE Computer Engineering 2nd year
Description: 2nd year Data Structure Lab, SE Computer Engineering short notes made briefly focusing on the important points