返回首页

php 单链表查找

234 2024-03-09 21:47 admin
php class Node { public $data; public $next; public function __construct($data) { $this->data = $data; $this->next = null; } } class SinglyLinkedList { private $head; public function __construct() { $this->head = null; } public function search($key) { $current = $this->head; while ($current != null && $current->data != $key) { $current = $current->next; } if ($current == null) { return false; } else { return true; } } }
顶一下
(0)
0%
踩一下
(0)
0%
相关评论
我要评论
用户名: 验证码:点击我更换图片

网站地图 (共30个专题154490篇文章)

返回首页