0% found this document useful (0 votes)
1 views11 pages

004 Recursion 2

The document outlines various algorithms and recursive functions related to string manipulation, including finding lengths, removing duplicates, and merging sorted arrays. It discusses specific methods for handling strings, such as recursive character checks and subset generation. Additionally, it includes code snippets and examples to illustrate the concepts presented.

Uploaded by

poojar.cs.24
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views11 pages

004 Recursion 2

The document outlines various algorithms and recursive functions related to string manipulation, including finding lengths, removing duplicates, and merging sorted arrays. It discusses specific methods for handling strings, such as recursive character checks and subset generation. Additionally, it includes code snippets and examples to illustrate the concepts presented.

Uploaded by

poojar.cs.24
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Duta 5 822

Recues on-2 Page No.

RecwtSion Stri n 67

finding Leng th od O Stmng


"amit 4

BaDe Coune Sto n s mpt


Id Can [ol== \0 etom

etom n9 th (orn ti) t1

2 Repta@ Chavactet Recurcive


(ob cda) a
xbCd C output.

(Stnlen (au)= =0) petumm


pepiaceCan t1 chi, en 2),
it (an [o] =e eh1)
aun tol = CU2

3
Remove Dupli Cotos Recut SiuQu
aab ce ba abcba
Cny ConsideT MeaUT Chanacken-

pemoNe CouUl +D

Su Ci o i< strtevm Com) , i+7)3


an Ti] = a [ t12
Date |
Page No.

4. Meroge Sorot Algo


MeTae Stot is a_ pecurcSi ve algo
Bneak th aun c mto
two Pants.
Hhem megejo peuun)iom
thOn menge mto a
uOhol
Soph9
aid Meuge Sotot (int on t1, int S, imte)
=e)_=e) netum
mide = (Ste2/2

meoe SUTD+ (aJUL, S, m )


m e Sovot Coun mt1, e);
mei m Coun S, mm, e )

3
vOid m TgN nt an [1 int lo int mid int h12h)
MeR So mo Wo)

i ck
5 Sord 120
povctiion)

UOnd s i n t an t1, m Si, intei) 3


bane ase
Ce Papt HOn (vUl Si ei)
S CaU Si> C-1)
te
pate
Page No.

PoctiHon

CoUnt SmaLn lomA n


than
SE On
si+ bun)

Q1se i& Cata 2 3 J-


es e 3
Swap Cantil, auz ti1)

t n2in Ctt

Upo mao we Used Chan aOUY Stor


Sttoir
Put im Ct thee_awoulolbie aShon cla

SthangS "abe

6tmin9* SP =mew Stin9


A
SP ami

5.Sj2e()
S.9bStro (3);
[Link] Mdej ");
Date L
Page No.

6 Re turnn Sobsequenas Og o Str


CoC

No O8 S S. 2
2
be
ee-
odoC

int onchion (Stmng inpu, Sing oukput C

Bane Gne- 'u

Reewse
wui h @mdlo
b

ac
Cappend 'abedone
thoa
if CStolen Cinpul-)= = o)}
Oukpn [o]
yoetom

E
Small Hns Junction inpru, substn(1), ouhpt),

otphL+ SmallfAmS] input [o]+output [il

nevmm 2* Smaul Pms,

WCopY the qns a0d append the


fiostChona Cten be fore thonl ormd
netwn ( 2 ) th
Date
Page No.

7 Retom key pod Approach


29 (2)> Ovd

at
mno bd
8 9 b
EVV WXy Cd
Ce

T23 ssome 2Pe Chou Taye


SO

OukpuF X lengtn (algit - Straima)

nke picho uco Chana cken l o d o .


then we Cam 2 o deined ouhat

int dunchion Gnt mombën, Stmrg outputLI)

OulptTOT=

Strinkeypod "," ""abC", "de!", "ghi","JKl',


mno, Pqns", "tvvh*w7y 7"
int end-diat= numben /, 10
int small fnS = fun chion (mumhen10, output)
Stm ng* teme me Stin9 [SmoulA8]
forr GnE i0 i<SmalfAns', itt)
temp [ i e output Li]

f CinE i=0% i< heypad Cend-di hE].Si2eC);i+t)}


Farint J-0) JL Smal fns Jt t) 3
tempL/t keypad
Outp wt [Y Smal AnstJ=
Tend-digi+J C1
petum Keypad [end-digit). sizet) * SmauAns ,
Date
-
Page No.

. Check AB
T h e SAmng begins wim an an aa '
2 fach ' a ' is folg wed y nothiv on
om a ' Oy b
3. Eachbb isfoluawodbmothin9on
Om aa),

abb m
bobolba fouse.

bool heper (( Cha inpuCI)


(Sto l e n Cinpnt) = = ' \0) nelurm tma

i t (inpuTo]== 'ao'12 npuutCI7= "\0' 1l inputT4 =a'))


=

etuvan helpeh Cimpu- +1)


(inpot To]- = "oa&2 Gnpn-Ti)--"b'linput C2]-="b'))
netDm helpen npul- + )
Cinput [o-"b 1! input T-="b &2 Cin Puut [2]=-
1l input t2] =='a'))

pe tum helpor nput t2)


pelumobe

9. Stain ane. (n) no O wa][sSteps - ,2.3]


5

SCC3) Sccsct1) 22
12-

setm-2) B2
Sc(m-1)
scCH-3)
se(n)
i (n ==0)

id (nal I| n=-2) neumm ,


betum SAoiva (m-1) +SIain (n-2) + Stoun (m-) ,
Data
Page No.
10.
Binary arch CusSing Recucdion)
2 532 1
ntk

nE
helpen mtan t1, mt SI, int eip
d Ceiz=si) _
n t mid =(SI +ei)/2
an[mid] = = k)
reton mid
C a mid 1 )
eform olpen (oru, SL mid -1,K)

pebm helpen (aU mid+ ei K)

ptom -1
3
41. Retum Sub set_Q an amc
3
520-12
5
20
1 52 0
RecucSi0 2 5 12
22 20
120 3TS 20 12
+2
2 2 01 2
15 Cor
Copy that Outpuu
2 15 20 CUUncu and attach
2 IS12
3120 12 hot
But a Stm ng eanily y ou an mo
Con Couli nate (Thonl u meld to main taun S2
Date
Page No.

i (n= = o)
output [o1 [o] = O
netum 1
nt mall Pns =
subse Gnput +1,m-1, etput)

culput[it smal Ans] [o1 output ti] [ol f1


=

utpuu- i+ Smcdls ] il
ttpukEt mput [OJ
fur Cint i0, Small Ansitt)
int Coul= Output litgmallAnA) [o]
S Cin J-9, J-Cod +*) 3
tput t tan8] LJJ =oUdput Tti] [3-11

peturm Sraule ¥A,

12 Pelo m Su se-S Sumto k


6
3 2 S

S 2 y6
2s16
Si
erclude .

TTtde

CUD, S1TT K
ErenudR_uul

Coy

n u

n S valuw
Date
Page No.

Bane Cone
-S==m
C =0)
Okpr O1 [O] =0,
etwmt
eup 0

Creud tmetndo2

Cep
THn i j e t d +
Col

S12 3 1 18

T22/2
VSi
nhw anay1
Recgi0
Date
Page No.
13.T Retuvm Ces-Stiu9
L23)

423D
W
AeSiO
CbeP

tau
bC

i t ([Link] 2e() 0 )
SPmPUsh-bCnLow)

eurm

romen a s 2 .

VOW C ShHoCo3tStoCi)

1 possib
Coul
h A tChapal
Date
Page No.

RehmRehron Pemutahion8- Stmn


bC Onb

1EnpntSi200 aeD
owpntLoj=)npF TO
bttwmt
4RPCuno
abC bC
Tb ab

Stm
t anb = peaun3i0)

s C J-0 o On
ohkprLinderra
mpn- CJt Smal
Owwph
3
OSUme

nor ColA oe u O
nemauin
qm Ondd An and
ncd d
thom assumL b St
Con Cal re(U)10D omam

You might also like