You are on page 1of 11

Data Structure & Algorithms

Trainer: Nilesh Ghule

Sunbeam Infotech www.sunbeaminfo.com


~ Backtracking
Course Introduction ② Greedy method
- Dynamic programming
~ Divide & Conquer

Data Structure and Algorithms Course Format


Data Structures: Linked list, Stack, Queue, Participants are encouraged to code
Binary search tree, Heap, Graph. MashTable alongside (copy code from code-sharing
utility in student portal).
Algorithms: Sorting, Searching, Stack, Queue & Post your queries in chat box (on logical
Linked list applications, Graph algorithms. end of each topic).
Course Goals Practice assignments will be shared.
They are optional. If any doubts, share on
Implement each DS & Algorithms from scratch. WA group (possibly with screenshot).
*
Understand complexity of algorithms. Faculty members or peers can help.
Course Schedules days
15 4 hrs Programming language
16th Feb 2023 to 4th Mar 2023 o
* 5th6th
(reserved) DS & Algorithms are language
independent.

Resource sharing
*
Mon-Sat: Lecture 5:00 PM to p8:00 PM
pon & pur
Classroom coding will be in Java (use
IDE of your choice).
Will share C++/Python codes at the end
https://github.com/nilesh-g/dsa-06 *
of session.
Recorded videos will be available for 7 days. Language pre-requisites?
http://students.sunbeamapps.org

Sunbeam Infotech www.sunbeaminfo.com


Course Pre-requisites
vars/cash
Java
1000with Python C++ C *

un

Language Funda Language Funda Language Funda Language Funda


Methods Functions Functions
- -
Functions
Class & Object Class & Object Class & Object Structures
static members Collections Friend class Arrays
Arrays Arrays Pointers
Collections Pointers
7
ArrayList
& HashMap

Sunbeam Infotech www.sunbeaminfo.com


Data Structure

Data Structure

3 efficiently
Organizing data in memory
Processing the data mon

Common data structures


ArrayV

Linked List V
Stack #
Queue V

Hash Table V

Advanced data structures


Tree 2
Heap V

Graph ↓

Sunbeam Infotech www.sunbeaminfo.com


Data Structure
analysis
uses arms,one...
2 time

Data Structure Asymptotic analysis analysis:bytes


a space
Organizing data in memory It is not exact analysis ↳ architecture
3 int
Processing the data notation ↓
num
g(s,vc,arm -
4


n
gac
sapprose few params.
Common data structures uneasure w.r.t.
⑲,
x86
ava -
2

Array Space complexity g(c

Linked List Unit space to store the data (Input space) and
Stack additional space to process the data (Auxiliary space).
O(1), O(n), O(n2) O(n)
115/7/s, S
O T
Queue ↑ 1 I

it an
arr
2

inputt
HashTable
2
S
spaces (1) ↑i - s k =

Time complexity key 3 =

nauxa
Advanced data structures san

Tree Unit time required to complete any algorithm.


Heap Approximate measure of time required to complete
Graph any algorithm. of iterations
hum
-
>T
Depends on loops in the algorithm. k
=

+ log s n

O(n3), O(n2), O(n log n), O(n), O(log n), O(1) Tan >

Sunbeam Infotech www.sunbeaminfo.com


Time complexity Space complexity
-space
auxe

Write a program to calculate factorial of given number.(n)


0x
res
res 1;
=

Tan
->
for (i 1;i =
x;i +)
+


=

0(1)
xes =
as a ij O(n)
mu
5 k-=

Pointgoes);

-j
Print 2-D matrix of n x n.

3
for (i = 0,i u ;i +
+

5 <a times total itas ->


021)
far(j 0,j(n;j +)
=
+
nites
<- x+ n
5 k-
=

print (aur[i](j)); 2xz


+

3 ↓

O(n)
Print given number into binary. -

I (01)2 ,n while (m 0) &


↑ 0(1)
=

> ites
↑&
n
=
-> S k =
-
print(n%.2);
2

10
1

n n/2;
=

log
zitz log m = >agen
log z log log
↑ a
o I 3 its
2 = 2

2)
Print table of given number.(r) its =

su
o (log
mu
i

far (i 1;i c
= =

10;i +)
+

T k =


-> Δ
pint(mai); o(1) S k+=
0(1)

Sunbeam Infotech www.sunbeaminfo.com


Linear Search -> found at index
5
key=77
o 7
2345 6 7 &
Find a number in a list of given
numbers (random order). arr
88 33 66 99 11 77 22 55 11

Time complexity
Worst case

Best case

Average case

Sunbeam Infotech www.sunbeaminfo.com


not found
Linear Search key =70 ->

-
X o 7 234567 &
Find a number in a list of given
numbers (random order). arr
88 33 66 99 11 77 22 55 11


linsearch
int (awr, key)
Time complexity 1)5
far(i 0, (n;i i
+

=
Worst case
if (aw [i]
key)9 =
=

Best case return I;


3
Average case 3

return
-

1;
3

Sunbeam Infotech www.sunbeaminfo.com


Linear Search
2 3 4
-
X o 7 56 78
Find a number in a list of given
numbers (random order). arr
88 33 66 99 11 77 22 55 11
m m

↑ the firstoccurrence
if
element is
repeated,
index will return.

linsearch
int (awr, key)
Time complexity
key 70 nitus
far(i (n;i
i 1)5 +

0,
=

-
Worst case < =

G
- xn =
manifes
key)9
if (aw [i]
%Egg-single
=
=

re
m

Best case <-


I;
return
Tk minimum its
3
=

↳ o(D
-

Average case nn

< candor elevant


find 3

return 1;
+azz
-

3
T2u
o(n)
ma

Sunbeam Infotech www.sunbeaminfo.com


Binary Search key 88 =

possible if is
~
only array already -
0 1 2 3 4 5 6 7 ->
8
sarted.
int bin search (arr, key) [ 11 22 33 44 55 66 77 88 99
e 0j=

e 2
v n =
-

1j
w)E
while(1
zit=b.n
= 20

w (l
=
+

1)/2; best case


log ->
middle
if(key =
=
aur(un)) finding

los w
single it
return los z
=

on; its ↓
1 k50(1)
avr(u))
=

if (key >

e m
=

1;
+
it
=
else -wast
case
found

3
v m
= -

1; -
a
return
-

j -> I las
m
-> ① (log 2)
3

Sunbeam Infotech www.sunbeaminfo.com


Thank you!
Nilesh Ghule <nilesh@sunbeaminfo.com>

Sunbeam Infotech www.sunbeaminfo.com

You might also like