2/7/14, 40min

理解进程与线程的本质及操作
本文深入探讨了进程与线程的概念区别,详细解释了它们如何共享内存空间及同步工作原理。同时,介绍了局部变量的存储位置、函数调用时的操作流程,并通过实例展示了二叉搜索树的迭代遍历方法。此外,还对比了TCP与UDP、RIP与OSPF这两种网络协议的特性及优势。最后,阐述了ARP协议的作用和ping命令的工作机制。

OS:

1: The difference between process and thread? Can multiple threads/processes share memory? 

Ans: 1) A process is an executing instance of an application. A thread is a pathofexecutionwithin a process. Also, a process can contain multiple threads.

2) Threads (of the same process) run in a shared memory space, while processes run in separate memory spaces. This allows threads to read from and write to the same data structures and variables, and also facilitates communication between threads.

3)  A thread can do anything a process can do. But threads are used for small tasks, whereas processes are used for more ‘heavyweight’ tasks – basically the execution of applications.

How does synchronization between threads work?


2: Where are local variables stored in memory? Ans: Stack

3: What happens in OS when one function calling another function?


Data structure:

1: Remove an item in a linked list. Time Complexity.

2: What is a BST? Traverse a BST iteratively. Time Complexity to remove a node from a BST.

BST properties:

  • The left subtree of a node contains only nodes with keys less than the node's key.
  • The right subtree of a node contains only nodes with keys greater than the node's key.
  • The left and right subtree each must also be a binary search tree.
  • There must be no duplicate nodes.

Traverse a BST iteratively. O(n)

  • 1) Create an empty stack S.
  • 2) Initialize current node as root
  • 3) Push the current node to S and set current = current->left until current is NULL
  • 4) If current is NULL and stack is not empty then 
  •  a) Pop the top item from stack. 
  •  b) Print the popped item, set current = current->right 
  •  c) Go to step 3.
  • 5) If current is NULL and stack is empty then we are done.

/**
 * Definition for binary tree
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector<int> inorderTraversal(TreeNode *root) {
        stack<TreeNode*> s;
        vector<int> res;
        if (!root) return res;
        TreeNode *cur=root;
        while (cur || s.size()) {
            while (cur) {
                s.push(cur);
                cur = cur->left;
            }
            cur = s.top();
            s.pop();
            res.push_back(cur->val);
            cur=cur->right;
        }
        return res;
    }
};

3: Difference between stack and queue. Which data structure can be used to build stack? How to build? Time Complexity to push or pop.


Networking:

1: Difference between TCP and UDP.

2: Difference between RIP and OSPF. Advantages of them.

RIP (Routing Information Protocol) is a Distance vector routing protocol based onBellman-Ford algorithm. Each router on the network complies a list ofnetworks it can reach and exchange with its neighboring routers only. Upon receiving vectors form each of its neighbors, the router computes its own distance to each neighbor. Then for every network X, router finds that neighbor who is closer to X than to any other neighbor.Router updates its cost to X. After doing this for all networks, the router goes to the first step.

OSPF (Open Shortest Path First) is a link state routing protocol based on Dijkstra algorithm. Each router on the network is assumed to know the state of links to all its neighbors, and each router will broadcast this information about its link state to all routers in the network. Therefor, each router has enough information to build a complete map of the network andi able to construct a shortest path spanning tree form itself to every other node.

OSPF advantages:

It provides the shortest path and its loop-free.

It has the ability to scale up or down the number of IP packets that are sent at a time or within a time frame, so that it's more scalable and can be used in large network.

The main reason behind the OSPF protocol being faster is that whenever changes are made in the routing tables, only the new or updated values are transferred, instead of sending the entire code.

3: What ARP used for?

Determine the MAC address of its IP address. ARP is at the link layer.


4: How dose ping work?

The ping command is a method for troubleshooting the accessibility of devices to determine whether a remote host is active or inactive, the round-trip delay in communicating with the host, and the packet loss. It sends one datagram per second and prints one line of output for every response received. It calculates round-trip times and packet loss statistics, and displays a brief summary on completion. It completes when the program times out or on receipt of a SIGINT signal. The Host parameter is either a valid host name or Internet address.

The protocol used for ping is ICMP (Internet Control Message Protocol) at the network layer. To ping a host you first send an ICMP Echo Request Packet, the host will then reply with an ICMP Echo Reply. ICMP messages are typically used for diagnostic or control purposes or generated in response to errors in IP operations.

Plus, the traceroute (by using UDP) command can be used to discover the routers along the path that packets are taking to a destination.


就记得这么多了,总的来讲印度哥哥还是蛮nice哒~

时间(min) 降雨强度(mm/min) 降雨总量(mm) 2025/6/1 12:00 0.2112 0.2112 2025/6/1 12:01 0.2132 0.4244 2025/6/1 12:02 0.2153 0.6397 2025/6/1 12:03 0.2175 0.8572 2025/6/1 12:04 0.2197 1.0769 2025/6/1 12:05 0.222 1.2989 2025/6/1 12:06 0.2244 1.5233 2025/6/1 12:07 0.2268 1.75 2025/6/1 12:08 0.2292 1.9793 2025/6/1 12:09 0.2318 2.211 2025/6/1 12:10 0.2344 2.4454 2025/6/1 12:11 0.2371 2.6825 2025/6/1 12:12 0.2398 2.9223 2025/6/1 12:13 0.2427 3.165 2025/6/1 12:14 0.2456 3.4106 2025/6/1 12:15 0.2486 3.6592 2025/6/1 12:16 0.2517 3.911 2025/6/1 12:17 0.255 4.1659 2025/6/1 12:18 0.2583 4.4242 2025/6/1 12:19 0.2617 4.6859 2025/6/1 12:20 0.2653 4.9512 2025/6/1 12:21 0.2689 5.2201 2025/6/1 12:22 0.2727 5.4928 2025/6/1 12:23 0.2767 5.7695 2025/6/1 12:24 0.2807 6.0502 2025/6/1 12:25 0.285 6.3352 2025/6/1 12:26 0.2893 6.6245 2025/6/1 12:27 0.2939 6.9184 2025/6/1 12:28 0.2987 7.2171 2025/6/1 12:29 0.3036 7.5207 2025/6/1 12:30 0.3087 7.8294 2025/6/1 12:31 0.3141 8.1435 2025/6/1 12:32 0.3197 8.4632 2025/6/1 12:33 0.3256 8.7888 2025/6/1 12:34 0.3317 9.1205 2025/6/1 12:35 0.3381 9.4586 2025/6/1 12:36 0.3449 9.8035 2025/6/1 12:37 0.3519 10.1554 2025/6/1 12:38 0.3594 10.5148 2025/6/1 12:39 0.3672 10.8821 2025/6/1 12:40 0.3755 11.2576 2025/6/1 12:41 0.3843 11.6419 2025/6/1 12:42 0.3936 12.0355 2025/6/1 12:43 0.4034 12.4389 2025/6/1 12:44 0.4139 12.8527 2025/6/1 12:45 0.425 13.2778 2025/6/1 12:46 0.4369 13.7147 2025/6/1 12:47 0.4497 14.1644 2025/6/1 12:48 0.4634 14.6279 2025/6/1 12:49 0.4782 15.106 2025/6/1 12:50 0.4941 15.6002 2025/6/1 12:51 0.5114 16.1116 2025/6/1 12:52 0.5303 16.6419 2025/6/1 12:53 0.5509 17.1928 2025/6/1 12:54 0.5735 17.7662 2025/6/1 12:55 0.5984 18.3647 2025/6/1 12:56 0.6261 18.9908 2025/6/1 12:57 0.657 19.6478 2025/6/1 12:58 0.6918 20.3396 2025/6/1 12:59 0.7312 21.0708 2025/6/1 13:00 0.7763 21.8471 2025/6/1 13:01 0.8284 22.6755 2025/6/1 13:02 0.8892 23.5647 2025/6/1 13:03 0.9614 24.5261 2025/6/1 13:04 1.0483 25.5743 2025/6/1 13:05 1.155 26.7293 2025/6/1 13:06 1.2891 28.0184 2025/6/1 13:07 1.4628 29.4813 2025/6/1 13:08 1.6963 31.1775 2025/6/1 13:09 2.0256 33.2031 2025/6/1 13:10 2.5224 35.7255 2025/6/1 13:11 3.3476 39.0731 2025/6/1 13:12 4.9435 44.0166 2025/6/1 13:13 3.7551 47.7717 2025/6/1 13:14 3.0187 50.7903 2025/6/1 13:15 2.5224 53.3127 2025/6/1 13:16 2.1674 55.4801 2025/6/1 13:17 1.9018 57.3819 2025/6/1 13:18 1.6963 59.0782 2025/6/1 13:19 1.5327 60.6108 2025/6/1 13:20 1.3995 62.0104 2025/6/1 13:21 1.2891 63.2995 2025/6/1 13:22 1.1962 64.4957 2025/6/1 13:23 1.1168 65.6124 2025/6/1 13:24 1.0483 66.6607 2025/6/1 13:25 0.9885 67.6492 2025/6/1 13:26 0.9359 68.5851 2025/6/1 13:27 0.8892 69.4743 2025/6/1 13:28 0.8476 70.3219 2025/6/1 13:29 0.8101 71.132 2025/6/1 13:30 0.7763 71.9083 2025/6/1 13:31 0.7456 72.6538 2025/6/1 13:32 0.7175 73.3713 2025/6/1 13:33 0.6918 74.0631 2025/6/1 13:34 0.6682 74.7313 2025/6/1 13:35 0.6463 75.3776 2025/6/1 13:36 0.6261 76.0037 2025/6/1 13:37 0.6073 76.6111 2025/6/1 13:38 0.5898 77.2009 2025/6/1 13:39 0.5735 77.7743 2025/6/1 13:40 0.5582 78.3325 2025/6/1 13:41 0.5438 78.8763 2025/6/1 13:42 0.5303 79.4066 2025/6/1 13:43 0.5175 79.9241 2025/6/1 13:44 0.5055 80.4296 2025/6/1 13:45 0.4941 80.9238 2025/6/1 13:46 0.4834 81.4071 2025/6/1 13:47 0.4731 81.8803 2025/6/1 13:48 0.4634 82.3437 2025/6/1 13:49 0.4542 82.7979 2025/6/1 13:50 0.4454 83.2432 2025/6/1 13:51 0.4369 83.6802 2025/6/1 13:52 0.4289 84.1091 2025/6/1 13:53 0.4212 84.5303 2025/6/1 13:54 0.4139 84.9442 2025/6/1 13:55 0.4068 85.351 2025/6/1 13:56 0.4001 85.7511 2025/6/1 13:57 0.3936 86.1446 2025/6/1 13:58 0.3873 86.532 2025/6/1 13:59 0.3813 86.9133 2025/6/1 14:00 0.3755 87.2888 2025/6/1 14:01 0.37 87.6588 2025/6/1 14:02 0.3646 88.0233 2025/6/1 14:03 0.3594 88.3827 2025/6/1 14:04 0.3544 88.7371 2025/6/1 14:05 0.3495 89.0867 2025/6/1 14:06 0.3449 89.4315 2025/6/1 14:07 0.3403 89.7719 2025/6/1 14:08 0.3359 90.1078 2025/6/1 14:09 0.3317 90.4395 2025/6/1 14:10 0.3276 90.7671 2025/6/1 14:11 0.3236 91.0907 2025/6/1 14:12 0.3197 91.4104 2025/6/1 14:13 0.3159 91.7264 2025/6/1 14:14 0.3123 92.0386 2025/6/1 14:15 0.3087 92.3474 2025/6/1 14:16 0.3053 92.6527 2025/6/1 14:17 0.3019 92.9546 2025/6/1 14:18 0.2987 93.2532 2025/6/1 14:19 0.2955 93.5487 2025/6/1 14:20 0.2924 93.8411 2025/6/1 14:21 0.2893 94.1304 2025/6/1 14:22 0.2864 94.4168 2025/6/1 14:23 0.2835 94.7004 2025/6/1 14:24 0.2807 94.9811 2025/6/1 14:25 0.278 95.2591 2025/6/1 14:26 0.2753 95.5344 2025/6/1 14:27 0.2727 95.8071 2025/6/1 14:28 0.2702 96.0773 2025/6/1 14:29 0.2677 96.345 2025/6/1 14:30 0.2653 96.6102 2025/6/1 14:31 0.2629 96.8731 2025/6/1 14:32 0.2606 97.1337 2025/6/1 14:33 0.2583 97.392 2025/6/1 14:34 0.2561 97.648 2025/6/1 14:35 0.2539 97.9019 2025/6/1 14:36 0.2517 98.1536 2025/6/1 14:37 0.2497 98.4033 2025/6/1 14:38 0.2476 98.6509 2025/6/1 14:39 0.2456 98.8965 2025/6/1 14:40 0.2436 99.1402 2025/6/1 14:41 0.2417 99.3819 2025/6/1 14:42 0.2398 99.6217 2025/6/1 14:43 0.238 99.8597 2025/6/1 14:44 0.2362 100.0959 2025/6/1 14:45 0.2344 100.3302 2025/6/1 14:46 0.2326 100.5629 2025/6/1 14:47 0.2309 100.7938 2025/6/1 14:48 0.2292 101.023 2025/6/1 14:49 0.2276 101.2506 2025/6/1 14:50 0.2259 101.4765 2025/6/1 14:51 0.2244 101.7009 2025/6/1 14:52 0.2228 101.9237 2025/6/1 14:53 0.2212 102.1449 2025/6/1 14:54 0.2197 102.3646 2025/6/1 14:55 0.2182 102.5829 2025/6/1 14:56 0.2168 102.7997 2025/6/1 14:57 0.2153 103.015 2025/6/1 14:58 0.2139 103.2289 2025/6/1 14:59 0.2125 103.4414 2025/6/1 15:00 0.2112 103.6526 这是一个降雨数据,你能帮我转换成dfs0的文件吗。
06-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值