search
HomeBackend DevelopmentPHP Tutorialphp程序员要不要学数据结构?

最近参加几个大公司的校招笔试,大部分试题都是数据结构和算法之类的,php怎么用到数据结构呢?恳请过来人给小弟一些指示,多谢多谢

回复内容:

程序员都要学 数据结构是基础,链表、二叉树、哈希、排序算法等,你可能在写PHP代码的时候,不一定能够用上,但是,掌握它们能让你对程序的运作原理有更深的理解。

举个简单的例子:
我们经常使用PHP数组,PHP数组不仅可以foreach的方式遍历,又能通过key-value的方式访问,我们都觉得很便利,那么问题来了,为神马会这样?
原因是PHP5的数组,是个HashTable(哈希表,支持key-value直接映射),并且元素之间又用双向链表连接起来(支持遍历)。如果,同学们不学习数据结构,连链表和hash都不知道,就更谈不上理解内部的运作原理。

这个只是数据结构应用的冰山一角,想对技术有深一些的理解,学好数据结构很有必要。而更好地掌握原理层,又可以促进我们对程序的优化和思考,采用更节省系统资源的方式完成我们的业务需求。 单纯从PHP码代码的角度来说不需要,但是校招你又没有做过什么项目,那不问你数据结构跟算法,问你什么问题呢?至少,数据结构和算法可以检验你在大学中是否认真学习了。 周二刚好面试了一个php程序员,除了一道题,合格答案是O(n^2)交叉遍历两个数组,优良答案是O(N)遍历第一个数组做一个Map,再遍历第二个数组顺便查Map。

然而此人除了调用PHP方法in_array(?)之外,就不知道怎么做一个Map了。现在我们对于要不要招这个人很纠结






才怪。 这也不学,那也不学,那你学什么呢? 个人建议是:先搞定工作,业余时间有针对的学习。 有时间在这刷知乎找答案,还不如去找本数据结构的书看一看呢! 答主曾经年纪小,误入传销组织,里面各种遍历树 自从协程大行其道,数据库结构也不够用了,还要操作系统原理,并行计算都得上阵,这得多累啊,如果钱没多,着实不能干。 不用学,五年后转管理岗
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Explain how load balancing affects session management and how to address it.Explain how load balancing affects session management and how to address it.Apr 29, 2025 am 12:42 AM

Load balancing affects session management, but can be resolved with session replication, session stickiness, and centralized session storage. 1. Session Replication Copy session data between servers. 2. Session stickiness directs user requests to the same server. 3. Centralized session storage uses independent servers such as Redis to store session data to ensure data sharing.

Explain the concept of session locking.Explain the concept of session locking.Apr 29, 2025 am 12:39 AM

Sessionlockingisatechniqueusedtoensureauser'ssessionremainsexclusivetooneuseratatime.Itiscrucialforpreventingdatacorruptionandsecuritybreachesinmulti-userapplications.Sessionlockingisimplementedusingserver-sidelockingmechanisms,suchasReentrantLockinJ

Are there any alternatives to PHP sessions?Are there any alternatives to PHP sessions?Apr 29, 2025 am 12:36 AM

Alternatives to PHP sessions include Cookies, Token-based Authentication, Database-based Sessions, and Redis/Memcached. 1.Cookies manage sessions by storing data on the client, which is simple but low in security. 2.Token-based Authentication uses tokens to verify users, which is highly secure but requires additional logic. 3.Database-basedSessions stores data in the database, which has good scalability but may affect performance. 4. Redis/Memcached uses distributed cache to improve performance and scalability, but requires additional matching

Define the term 'session hijacking' in the context of PHP.Define the term 'session hijacking' in the context of PHP.Apr 29, 2025 am 12:33 AM

Sessionhijacking refers to an attacker impersonating a user by obtaining the user's sessionID. Prevention methods include: 1) encrypting communication using HTTPS; 2) verifying the source of the sessionID; 3) using a secure sessionID generation algorithm; 4) regularly updating the sessionID.

What is the full form of PHP?What is the full form of PHP?Apr 28, 2025 pm 04:58 PM

The article discusses PHP, detailing its full form, main uses in web development, comparison with Python and Java, and its ease of learning for beginners.

How does PHP handle form data?How does PHP handle form data?Apr 28, 2025 pm 04:57 PM

PHP handles form data using $\_POST and $\_GET superglobals, with security ensured through validation, sanitization, and secure database interactions.

What is the difference between PHP and ASP.NET?What is the difference between PHP and ASP.NET?Apr 28, 2025 pm 04:56 PM

The article compares PHP and ASP.NET, focusing on their suitability for large-scale web applications, performance differences, and security features. Both are viable for large projects, but PHP is open-source and platform-independent, while ASP.NET,

Is PHP a case-sensitive language?Is PHP a case-sensitive language?Apr 28, 2025 pm 04:55 PM

PHP's case sensitivity varies: functions are insensitive, while variables and classes are sensitive. Best practices include consistent naming and using case-insensitive functions for comparisons.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools