0% found this document useful (0 votes)
26 views8 pages

DLL (Solving Question)

The document describes a double linked list data structure and its operations. A double linked list has pointers to both the next and previous nodes, allowing traversal in both directions. Methods are provided to add, remove, and search nodes in the list using an iterator or by traversing the nodes directly.

Uploaded by

noorjafffer
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)
26 views8 pages

DLL (Solving Question)

The document describes a double linked list data structure and its operations. A double linked list has pointers to both the next and previous nodes, allowing traversal in both directions. Methods are provided to add, remove, and search nodes in the list using an iterator or by traversing the nodes directly.

Uploaded by

noorjafffer
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
You are on page 1/ 8

Double linked list


~

ple
itex10
-

head Her 2

1201 Is) 1401 E


-

=
- -
has Next has Next

(true) (true)

iter49tPol 1981 -ol E

Hert, next- 18
-
10 iterz. next =

-
equal
ple
not

- public void undefined (S0);

iteyist 4,01 -
= 1901 =(0) =
10 10
=

& equal

Yitpo=901 = 190) =(0) =


I
=2
r
x 15
=

y 15=

If(X =
= y) 15 30
+

iter. Set (15 + (15 x 2)


(4)
ter. Set

=):/2
-

sto
-N
Her null

:E)

13//
38 as
=
a
↳ is

↳mini
↳ :dant

=):=
n

re
I

:
88 50 To 1038 20

-metinued
fireisdie eine

->
-
flyinga I
::
20

->

=:: (l)=
30

38

:41)
10 70 5888

70
Output
10 30 20
↳" :(1)
80 so 10 30
E

20

80 So 70 1030 20

78 so 8o

2038 10 70 so 80

38

80 So 1830 20



list. add (0)

⑭nead
N::e2
=>

cer

):
-
X
: ::
X

⑳ E
27.2 = = 1 No 3%2 = 1yes
=

Her. Set (3 1 +
4)
=

: e2
-

42 18
-

Euse-> head,tail keep per

public void reverse Nodel) E


If (Size = 1)
=

System. out.
Printin ("Listis Empty");
else E

Node (E)f= head;

Node(z) b tail;
=

E item 1 item 2;

for (inti =0, is


size/a,i 1)+

item 1 f. data,
=

item 2 b. data;
=

f.data_item 2;

b. data-item 1,
f f.=

next;

b boprev;333
=
-
Search
&
befor item.
item if add node
to und

&true

list
1 with Iterator 1) listiterator
without
if (head null) ==
If (head==null) return false;
return false; Node (1) ptr-head;
List Iterator (2) iter= list Iterator(); Node(E) newNode new Node
=
(item 1);
Ex ;
boolean found:
false;
While (iter. has Next()) 2

X iter,
=
next ();
While (ptr!=null 8x! found)
if (X. equals (item)) If (ptrdata = item)
=

E found =
true;
int iter. next Index();
y
=

else
/Ifnode be added
to
before the firstnode
f(y -
z (0)2 ptr ptr.next; 3
=

add First (item 1); (found) E


If
return true;
If (ptr = head)
=

1) Ifadd node some where in middle


add First (item 1];
iter=listIterator (y);
iter (): elseE
previous
add (item1);
ptr.prev. next newNode;
iter. =

return true;
33// end for while
New Noch, next
return false;3 ptr;
=

New Node.prev=ptroprev;
proper new Nole;3
-

Sizett;
return true;3

return false; 3
check
head:
tail

head, next:
tail, previous

↳half half

1with
list iterator 1/ withoutdistiteratur
E E
List Iterator listIterator (0):
fptr head;
(t) nextIter
Node (E)
=

List Iterator (1) listlerator (Size);


prevIter
=

Node (t) bptr=tail;


int count = 8;
int
court 0;
Ea,b; =

while (count a Size/2) E while(crunt<Size/2) E


a nextIter.next();
=

If (fptr. data! =bptr.data)


b
pevIteroprer();
=

return false;
count 1+i
else?
If (ba. equals(b))
return false;3 fptr fptr.next();
=

return true;3 bptr=bptr.prev);


cant++;33
return true; 3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy