- 介绍一下项目(自己实验室课题,机器视觉方面的,这个面试官并不在意)
- 浏览器中输入一个URL,网页加载的过程和使用到的协议
- http和https的区别,以及加密过程
- 追问:在https握手过程中,服务器给客户端发送证书,如何确定发送哪一个证书?
答:客户端在发送的时候会发送自己的SSL的版本吗 - 第二个追问没听明白。。。。
- 追问:在https握手过程中,服务器给客户端发送证书,如何确定发送哪一个证书?
- 上一个问题用到了IP协议,那么IP常用的路由协议有哪些?
答:没答上来
追问:那你觉得应该如何设计路由协议?
答:由于路由器之间形成的结构是图,将路由器自己的状态广播出去,最后形成一个图。。。大脑当时一片空白,想到啥回答啥。
找到哈工大课程的ppt如下:
- TCP如何保证可靠性?
答:三次握手,确认重传,滑动串口,拥塞控制(好像不是,面试官说还有么,我就说了这个),面试官提示还有校验码。 - 拥塞控制说一下?
追问:现在linux中的传输还是用这种方式么?答:不了解。
追问:还有其他的拥塞拥塞控制算法么?答:不了解
追问:那你觉得判断网络拥塞的指标是什么?答:超过RTT时间没有收到确认
追问:到了默认时间是如何处理?答:丢包重传
面试官:回去可以看一看具体的算法 - 操作系统?答不是很熟,面试官换成了数据库
- Mysql的常用存储引擎?
- Inoodb和Myisam的区别
10.为了达到可重复读这个隔离级别,Innodb做了哪些?答的快照读 - 快照读底层是如何实现的?MVCC实现的
手撕算法:给一个链表,奇数位上升,偶数位下降,将链表排序成升序链表。例如1->6->2->4->3->2,排序后1->2->2->3->4->6 (当时没想出思路)
import java.util.List;
public class Test0421 {
public static void main(String[] args) {
int[] input = new int[]{1,6,2,4,3,2};
ListNode dummy = new ListNode(0);
ListNode cur = dummy;
for (Integer i : input) {
cur.next = new ListNode(i);
cur = cur.next;
}
// cur = dummy.next;
// while (cur != null) {
// System.out.println(cur.val);
// cur = cur.next;
// }
ListNode slow = dummy.next;
ListNode fast = dummy.next.next;
ListNode dummy1 = new ListNode(0);
ListNode dummy2 = new ListNode(0);
dummy1.next = slow;
dummy2.next = fast;
while (slow.next != null && fast.next != null) {
slow.next = slow.next.next;
fast.next = fast.next.next;
slow = slow.next;
fast = fast.next;
}
slow.next = null;
fast.next = null;
// while (dummy1 != null) {
// System.out.print(dummy1.val);
// dummy1 = dummy1.next;
// }
// System.out.println();
// while (dummy2 != null) {
// System.out.print(dummy2.val);
// dummy2 = dummy2.next;
// }
ListNode newFastHead = reverseList(dummy2.next);
// while (newFastHead != null) {
// System.out.print(newFastHead.val);
// newFastHead = newFastHead.next;
// }
ListNode newNode = merge(dummy1, newFastHead);
while (newNode != null) {
System.out.println(newNode.val);
newNode = newNode.next;
}
}
public static ListNode reverseList(ListNode head) {
ListNode pre = null;
ListNode cur = head;
while (cur != null) {
ListNode temp = cur.next;
cur.next = pre;
pre = cur;
cur = temp;
}
return pre;
}
public static ListNode merge(ListNode head1, ListNode head2) {
ListNode dummy1 = new ListNode(0);
ListNode dummy2 = new ListNode(0);
dummy1.next = head1;
dummy2.next = head2;
ListNode dummy = new ListNode(0);
ListNode cur = dummy;
while (head1 != null && head2 != null) {
if (head1.val <= head2.val) {
cur.next = head1;
head1 = head1.next;
} else {
cur.next = head2;
head2 = head2.next;
}
cur = cur.next;
}
if (head1 == null) {
cur.next = head2;
}
if (head2 == null) {
cur.next = head1;
}
return dummy.next;
}
}
class ListNode {
int val;
ListNode next;
ListNode(){};
ListNode(int val) {
this.val = val;
}
}
手撕算法: k个一组反转链表
public ListNode reverseKGroup(ListNode head, int k) {
ListNode hair = new ListNode();
hair.next = head;
ListNode pre = hair;
while (head != null) {
ListNode tail = pre;
for (int i = 0; i < k; i++) {
tail = tail.next;
if (tail == null) return hair.next;
}
ListNode temp = tail.next;
ListNode[] listnode = reverseKLinkedList(head, tail);
head = listnode[0];
tail = listnode[1];
/**
连接子串
*/
pre.next = head;
tail.next = temp;
/**
要继续执行的推进步骤
*/
pre = tail;
head = tail.next;
}
return hair.next;
}
ListNode[] reverseKLinkedList(ListNode head, ListNode tail) {
ListNode pre = tail.next;
ListNode p =head;
while (pre != tail) {
ListNode temp = p.next;
p.next = pre;
pre = p;
p =temp;
}
return new ListNode[]{tail, head};
}