-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinked_list.php
More file actions
42 lines (29 loc) · 796 Bytes
/
linked_list.php
File metadata and controls
42 lines (29 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
include_once "../vendor/autoload.php";
use App\LinkedList\LinkedList;
$names = ["Smantha", "Suzy", "Krystal", "Justine"];
$list = new LinkedList();
foreach ($names as $name) {
$list->push($name);
}
echo "Append/push<br>";
$list->append("John");
$list->printList("<br>");
echo "<br>Prepend/unshift<br>";
$list->prepend("Micheal");
$list->printList("<br>");
echo "<br>Insert After<br>";
$list->insertAfter("Sam", "Suzy");
$list->printList("<br>");
echo "<br>Insert Before<br>";
$list->insertBefore("Lilly", "Suzy");
$list->printList("<br>");
echo "<br>Delete<br>";
$list->delete("Sam");
$list->printList("<br>");
echo "<br>Delete First/Shift<br>";
$list->deleteFirst();
$list->printList("<br>");
echo "<br>Delete Last/pop<br>";
$list->deleteLast();
$list->printList("<br>");