-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75715e9
commit 2dc3434
Showing
16 changed files
with
401 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!---title:复习找工作之排序算法--> | ||
<!---keywaords:找工作--> | ||
<!---date:2015-04-03--> | ||
|
||
前几天为了阿里的笔试,特意在项目之余抽出时间猛补数据结构和算法,本科本不是计算机专业出身的,自学数据结构。昨晚阿里笔试那个被虐的啊。。。。更惨的不是被虐,而是一不小心在笔试后修改职位,居然把笔试记录还给弄丢了(我一直觉得这是阿里招聘系统中好不人性化的一个Bug),和我阿里梦擦肩而过,找阿里客服还一个劲的安慰我,说“出现这种事实在很抱歉,加油加油”,真是忧郁莫过那晚了。。。。。。但庆幸自己的乐观,今天还是集中复习的排序算法整理了一下,主要是插入排序、堆排序和快速排序,也算为了加深理解吧,都手写的分析和代码, | ||
|
||
## 先看插入排序 | ||
|
||
 | ||
|
||
## 堆排序 | ||
|
||
 | ||
 | ||
|
||
## 快速排序 | ||
|
||
 | ||
 | ||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<!---title:找了几道研究生复试面试题--> | ||
<!---keywords:程序设计--> | ||
<!---date:2015-03-25--> | ||
|
||
当时应导师任务,出几道题给研究生复试面试用,“不能太难”,于是乎琢磨,从C/C++、数据结构、计算机组成原理、计算机网络中各选数题。最后发现也没怎么用上,但觉得也算基础,贴在这里吧。 | ||
|
||
### 链表和数组的特点,什么时候使用链表,什么时候使用数组? | ||
|
||
- 数组数据连续存储,链表数据存储可不连续 | ||
- 数组访问元素只需要O(1)时间,链表则需要O(N) | ||
- 主要执行插入删除操作时使用链表,为快速检索时使用数组 | ||
|
||
### 二维数组与指针的关系? | ||
|
||
二维数组是一维指针,不是二维指针。 | ||
|
||
### 在32位的机器上,sizeof(指针)=? | ||
|
||
4字节 | ||
|
||
### C++中struct与class的区别 | ||
|
||
struct默认成员都是public,而class默认都为private | ||
|
||
### static作用于局部变量和.c文件中的函数前有什么区别? | ||
|
||
- static作用于局部变量表示将数据存储到全局数据区,但依然具有局部变量的属性 | ||
- static作用于.c文件中的函数表示该函数只能在该文件中访问,是相对于extern而言 | ||
|
||
### new与malloc的区别 | ||
|
||
1. new是C++关键字(操作符),属于编译器的范畴;malloc是C语言中的函数,clib的范畴 | ||
2. new创建的是一个对象,包含构造函数的初始化过程;malloc仅仅是分配一块内存,需要手动初始化 | ||
|
||
### 定义`void *p;`,指针p指向的是什么类型? | ||
|
||
void *表示指针可指向任意类型(任意类型的指针都能直接给p赋值),在C语言函数传参中很有用 | ||
|
||
### 冯诺依曼结构 | ||
|
||
1. 计算机处理的数据和指令一律用二进制数表示 | ||
2. 存储程序概念,把要执行的程序和处理的数据首先存入主存储器(内存),计算机执行程序时,将自动地并按顺序从主存储器中取出指令一条一条地执行,这一概念称作顺序执行程序 | ||
|
||
### 死锁 | ||
|
||
是指两个或两个以上的进程在执行过程中,因争夺资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下去。 | ||
|
||
### 快速排序的平均时间复杂度?快速排序是否总是比一般的排序快? | ||
|
||
O(NlogN)。数据已经排好序,在选择参考标准的时候总是选择最后一个数据作为参考标准,此时快排效率最低,O(N^2)。 | ||
|
||
### 进程与线程区别。操作系统设计中为什么要在进程的基础上提出线程的概念? | ||
|
||
区别: | ||
|
||
1. 线程是进程的一个实体,一个进程可以拥有多个线程,多个线程也可以并发执行。一个没有线程的进程也可以看做是单线程的,同样线程也经常被看做是一种轻量级的进程。并且进程可以不依赖于线程而单独存在,而线程则不然。 | ||
2. 线程没有独立的存储空间,它共享进程的资源,而进程有独立的用户空间 | ||
|
||
线程引入: | ||
|
||
1. 因为进行的创建要分配存储空间,要花费较大的系统开销和占用较多的资源 | ||
2. 进程涉及的上下文切换耗费时间(连带存储资源的切换) | ||
|
||
线程就是为了提高CPU的执行效率,避免硬件资源浪费而提出的 | ||
|
||
### 进程调度的方法 | ||
|
||
- 优先级轮转:又分抢占式(实时)和非抢占式 | ||
- 时间片轮转 | ||
|
||
### 因特网协议栈包括哪些层?UDP协议属于哪层的协议? | ||
|
||
1. 应用层 | ||
2. 传输层 | ||
3. 网络层 | ||
4. 数据链路层 | ||
5. 物理层 | ||
|
||
UDP是传输层协议。 | ||
|
||
### CSMA/CD | ||
|
||
Carrier Sense Multiple Access with Collision Detection。 | ||
|
||
有人将CSMA/CD的工作过程形象的比喻成很多人在一间黑屋子中举行讨论会,参加会议的人都是只能听到其他人的声音。每个人在说话前必须先倾听,只有等会场安静下来后,他才能够发言。人们将发言前监听以确定是否已有人在发言的动作称为"载波监听";将在会场安静的情况下每人都有平等机会讲话成为“多路访问”;如果有两人或两人以上同时说话,大家就无法听清其中任何一人的发言,这种情况称为发生“冲突”。发言人在发言过程中要及时发现是否发生冲突,这个动作称为“冲突检测”。如果发言人发现冲突已经发生,这时他需要停止讲话,然后随机后退延迟,再次重复上述过程,直至讲话成功。如果失败次数太多,他也许就放弃这次发言的想法。通常尝试16次后放弃。 | ||
|
||
### 中断的作用 | ||
|
||
1. 响应用户事件(如键盘、鼠标等) | ||
2. 响应实时性要求的紧急任务 | ||
|
||
### 栈和队列的区别 | ||
|
||
- 栈:后入先出 | ||
- 队列:先入先出 | ||
|
||
### 怎么从尾到头打印单向链表,不改变链表结构?(可给提示:“请提供某种可用的数据结构”) | ||
|
||
使用栈或递归可以方便地从尾到头打印链表,从头扫描入栈,扫描完成后全部出栈。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<meta http-equiv="Content-Style-Type" content="text/css" /> | ||
<meta name="generator" content="pandoc" /> | ||
<title></title> | ||
<style type="text/css">code{white-space: pre;}</style> | ||
<link rel="stylesheet" href="../stylesheets/Github.css" type="text/css" /> | ||
<title>复习找工作之排序算法</title> | ||
</head> | ||
<body> | ||
<div id="header"><center> | ||
<p class="header_titleline"> | ||
<a href="../index.html" target="_self" title="主页">主页 </a><a href="../Search.html" target="_self" title="站内搜索">站内搜索 </a><a href="../Projects.html" target="_self" title="项目研究">项目研究 </a><a href="../Archives.html" target="_self" title="文章存档">文章存档 </a><a href="../README.html" target="_self" title="分类目录">分类目录 </a><a href="../AboutMe.html" target="_self" title="关于我">关于我 </a> | ||
</p> | ||
</center></div> | ||
<h1>复习找工作之排序算法</h1> | ||
<h4>2015-04-03 / xiahouzuoxin</h4> | ||
转载请注明出处: <a href="http://xiahouzuoxin.github.io/notes/">http://xiahouzuoxin.github.io/notes/</a> | ||
<div id="TOC"> | ||
<ul> | ||
<li><a href="#先看插入排序">先看插入排序</a></li> | ||
<li><a href="#堆排序">堆排序</a></li> | ||
<li><a href="#快速排序">快速排序</a></li> | ||
</ul> | ||
</div> | ||
<!---title:复习找工作之排序算法--> | ||
<!---keywaords:找工作--> | ||
<!---date:2015-04-03--> | ||
<p>前几天为了阿里的笔试,特意在项目之余抽出时间猛补数据结构和算法,本科本不是计算机专业出身的,自学数据结构。昨晚阿里笔试那个被虐的啊。。。。更惨的不是被虐,而是一不小心在笔试后修改职位,居然把笔试记录还给弄丢了(我一直觉得这是阿里招聘系统中好不人性化的一个Bug),和我阿里梦擦肩而过,找阿里客服还一个劲的安慰我,说“出现这种事实在很抱歉,加油加油”,真是忧郁莫过那晚了。。。。。。但庆幸自己的乐观,今天还是集中复习的排序算法整理了一下,主要是插入排序、堆排序和快速排序,也算为了加深理解吧,都手写的分析和代码,</p> | ||
<h2 id="先看插入排序">先看插入排序</h2> | ||
<div class="figure"> | ||
<img src="../images/复习找工作之排序算法/插入排序.jpg" /> | ||
</div> | ||
<h2 id="堆排序">堆排序</h2> | ||
<p><img src="../images/复习找工作之排序算法/堆排序.jpg" /> <img src="../images/复习找工作之排序算法/堆排序代码.jpg" /></p> | ||
<h2 id="快速排序">快速排序</h2> | ||
<p><img src="../images/复习找工作之排序算法/快速排序.jpg" /> <img src="../images/复习找工作之排序算法/快速排序分割策略.jpg" /> <img src="../images/复习找工作之排序算法/快速排序代码.jpg" /></p> | ||
<div class="ds-thread" data-thread-key="复习找工作之排序算法" data-title="复习找工作之排序算法" data-url="xiahouzuoxin.github.io/notes/html/复习找工作之排序算法.html"></div> | ||
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"slide":{"type":"slide","bdImg":"5","bdPos":"right","bdTop":"300"},"image":{"viewList":["qzone","tsina","tqq","renren","weixin"],"viewText":"分享到:","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["qzone","tsina","tqq","renren","weixin"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script> | ||
|
||
<!-- 多说公共JS代码 start (一个网页只需插入一次) --> | ||
<script type="text/javascript"> | ||
var duoshuoQuery = {short_name:"xiahouzuoxin"}; | ||
(function() { | ||
var ds = document.createElement('script'); | ||
ds.type = 'text/javascript';ds.async = true; | ||
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js'; | ||
ds.charset = 'UTF-8'; | ||
(document.getElementsByTagName('head')[0] | ||
|| document.getElementsByTagName('body')[0]).appendChild(ds); | ||
})(); | ||
</script> | ||
<!-- 多说公共JS代码 end --> | ||
|
||
<div id="footer"> | ||
<p class="footer_subline">联系邮箱: xiahouzuoxin@163.com</p> | ||
<p class="footer_subline">声明: 本站所有文章如非特别说明均为原创,转载请注明出处! | ||
<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1253219218'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s4.cnzz.com/z_stat.php%3Fid%3D1253219218%26show%3Dpic' type='text/javascript'%3E%3C/script%3E"));</script> | ||
</p> | ||
</div> | ||
|
||
<!-- 回到顶部 --> | ||
<script> | ||
lastScrollY=0; | ||
function heartBeat(){ | ||
var diffY; | ||
if (document.documentElement && document.documentElement.scrollTop) | ||
diffY = document.documentElement.scrollTop; | ||
else if (document.body) | ||
diffY = document.body.scrollTop | ||
else | ||
{/*Netscape stuff*/} | ||
percent=.1*(diffY-lastScrollY); | ||
if(percent>0)percent=Math.ceil(percent); | ||
else percent=Math.floor(percent); | ||
document.getElementById("full").style.top=parseInt(document.getElementById("full").style.top)+percent+"px"; | ||
lastScrollY=lastScrollY+percent; | ||
} | ||
suspendcode="<div id=\"full\" style='right:1px;POSITION:absolute;TOP:600px;z-index:100'><a onclick='window.scrollTo(0,0);'><img src='../images/top.png'></a><br></div>" | ||
document.write(suspendcode); | ||
window.setInterval("heartBeat()",1); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.