百度笔试题目解析

1. 输出结果
<?php
       $array= array('1','1');
       foreach($array as $k=>$v){
              $v= 2;
       }
?>

结果为array('1','1'),因为foreach()仅仅只是不是引用而是形参

2.sax对xml的解析
<span style="white-space:pre">	</span>sax解析xml时不会像dom解析那样在内存里面建立一个dom对象而仅仅只是一行一行的解析xml所以每次都只读入一行xml这样的话效率高内存占用都会少很多

3.并发会带来的数据不一致性
<span style="white-space:pre">	</span>丢失修改、不可重复读、脏读
4.SQL中关于视图操作
<span style="white-space:pre">	</span>视图仅仅只是你用sql语句建立起来的一个虚表一样的东西。
<span style="white-space:pre">	</span>所以你的任何改动都不会引起实际的表的改动。
<span style="white-space:pre">	</span>你可以通过存储结构,从另外一个视图,查询内部等方式来建立起以个视图,当你使用with checkout option 的时候,那么你要在视图上进行的增删改查都需要符合你视图定义时的where语句的条件才行不然的话是不效果的。
5.磁盘的扫面算法
<span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">            例</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">:</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">假定某磁盘共有</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">200</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">个柱面,编号为</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">0-199</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">,如果在为访问</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">143</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">号柱面的请求者服务后,当前正在为访问</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">125</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">号柱面的请求服务,同时有若干请求者在等待服务,它们每次要访问的柱面号为</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">   86</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">,</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">147</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">,</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">91</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">,</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">177</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">,</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">94</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">,</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">150</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">,</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">102</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">,</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">175</span><span style="color: rgb(0, 0, 205); font-family: Arial; font-size: 14px; line-height: 26px;">,</span><span style="color: rgb(0, 0, 205); font-family: Arial; line-height: 26px; font-size: 12pt;">130</span>
<span style="white-space:pre">	</span>FCFS:先来先服务  根据先到先扫描的算法
<span style="white-space:pre"><span style="font-size:10px;">		<span style="font-family: Arial; line-height: 26px;">这是一种比较简单的磁盘调度算法。它</span><span style="font-family: Arial; line-height: 26px; color: rgb(255, 0, 0);">根据进程请求访问磁盘的先后次序进行调度</span><span style="font-family: Arial; line-height: 26px;">。此算法的优点是公平、简单,且每个进程的请求都<span style="white-space:pre">			</span>能依次<span style="white-space:pre">					</span>得到处理,不</span><span style="font-family: Arial; line-height: 26px; color: rgb(255, 0, 0);">会出现某一进程的请求长期得不到满足的情况</span><span style="font-family: Arial; line-height: 26px;">。此算法由于未对寻道进行优化,在对磁盘的访问请求比较<span style="white-space: pre;">			</span>多的情况下,此算法将降<span style="white-space:pre">				</span>设备服务的吞吐量,致使平均寻道时间可能较长,但各进程得到服务的响应时间的变化幅度较小。</span></span></span>
<span style="white-space:pre">	</span>扫面顺序是:86 147 91 177 94 150 102 175 130
<span style="white-space:pre">	</span>需要的穿过的路径值:61+56++86+83+56+48+73+45  
<span style="white-space:pre">	</span>SSTF:最短寻道时间:每次都寻找最快可以到达的

<p align="left" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; font-family: Arial; line-height: 26px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="font-size:10px;"><span style="white-space:pre">		</span>该算法选择这样的进程,其要求访问的磁道与当前磁头所在的磁道距离最近,以使<span style="color: rgb(255, 0, 0);">每次的寻道时间最短,该算法可以得到比较好的吞吐量,但却不能保证平均寻道时间<span style="white-space:pre">		</span>最短。</span>其缺点是对用户的服务请求的响应机会不是均等的,因而导致响应时间的变化幅度很大。在服务请求很多的情况下,对内外边缘磁道的请求将会无限期的被延迟<span style="white-space:pre">		</span>,有些请求的响应时间将不可预期。</span></p><p align="left" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; font-family: Arial; line-height: 26px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="font-size:10px;"><span style="color: rgb(199, 21, 133);"><span style="white-space:pre">		</span>最短寻道时间优先(125)</span><span style="color: rgb(199, 21, 133);">130.147.150.175.177.102.94.91.86</span></span></p>
<span style="white-space:pre">	</span>SCAN:扫描算法:每次都是从一端沿着其移动方向到另外的一端的最后一个为止然后在反方向再执行一次。这样来回转动的
<span style="white-space:pre">	</span><p align="left" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; font-family: Arial; line-height: 26px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="font-size:10px;">扫描算法不仅考虑到欲访问的磁道与当前磁道的距离,更<span style="color: rgb(255, 0, 0);">优先考虑的是磁头的当前移动方向</span>。例如,当磁头正在自里向外移动时,扫描算法所选择的下一个访问对象应是其欲访问的磁道既在当前磁道之外,又是距离最近的。这样自里向外地访问,直到再无更外的磁道需要访问才将磁臂换向,自外向里移动。这时,同样也是每次选择这样的进程来调度,即其要访问的磁道,在当前磁道之内,从而避免了饥饿现象的出现。由于这种算法中磁头移动的规律颇似电梯的运行,故又称<span style="color: rgb(255, 0, 0);">为电梯调度算法</span>。此算法基本上克服了最短寻道时间优先算法的服务集中于中间磁道和响应时间变化比较大的缺点,而具有最短寻道时间优先算法的优点即吞吐量较大,平均响应时间较小,但由于是摆动式的扫描方法,两侧磁道被访问的频率仍低于中间磁道。</span></p><p align="left" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; font-family: Arial; line-height: 26px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="font-size:10px;"><span style="color: rgb(199, 21, 133);">电梯调度(125)</span><span style="color: rgb(199, 21, 133);">102.94.91.86.130.147.150.175.177</span></span></p>
<span style="white-space:pre">	</span>CSCAN:循环扫面算法:从一端扫描到另外的一端然后直接移动到原始的位置再来扫描一次
<span style="white-space:pre">	</span><p align="left" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; font-family: Arial; line-height: 26px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="font-size:10px;">循环扫描算法是对扫描算法的改进。如果对磁道的访问请求是均匀分布的,当磁头到达磁盘的一端,<span style="color: rgb(255, 0, 0);">并反向运动时落在磁头之后的访问请求相对较少</span>。这是由于这些磁道刚被处理,而磁盘另一端的请求密度相当高,且这些访问请求等待的时间较长,为了解决这种情况,循环扫描算法规定磁头单向移动。例如,只自里向外移动,当磁头移到最外的被访问磁道时,磁头立即返回到最里的欲访磁道,即将最小磁道号紧接着最大磁道号构成循环,进行扫描。</span></p><p align="left" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; font-family: Arial; line-height: 26px; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="font-size:10px;"><span style="color: rgb(199, 21, 133);">循环扫描 (125)</span><span style="color: rgb(199, 21, 133);">130.147.150.175.177.86.91.94.102</span></span></p>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值