ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
100 21
INFO LINK
300 41
200 31
400 51
500 NULL
11 41
21
31
51
Add
SRCHSL (INFO, LINK, START, ITEM, LOC)
START=11
ITEM=300
LOC=?
100 21
INFO LINK
300 41
200 31
400 51
500 NULL
41
21
31
51
1. Set PTR:= START
START=11
ITEM=300
LOC=?
11
Add
PTR=
100 21
INFO LINK
300 41
200 31
400 51
500 NULL
41
21
31
51
2. Repeat Step 3 while PTR≠ NULL
START=11
ITEM=300
LOC=?
11
Add
PTR=
100 21
INFO LINK
300 41
200 31
400 51
500 NULL
41
21
31
51
3. If ITEM>INFO[PTR]
START=11
ITEM=300
LOC=?
11
Add
PTR=
Means
300>100
100 21
INFO LINK
300 41
200 31
400 51
500 NULL
41
21
31
51
3. If ITEM>INFO[PTR] then
Set PTR:= LINK[PTR]
START=11
ITEM=300
LOC=?
11
Add
PTR=
Means
300>100
100 21
INFO LINK
300 41
200 31
400 51
500 NULL
41
21
31
51
3. If ITEM>INFO[PTR] then
Set PTR:= LINK[PTR]
START=11
ITEM=300
LOC=?
11
Add
PTR=
300>300
100 21
INFO LINK
300 41
200 31
400 51
500 NULL
41
21
31
51
3. If ITEM>INFO[PTR] then
Set PTR:= LINK[PTR]
Else if ITEM=INFO[PTR]
SET LOC=PTR and EXIT
START=11
ITEM=300
LOC= 21
11
Add
PTR=
300=300
100 21
INFO LINK
300 41
200 31
400 51
500 NULL
41
21
31
51
3. If ITEM>INFO[PTR] then
Set PTR:= LINK[PTR]
Else if ITEM=INFO[PTR]
SET LOC=PTR and EXIT
Else Set LOC:= NULL and Exit
START=11
ITEM=300
LOC= 21
11
Add
PTR=
300=300
Else if
if(ccondition)
{
Statement;
}
else if(condition 2)
{
Statement2;
}
else
{
Statement3
}
100 21
INFO LINK
300 41
200 31
400 51
500 NULL
41
21
31
51
1.[OVERFLOW?] IF AVAIL=NULL, the Write: OVERFLOW
START=11
11
START
AVAIL
100 21
INFO LINK
300 41
200 31
400 51
500 NULL
41
21
31
51
2. SET NEW:= AVAIL AND AVAIL:=LINK AVAIL
START=11
11
START
AVAIL LINK
NEW
100 21
INFO LINK
300 41
200 31
400 51
500 NULL
41
21
31
51
4. SET LINK[NEW]=START
START=11
11
NEW 23 11
START
100 21
INFO LINK
300 41
200 31
400 51
500 NULL
41
21
31
51
5. SET START=NEW
START=11
11
NEW 23 11
START

More Related Content

Linear linklist search

  • 1. 100 21 INFO LINK 300 41 200 31 400 51 500 NULL 11 41 21 31 51 Add SRCHSL (INFO, LINK, START, ITEM, LOC) START=11 ITEM=300 LOC=?
  • 2. 100 21 INFO LINK 300 41 200 31 400 51 500 NULL 41 21 31 51 1. Set PTR:= START START=11 ITEM=300 LOC=? 11 Add PTR=
  • 3. 100 21 INFO LINK 300 41 200 31 400 51 500 NULL 41 21 31 51 2. Repeat Step 3 while PTR≠ NULL START=11 ITEM=300 LOC=? 11 Add PTR=
  • 4. 100 21 INFO LINK 300 41 200 31 400 51 500 NULL 41 21 31 51 3. If ITEM>INFO[PTR] START=11 ITEM=300 LOC=? 11 Add PTR= Means 300>100
  • 5. 100 21 INFO LINK 300 41 200 31 400 51 500 NULL 41 21 31 51 3. If ITEM>INFO[PTR] then Set PTR:= LINK[PTR] START=11 ITEM=300 LOC=? 11 Add PTR= Means 300>100
  • 6. 100 21 INFO LINK 300 41 200 31 400 51 500 NULL 41 21 31 51 3. If ITEM>INFO[PTR] then Set PTR:= LINK[PTR] START=11 ITEM=300 LOC=? 11 Add PTR= 300>300
  • 7. 100 21 INFO LINK 300 41 200 31 400 51 500 NULL 41 21 31 51 3. If ITEM>INFO[PTR] then Set PTR:= LINK[PTR] Else if ITEM=INFO[PTR] SET LOC=PTR and EXIT START=11 ITEM=300 LOC= 21 11 Add PTR= 300=300
  • 8. 100 21 INFO LINK 300 41 200 31 400 51 500 NULL 41 21 31 51 3. If ITEM>INFO[PTR] then Set PTR:= LINK[PTR] Else if ITEM=INFO[PTR] SET LOC=PTR and EXIT Else Set LOC:= NULL and Exit START=11 ITEM=300 LOC= 21 11 Add PTR= 300=300
  • 9. Else if if(ccondition) { Statement; } else if(condition 2) { Statement2; } else { Statement3 }
  • 10. 100 21 INFO LINK 300 41 200 31 400 51 500 NULL 41 21 31 51 1.[OVERFLOW?] IF AVAIL=NULL, the Write: OVERFLOW START=11 11 START AVAIL
  • 11. 100 21 INFO LINK 300 41 200 31 400 51 500 NULL 41 21 31 51 2. SET NEW:= AVAIL AND AVAIL:=LINK AVAIL START=11 11 START AVAIL LINK NEW
  • 12. 100 21 INFO LINK 300 41 200 31 400 51 500 NULL 41 21 31 51 4. SET LINK[NEW]=START START=11 11 NEW 23 11 START
  • 13. 100 21 INFO LINK 300 41 200 31 400 51 500 NULL 41 21 31 51 5. SET START=NEW START=11 11 NEW 23 11 START