Professional Documents
Culture Documents
Week-7
~
f the Session: -
l)lfCO
I
-
I
-
-nulslte .
"'""eue - First in First out
• QII c ha!I two openings
1
1 ~tll. Uy FRONT • REAR • -1
. )
Time of the Se!lslon:
--
to
Int
Operation _ lnscrtmn - Enqueue(
: Operation _ Deletion - Dequeue()
tBlfbJask
I. Slaow the detailed contents of the stack after performing the following operation, and w<ite '""in., ~
....,_
dDcpp(). enqueue( pop
push and'P'), operations. enqueue('P'),
dcqueue(),enqueue(' A'). enqueue(' U'), dequeue(), cnqucuc('S'), cnqucue(' H"),
C' r ' .) .i
'e.11\~~ \.C e
de-.,1.A e~ C) )•
~~"'-e { 1 A') j
~ \ ~k~t) J
v:, ,·cJ.. e ~ e Cc. k ir Q.(. e) ,t_
€.be .(.
ft (¥/It .:..::- \ ~~ VfE."Q.T:::: - l j
~
'r'"8'.lY-f-fJ
~
f ,..;,,._M- ( \ \ (- C. i~ ~ 4 ~ ~ ,,, ,~ ~ J;
""'tol deyu e ue ( ?{
,J ( ~Ill -: -=.- l )
.t.
l>MM (" U)'\de1-~ w \,/ ') j
J,
e,be_ '(
f»' )i ~ (' ' ·/ ·c.. i.t d.~....e,.,.J,.._ \l"l ''.,4ue.J-te. r,,. ~ nt- J ~
1°k (..\-vl"ll =-.:. teq¥)
{
,f-K,nc :::-1;
j
~
"°i cJ. cJ.;sp~C ) -:i
<
wtion ,m"t11'i11c 111 c ,)tlllelc,jlcld with th N
uw•Y'the 11111t b,>~I"· Imp Icmcint queu~ u ei . numh er of Bagi
~ etl~,,e( ••~,uie
IJI, rt
t SLL, Opernt10,~s Which are con
u11in1i Sl111ilc Llnketl Ll11t. Te,u tl~.."H
11.,.. , do
r • ..-.htll•
""• ., love p s are crention ·nected tn
ft · one d'
· SLL
rngrnin using
fl"~ for II , 1ns-·
... ,,on, d I .trecll·on
_,,dll • menu oPtio ' '"on Ind
~ ~ail'C.) ~
'~~ c.\..~c.e ;
~ \e t'-){
\>' '"t-\ (" \ •cl"l"),ue,gc. \ n J . ~ ~c..<a.e ' " ~. t) i~ ~~ \~ .y ,e~il \ 11 •) ~
~"t~ l '4 O'I ~.,. ~ e c}o ice \ n '' )~
s~ , " i d ';I ~ d,o((e)~
~~ i-l<:"" (.c.w,i ce ') ·
t CD~e \ ·• o-ii, ueL<e. < ''/
»<e..~:.
~ l- '; d.<ayu0- e.C1 ·,
~ ye,_\: :
~L l : ~f>L&.j<: J ~
~~}
~ee 1-1 ; e'lti'i.t .,;~
de~; p>i"ti C'' f "11cil.d ' t
j 1
----
v0l &. e_no.,v.~,._e c) ~
~~ >-.o&t! -+ ch' ·=
~&,~ne·,rf-:- rJ uL L)
.( ~ rk 'i'. ~)
\es,Y t r::' j
":>
.tCA- ,l
rQ.c'< ~"e><l.:- r:~~
,y~v--::- ph:,
)
~
~
dre ecr{.,-);
~
\.,o\d. cl:~~ ) (
~~ roc(.e "' p(;-r- =~t;
,·~ (.p~=- ~ NULL)-{
~11HCt' (3) tlf'u e ,~ e.,.,f ~ \11 '1~;
~,11:, l
l.J...' (.e t t" I , "' CIU. ) {
pri11H ("·/. d ", p(r ...\M<·);,
f(.,r f ~ -41\~c-.:,
- --
21sc1202 - DATA STRUCl'UREs
t1sk
~eue
1.
y~
~ 2
·ven a sequ
1iave t,een Ogtf operat'ons
types
1
.
ence
.
on this hst: •digits. Each digit in thi, leq,,cnc.,
A ofN
the end of the hst .
range, rr..., 11q It)'} . y.., ,_..,
V-::U
_..fortD)· Add element x ~o
maximum element in the current llequence.
ha .
~rP\.,._ · )·. find of
fdax(list
ch query thetype 2, you need to printthe result oft t •-•lion.
for ea
,cq,s:JfwWW.bac
kereartb.co
---'algorithm/queu
probleuu,
m/procttwdot■-structu
es-c:ontent-problemJ ...1,r-,hc•l"••lorhy-11•-•r..,..._
l.
\lc:tcl.. d..s ~ l )
~ .
-~~ \ :.
~ C~ "l -:: -::. .., J
(->rt·~ C'' Q4e",e
e\;L t.
~y-(.. \ ~~\O~-l:., \c:. ~ Y EQ'r; ~"f- "'t)
t>°" ~ ( '( .., .cl ,, , '\, u 0-t e [ I"~ ) ·,
~ C~l.le"' e Cr ) ~ rnct>c~
t er namehich~ts to be checke
customber
et num w
oblems/KCPROG4
d in the da tab ase an d
ll:tftnn!,codecbef.com/pr
~ >
c. ~ po -)
i.s ~~ \i ~ d s~
b,
, 11 ~
'J
k( I:. ~ p~ , 'h t I'\ J
"U1ol (> '1- SJ ..( ~c _k ~-
()~~~+~
('~➔ ~t .C p& ~ bf
'7 ~ n_;
J.
c-----__________________ _ r 98 L
1,)1';\o;u, ... wn-· ... " r t-,- )
,._ . , .. \,P\~ ft>r( ~~,. .,~ ~l 41 CII"
i rtv ~ ~ r> - ~ j
"'
t"'- n, It j
~I'\ ~ l.anj ,'IJ -i 'jt:
l ""i..·1e (J1 ~ Ht.>, ~ bip1 '::» ~n:i 2..e '- ~&.f~ Cs, ))
? ""~
t,il ftie cifCU e first node to ma e a circ e.
to th
circular q1Jeue, the b
" ..n, •
,_I
. ~'111.hackerrank.com contests 17cs1102 challen es 7a-circular- ueue-usin -ar as
~,"c.\-6..e ~s~fi.\'c,.~?
-tf. t "<.~~ e £S~l:\,. ~'>
'd&. ~ )i
\,\':ill. I..~ 'j
~~ mav-ic ) 1.
\ ~ c:.\,«,,·cc_· J
w'--4'\e l \) { . -1·& ;( vl J;
. ~ . d.'.) p I°'::! \ll
~v, ~P..l '' 1 .G,~"'E:"-.e \., i,. O E'5 ~e<-e.\n
~ i,.,1 'l(l,,(d,oice)
~
CA.)~ \ ~ 40 j
\,~ le j
~ 3 ~ ~.) p4'1( ) ~
~Q. r :i
cle!o.""( '= ;
Q~,•v,.>/·
~n, o:.
~
-w,cl..~c.) ./. .
rJ:- Q.tQ.;
~c~ ( •••td ~ QdeJ~
i~ ( ~ l -= : o .e. Q rtnr : =!,i7e , 1 \I +-,11~ r ~ l-1nr+lj
P,.'.-..M ("'QI.{ "'~ over..\(ow ,, ) j
~ n,• J
W.::r~ o .,J·
l
e\~ <.
H(~ear -: :. .si-ze,-\ )
'(t!a'r f tj
,. ~
~ e C~tJ:-e1 e;, ~
\ioC ci clo,< H
,Hbnti .. ..()
-.e,l>.n,:.
~ t ~o:,
ts of the queue data s~crure oy ms~mng numoers 10, 15, 5, 25, 17, 21
73
·icd conten e after performing the following operations? i. Delet ' ' 0. Wl
dctB' f the queu e two elements .. I
wtJtC tents o . u. ns,
511"
I, dt,e
,~e coll
~~zO·
,1'
, ,#;o.~>
•r,t.l .#,
I' ~ctU\,\.i-::>
. ..,.l,,&e
,IJ \ ,..
'->
VJ'"' aiyt ')~
•J l-,.t .,.)
\P\ CI, I
.I • DI t'l,f ),
-~ 11'-' ) '
'-"' C:'\) -ls--;:_'(":,-\' •
, -.J:: \ \'t.e. =~ , -vue.\,e , ,I
t\J.- C"fl~'\t.)
(
,fl1c d.,.,ic.Ci?~
La>Wle( 1 )
,t
~Y\flt.~ \~' \·Gi',t.<~e. \ " ':l ~~cayve.....e\l'\ ~- ~\~ \r, 4,e~ \t , vi '')~
~rtn t:.li- t
II
tf'\ le-r 4.\-e c.bi c:e '' )'.,
')
100 111111
ehe.
~c•c.,c,~ ~")~
""tV--7:.-' fl~"':::-\) ~
1~ rco; ~
~(-'e.~ ..._
"(~-t;
~
q,~ei..~(y-J ~ "~
~(f cl,-O{
~\,e_ ~
\pp\ ,t.,. j
,s\=ac\c, [~~-:> ..._ cJ...a. t a~
,~ vet=>'' t..
;.1r t~t>' -:..::- \ ')
pyc' i,t,~l• Slt:IC.\. ~ err,~-y,1 ):
'-\)e.. "'
j" t O -:. S lea C. \.: \ t ~~ r:i·.,
b>p' - -~
~ ' \ . l Y f'I Q ~
~\~ ~
~'\'~4-+ )
5 ~oc~ '). nx~,?l --=- x-;
I
I
e.-\" :a - .. )
1
I ..."'~'" ~k~""" t l
I ~ ~."".(l,J, .),
j ri-4)\ i(>r>J
I .. ~l ,f + ~ }
t ~
\.o ,, d.. ct e, ~ ( ' d• c) i
I ili- \ l"-'\)'- , ,. -t a~
et~ (
~~:i -s. a - 1 ) J
\~\. = \=O~io~
b
t-,,1'{~ t"·l•d.' t b ):,
~
\l\l- ~ .. ~~{ ) '.I
f'1.) ~ , ( <"J.) .)
~ ~
\oi'c:l cic\~~ (.) ~
~(c~ t ... ~~~<'&.~t;;r"f~
l
'
~
"'i''l~~(•II-/. d.,,
• ,
19L-.
~\:I Crl )~
~,~ o·..,
~•<'lo)~
~·~(.))
~5"....
i 11:
''
~
jlll"'*~
1 the Head Chef) are standtng 1n que~e to submit their bills
_ ,e,cept 11 re are N chefs of K d t!Terent seniority levels. These a ·. The Chef, bav,
·
.,at,Jtejs
~It 1"' en'°" (_ty. In all •~enote the seniority of chers in the queue, "• denot: ~ven to You in ,.
...,
s At. A,, heANqueue. . . . . ont of the qucu,
dilfe where end oft .. thought past his head, He begins to think what if every chef stan· fr om
y otes . terestmg10 . . b f b 't . b'll h tng
,,,.; c1en ts an Ill delegate htS Jo o su m1 hng I s to a e er least ahead of him i th
Clt'r!e
.
~ ~
,..ieod
quell
thC eeObutfcbe
JUfn queue an<I m
fe fulness ~ Head Chefs. mind.
fu
queue _beg~~e Head Chefs fear In~•• of this scenario is r • 12 - II + t, where : ~
r,1 of. ,or to hun, 11 1, the index of the Junior chef, Head Cher s total rearru Ines, or chao, 11 is the
f . 1Note ir a cher has no junior ahead of him/her in1the
nthe ar
~
. del fulness for this Che . 1s .
th fearfu Ines, given an arrangement of Cher, in a queue.
P'~~ethen of•H~ed
q11 are requ
d Chefs
find
toan fear
be e_H~a
quite ar outputtotal
dgeChefs it modulo 1000000007.
yo11 . number c
· ili~ UE
odechef.com/problems/CHFOUE
SinCe
~,c_
l!!"'am :-
~<-~i ~ . 'r\":::>
~ ,nc..\v.
, u"'~e <~ t
~ u""•"'".:>
.. \ti
,'Jc ""°'"t ) ~
'" Ir ",\<. )
~ ~" 5 vk """ ':. I ;
s=....-\- l '' .,:ct "'~d. : D.." I' ~~ );
Mk ClU\J':,
~y( c'>tk [=O~t<l'\j{-f'f) ~
gl ➔~C-z.e.. =n;
s1~ L"Df:. 0,
.S.l..., &'\: :- C. r ~ ~) Yl"'R\ lo <'- Ul '2e. t)-\ ( t.J-) ... t\)~
p~~ -=- c;.J:. .. ) ~ C . (.lt z.eu,\(/-,tJ
!.\......, & Fi ) •
ti,;,,-~
ti''
· ..-i tht
. art f''CI\ the"'
arro' d in w llC
. t/output "
I . ,, people l\l'flVC at t ,e osptto and ave to print the order of th .
. .
me tilll<ls. Pylhon users •hould sub1mt thc1r ll<llution, in pypy 3.
.
ctr appointments
·
,·111 r.st ,npu
t-li«: tl$C
toduhef,com/oroblcms/CAC202
--
~
--
t..:>~'le {t:---) 4_
):,Oo LIJ ~ Oj
~
w~'I~ C'l--) ,l
~ •y .a1 1., ~ ')( ).:,
~ (,>\ ~l'n) {
10:
'p~ (>e ') =- ';
~ , e( ~~ ! ~ -, O~ b::P '( ~ ( ~ J'1--.. ~ , J~
~ r~r~'J] ~ ~:,
l'"ili , ...., ~d ..: s C~0 3 J~
~r--J
:,
'-'.;)½'\e. (. lo(>~ -:. - \) ~
~ -I
.,,.cJ""&e
J.f ~.)
to~·~·t.,>
1'rl,V' ~
j:l .t ,,od.."
·J, a.,, ~a i
' ~V"'
\
t Y'«l e ..\
n~>c-t.,;.
~(:_...,.C..,.,-
L J. '(«J,Y j
,,.~,,~ I
l ~~ c~icoj
1.,.) ,.c'l~t,)
~
c~:a e ,: €-11 ')..-L<e=t. e t ) .)
t.:>~(c ~
~~ .l. : ~<ecj t ! . t ~ C ) :
\, )" ~c:::: \c ~
lA~ \ ·. ~ ~j p~c:,;
\, 1--e~~ :.
104
~
~ )e -'
~ ~" ~~ ~ .= p(y;
~'(;~~~
~,...& ~e.e c) f.
~cl~~"~ ~
,l( ~,J;:- ::::N" LL I
~ - : ~--l~ l) ~,i.:{)
-t-~ cf)~>~
JU IQ c1, .a P~;
P-=~d;
,\.(► ~=/\I "t( )
~ ,-
"-A.~,,( «"lll. f
......_ "- "111 «J
'
l ,\ "'~ t ·..
,SC4'rt'' -.,d•,. ~l).:,
~~ \t t ~--)
l ~~ '· ~o~~~
s c~ t "' i .d \. !:t no oi ~~ \:,
j
l on ~ ➔ :aw- Ct J',,
\ -~ ( ~ .-..> ") ~ l~"" )
I ~-- ~ ~;
b~ak;
~
,., ~~ ~ -= 0 )
-'lt!,e ~
'
')
~~e ~ 1 ~"o.'-\::>
-ii:. (\(...\(A c,.
11 t" L ~ ~ rl \1'3 · I\'.:>
i i,,d .. o.
JI. °'r(l ... cte ~ tyr::ttJ..· \.-\ ~
,-' €rt a '-( e,_U~ t ,'-i!- '.) ~
w1 eo. "
I.A4~c( c/.. ~"" e<-t e C.. l:,
""''&.. pi ~ _el.e t,.:,
(\.t ,\-atl t ":. - 1., Y ~"(""~ - l _. ~,•2.e ':. f OO~e>~O~
,~ t1. CSt?-.c1:.
µ ~ O:n C. ) -l
,.t. , ,.
~ . ' _,,.., '~
e"~-~
\.,yeo. le. .:,
Uc..
\ (ii
------