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

ICT(COMPUTER HARDWARE AND RESOURCES)£11.25

Title: DATA STRUCTURES AND ALGORITHMS
Description: DATA STRUCTURES AND ALGORITHMS Learn everything about c++ programming language. Part

Document Preview

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


DATA STRUCTURES
AND ALGORITHMS

Part 1

1: Intro to programming and flowcharts
...
We will also learn about
programming languages and why we use them
...
This will
be our flow whenever we will solve any problem
...
Bhaiya explains that a flowchart is a diagrammatic
approach of that approach known as flow chart
...
He says that from where a program is starting we
have a component called terminator
...
Next block is a simple rectangle, which shows a process
...
He says the pseudocode as a whole is a
generic way of representing logic
...
We use parallelogram to show the input/output of the
program
...
If a < b print `` YES '' else print `` NO '' and it's done Simple You just have to
write in English what you are thinking and it is called pseudocode
...
We have to check whether N is ODD or
EVEN , so we will make one block for this condition
...

We have to print something and then increment too You have to Print and then increase the
printed number too You can see here , we printed and then increased the number by 1 But we

do n't know how to do it How we will increase again and again Let 's rub it You know that we
have to start from 1 and print till 5 So if I give you a number which starts from 1 to 5, will it
work ? You are like , yes , this is what we needed So I took a number =1 This is not an input ,
it is a process , so I wrote it inside a rectangular block
...
The catch is , 1 and N are inclusive here in the
answer should be 15
...
We know that we have to start with num=1 and increment it till I know N = 5 , Num
=1 , and sum =0 in the beginning
...
You will get your homework after this
...

Flowchart shows how to add conditions, loops, input/output, processing, processing and
start/end
...
We will answer only 2 questions - What is it ? and why do we use it? You will get
your homework questions too
...
Next lecture will be out tomorrow - most
probably where we will be writing our first C++ program - Namaste Duniya ( Hello world ) As
homework, you have to write pseudocodes for all the questions we have solved today
...
We will see how a program runs and what each line
means in this lecture
...
Coding Ninjas has supported us in providing this
amazing DSA course to you
...
you need an
IDE to write, run and execute a code
...
You can directly
create a C++ there and run it using Replit
...
We
use these signs to output the result into standard namespace
...

We are going to talk about data types and variables
...
You have to mention what type of data it is and how
much memory it will take
...
We have certain rules which we have to follow when we are giving names
...
In memory, the first 29 bits will have 0, and the last 3 bits will be 101, so in memory
the first 29 bits will have 0 and the last 3 bits will have 101
...
In c++, all the characters are mapped to
some ASCII value in memory
...

If we have 4 different bytes with some binary value, how will the compiler know whether it is
a single Int value of 4 separate char values ? Compiler will come to know from data types
which we used when we declared any variable
...

There are a few steps which I have to follow while storing a negative number
...
With this our maximum value will be limited to 2^31 -1
instead of 2^32 -1
...
4 , why ? Because you are storing your answer in
an int variable
...
If you want to check
whether A is equal to B or not I can do that using this ( a==b ) relational operator = , > , < , ! =

is an assignment operator, because we are assigning 3 to a
...
We have got the basic idea of operators
...
Now let 's move ahead towards bitwise operators
...
We will do Bitwise operators later
...
We will make a
simple program , where we will ask the computer to print A if A is bigger than B , else print B
...
If you are given a number
A , and you are told that print +ve if A is positive, otherwise, print not +ve
...
If A is 5 , then 'if A is -2 and if a is -5, then it
will print anything
...
But if I add a 'else' block here, then this block is executed
...
get ( )
takes input in the form of characters
...
Cin doesn't read
SPACE , TAB , ENTER and TAB
...
Let 's code that
tells us which number is greater
...

Entered A as 15 It printed A is positive This time I entered -1
...
Correct output
...
You just have to enter a
condition and the statements which you want to execute
...
Here is your homework question
...
We have to tell whether n is prime or not, a prime number is a number
which has only 1 and N as its factor
...
% tells us
the remainder when we divide 2 numbers
...
If no such number exists, then it is a prime number
...
We will
do many patterns problems in the next video
...
But first let 's understand this code
...
J will also run from 1- N and we simply have to
print the row number
...


4: Solving Pattern Questions (Part-2)
Love Babbar: We are going to solve 18 pattern questions in this video
...
We also did 2 pattern questions
...
Let 's try this approach
...
We know that row = n
...

Outside this loop , we will enter a new line and increment ' i'
...
Then after printing it inside the col loop , we will keep
on incrementing it by 1
...
We can't simply print a row and increment it , because then our program
will misbehave
...

We have done 9 pattern questions
...
Next pattern looks like this: 1st obs - row = n 2nd obs- A is mapped to 1 , B is
mapping to 2 and so on
...
We got our counting correct but just had to map 1 to ' A ' so to do so , we added ' A
-1 on both sides , so to
...
We just have to print ' A'+i -1 , but it will be typecasted to
integer so to avoid that
...
Then
increment col , added a new line outside the col while loop and then increment row too
Simple You have to implement it by yourself
...
If you are not able to do this question by yourself, then revise these first
...
We know that it is written in the
reverse order
...
We will get the answer the same for each row
...
formula is ' A ' + row + col -2'
It was a very easy question
...
After that it became
very simple
...
Do this one Now let 's try out this variant
...
You can see that before printing these characters , we have to print some spaces too
...
These are

very easy questions if you have understood previous questions
...
If you are able to do this one
without my help, then it is very good for you
...
I will tell you the solution and then give you one more question to try as your
homework
...
In the next one , we will see operators , bitwise
operators , For loop , and many more interesting things
...

Also tell the answers in the comment section for the questions which I asked inbetween of
the video
...
We have already covered the while loop , today
we will see the FOR loop
...
Today we
are going to solve easy and medium level questions on Leetcode
...
We have already seen this conversion in the previous lectures
...
So we got our
answer as -3 Got it Bhaiya says
...
We will talk about left shift and right shift operators
...
For smaller numbers we will get our answer
as 2 * n But in some cases it creates negative numbers This is your left shift operator
...

Bhaiya: What does post increment mean i++ It means that first use the value and then
increment it by 1 Let 's see with an example If i=4 and I write it as int a = i++ Now let 's check
what are the values of ' a ' and ' i' Post increment means , increment after using , so it means
' a will be having the old value of i which is 4 in this case and i ' is incremented after this
operation , it means i is 5 now Got ? You must see the 5 questions and you have to tell the
output in the comment section
...
You can simply write this also for ( ; ; ) You should also play with these operators
because they are very easy and are asked in MCQs
...
You come here only once ,
then you come to this condition
...
You can use any loop from FOR loop or WHILE loop See it is giving correct output
...

If it gets divided by any number, then it is not a prime number
...
If we don't divide then we have to
check for other numbers because it may give 0 with them
...
We are familiar with both break and continue
...
We came to know that it is not a prime number
...
If I redeclare B twice in the
same block , then I will get this error
...
Operator precedence table increases from bottom to top and left to right
...
We have to run the loop until
the N is 0 in rem =n % 10 in rem
...
In this chapter, we talked about operators,
For loop, precedence, precedence and variable scope
...


6: Binary & Decimal Number System

We will see how we can convert a number from one number system to the other
...
So this video is
sponsored by Releval
...
Bhaiya explains how algorithms help us to convert this decimal to binary in
code
...
Then we will find the last
bit by doing & with 1
...
Then this is the output
which we got = 0 1 0 0 1 1 0 1
...
Let 's code it First
take the input of N
...
After that we will get the
last digit like this After initialising and with 0 in the beginning , we will write , ans = ( digit *
pow ( 10 , i ) + ans) Ooh , it gave us 125
...

We developed a logic from there that we can represent any binary number in power of 2
...
Similarly we will multiply it by 2 while converting binary
numbers to decimal
...
Then we will check the bit
...
This is how we came to know what mistake we were making
...
If you are trying to find the bit , then 123 will be represented something like
this in binary
...
find the
...
If it is one, we added 2 's
power to our answer , else we skipped this value
...


7: LeetCode Problem Solving Session
We solved 2 leetcode problems in one of the previous videos
...
We will learn some new concepts while solving these
questions
...
If you want to purchase any
of their courses, then you can use the link given in the description and get 25% on all of their
courses
...
We have only handled the normal case
...
We know that integer has this min range and this max
range
...
So we have to multiply
carefully by keeping this thing in mind that the result should not exceed the integer limit
...

We know that we are given a number , we have to play with its bits
...
Till now, we have seen these bits operators- AND, OR, NOT, XOR, Left shift ,
Right shift So we are going to use these operators to get our answer
...
We have a variable mask which will help me in ignoring these
initial bits
...
001
...

We are left shifting and adding 1 to it by taking its OR with 1
...
ans = ( ~n ) & mask and at the end we have to return the ans Let 's run it and see
Accepted See it is giving correct answer for all given test cases
...
0000,
left shifted it with 1 and took its OR with 1 Then we repeated these steps for x times to get
our desired mask
...
We will get this X
by right shifting this number again and again until we get 0 Take 5-6 examples and dry run it
over them to understand this
...
We are calculating 2 's power multiple times
...
This way we will keep on using the previous answer and need not to calculate
the same power again and again
...
We
have used various keywords like - switch, case, default, expression, constant
...
We will understand this more clearly with an
example , but for now , keep this thing in mind that you ca n't use any float or string value
here
...
Once they are executed, it will execute
all other cases written below it
...
It is similar to this if-else ladder ladder
which we saw in the starting
...

You have to make a simple calculator today
...
We took input
of a , b and operation Now we will write a switch case something like this 1st case will
perform addition, 2nd case - subtraction, 3rd case - multiplication, 4th case - divide, 5th case
of modulus
...
We missed this symbol
here and we missed this one too
...
A
function is a program which takes input and gives us output
...
We are writing the same code again and again
...

Our code is becoming bulky Our code length is increasing Let 's say you made a mistake in
the first place and then copied same code 10 times
...
We have to write a return type = int then we will write the name of
the function = int power
...
At last you will write return , and return your answer, and
then this answer is stored inside this 'ans' variable
...

Let 's understand this function again so that it becomes clear to you
...
The names of the variables in the calling function and

the Power function are different
...
I will add space instead of a newline instead of newline to
make it easier to read the code
...
We used to divide it
with every number from 2 to n-1
...
If that is not the case, then then it's a prime number
...
Is this code bulky ?
No It became easy for me to fix bugs in the code
...
IS this code readable ? Yes We have divided our code into different sections
...
When it 's work is over , it will
pop out of this stack
...
stack , you will be able to visualise
how your function is working and calling other functions
...
At last program is an easy concept when I write this
main ( ) function here
...
Inshort , we have a variable 'n ' in this main function , we
passed it to the function where it got incremented and got printed as 'n+1' In Short, dummy
created a copy of the variable to use the value of 'n' When we just give the copy of a variable
to any function to use it , we call it as pass by value
...


9: Introduction to Arrays in C++
Love Bubbar starts with lecture 9 and we will talk about arrays
...
To take
part in this firstly you will have to register yourself for the test
...
You will also have to attend the interviews and then you will get the
offers and all the process just takes 15 days and you will be hired
...
The values stored in contiguous locations all things
are stored at contiguous locations means int a then we have a block in our memory which
contains some values garbage value
...

We understood what an array is
...
Today you learn how to initialise an array there are many ways like i want all
my array int array [ 100000 ] so I am not gon na write all the values so let us assume i have to
initialise it from 0 if we don't write 0 in this case you will get 100000 values and contains
some garbage values and no one will know the actual value something random comes
...
We need only the name of the array and index
...
If i start a loop 0-1 and put i
in this , will it work ? for { int i =0 ; i < n ; i + + ) { cout < < third [ i ] < < `` `` ; }
...
Size will be entered by you
...
We should not use a variable to define an array 's size
...
I'll teach you when

you take size as a variable
...
When you will come out of this loop you will
have your max value ready
...

When I was in college, there was a subject called `` Intro to Programming '' in our first
semester and there we had to reverse the string
...
Even if you are afraid of
solving this question , then I must say that you should not
...
Reverse function start = 0 , end = n-1 and reverse function reverse
function print the array
...
These are some of the questions we will do in the next lecture
...
So tell me in the
comments how was today 's lecture
...
If
you are finding it boring, leave it
...
If you consider Amazon as a
good company then I can help you in cracking them
...
The answer is 2,1,4,3,6,5
...
You can find a discord server
link at the description
...
Coding ninja is the largest coding education platform where you can see interesting
courses and if you're interested in paid courses and want to develop yourself learn machine
learning , android , core subjects , DSA with any language like java and python
...
We
have an array here So we will deal with both of them
...
Assume that 6 of them are greater or let "s say 8 are greater
...
odd [ 5 ] = I have written here
11,33,9,76,43 in this way
...
Therefore it was 8
...
Let 's run it 2 times
...
6,7 and then 0,1 It 's going perfect
...
Then
here it is odd and its size would be 5 and then run it
...
i+=2 inside the for loop which
means the same as i=i+2
...
We have to swap
the value of 0th and 1st index
...
The link to all the questions will be given in the
description itself
...
And now I have to update the 0th index which is an array of 0
and inside it should be 2
...
What do they mean ? They meant to say that in your array the M
...
But one single number appears only once and others appear
twice
...
In
this way we have printed 1 why because here 2 is present two times
...
In this case 2 and 7 appear twice, 4 is left
so the desired answer is 4 next
...
But what even is the point of storing it will remain the same
...
We had to XOR 2, 3,1,6,3,6 and 2 to solve
our first question
...

The question says Given a number of integers array you have given an array of integers in
that array
...
Next -3
...
let me just solve it for you
...
This question's unique concept is that
you have to solve it
...
Next question is Find duplicates in an array
...
It is
easy while solving but it is very famous for finding duplicates
...
X ,
...
In that way these numbers
will be present
...
It will cancel out if I try to apply for XOR
...
That is what we require so your game is complete so
i have to think something to cancel out this
Title: DATA STRUCTURES AND ALGORITHMS
Description: DATA STRUCTURES AND ALGORITHMS Learn everything about c++ programming language. Part