计算机网络知识点汇总

摘要: 在实习笔试面试过程中, 发现计算机网络中很多知识生疏了, 记录在这:1.随着IP网络的发展,为了节省可分配的注册IP地址,有一些地址被拿出来用于私有IP地址,以下不属于私有IP地址范围的是___:A.10.6.207.84 B.172.23.30.28 C.172.32.50.80 D.192.168.1.100解析: 阅读全文
posted @ 2013-04-04 10:00 jiyiyouxin 阅读(199) 评论(0) 推荐(0)

用c写算法4[二叉数的构造以及遍历]

摘要: 题目:给出二叉树的先序序列,构造对应的二叉链表,并写出遍历二叉数的代码解答:#include <stdio.h>#include <stdlib.h>#include <string.h>/*Tree.c: implements the datastructure of string in P127*/#define TRUE 1#define FALSE 0#define OK 1#define ERROR 0#define INFEASIBLE -1#define OVERFLOW -2typedef int Status;typedef int TEl 阅读全文
posted @ 2013-03-28 09:39 jiyiyouxin 阅读(256) 评论(0) 推荐(0)

用c写算法3[合并两个排序的链表]

摘要: 题目:将两个已经排序的单向链表合并为一个链表解答:// 归并版本ListNode * mergeList1(ListNode* pHead1, ListNode* pHead2) { if (pHead1 == NULL) return pHead2; else if (pHead2 == NULL) return pHead1; ListNode* pMergeHead = NULL; if (pHead1->m_nValue < pHead2->m_nValue) { pMergeHead = pHead1; ... 阅读全文
posted @ 2013-03-28 08:06 jiyiyouxin 阅读(241) 评论(0) 推荐(0)

[转]单向链表的反转

摘要: 之前写过一篇博客 用c写算法[逆置链表]上面写了循环逆转链表的解法, 当时没有给出递归版本的代码,今天看到一篇关于链表逆转的比较完整的解法:题目:输入一个链表的头节点,反转这个链表,并返回反转后链表的头节点,链表定义如下:structListNode{intm_nKey; struct ListNode* m_pNext;};解答:算法一:我们需要额外的两个变量来存储当前节点pCurrent的上一个节点pPrev和下一个节点pNext。假设经过若干次操作,我们将当前节点pCurrent之前的指针都反转完成,这些节点的m_pNext指针都指向前面的一个节点。现在我们遍历到pCurrent,... 阅读全文
posted @ 2013-03-27 17:09 jiyiyouxin 阅读(211) 评论(0) 推荐(0)

用python写算法1[用两个栈实现一个队列]

摘要: 最近在看算法相关的知识, 顺便复习下python, 就用python来写算法吧, 开始!题目1: 用两个栈实现一个队列, 分别在队列尾部插入节点和在队列头部删除节点解答:#!/usr/bin/python# use two stacks to implement a queueclass MyQueue(object): """docstring for MyQueue""" def __init__(self, arg): super(MyQueue, self).__init__() self.arg = arg self.sta 阅读全文
posted @ 2013-03-27 16:38 jiyiyouxin 阅读(438) 评论(0) 推荐(0)

用python写算法2[快速排序]

摘要: python版本的快速排序, 经典算法, 话不多说, 代码搞起:#!/usr/bin/pythonimport randomclass QuickSort(): def Partition(self, A, p, r): x = A[r] i = p - 1 for j in range(p, r): if A[j] <= x: i = i + 1 A[i], A[j] = A[j], A[i] A[i+1], A[r] = A[r], A[i+1] ... 阅读全文
posted @ 2013-03-27 16:35 jiyiyouxin 阅读(160) 评论(0) 推荐(0)

用python写算法4[Fibnocci数列的两种实现]

摘要: 题目: 实现递归和非递归实现Fibonacci数列解答:#!/usr/bin/pythondef Fibonacci(n): a = [0, 1] if n < 2: return a[n] fibNMinusOne = 1 fibNMinusTwo = 0 for n in range(2,n+1): fibN = fibNMinusTwo + fibNMinusOne fibNMinusTwo = fibNMinusOne fibNMinusOne = fibN return fibN def Fib... 阅读全文
posted @ 2013-03-27 16:25 jiyiyouxin 阅读(352) 评论(1) 推荐(0)

用python写算法5[二进制中1的个数]

摘要: 题目:输入一个整数,求该整数的二进制表达中有多少个1。例如输入10,由于其二进制表示为1010,有两个1,因此输出2解法:#!/usr/bin/pythondef NumberOf1(n): count = 0 while n: if n & 1: count += 1 n = n >> 1 return countdef NunberOf1A(n): count = 0 while n: count += 1 n = (n-1) & n return count# differe... 阅读全文
posted @ 2013-03-27 16:24 jiyiyouxin 阅读(280) 评论(0) 推荐(0)

用python写算法6[全排列]

摘要: 题目:给定一组数,给出这组数所有的排列算法:#!/usr/bin/python#coding=gbk'''Created on 2013-03-24@author: songjian'''def quanpailie(test_arr, sub_arr): if len(test_arr) == 1: sub_arr.append(test_arr[0]) print sub_arr sub_arr.pop() else: length = len(test_arr) for i in range(0, leng... 阅读全文
posted @ 2013-03-27 16:23 jiyiyouxin 阅读(246) 评论(0) 推荐(0)

用python写算法3[旋转链表]

摘要: 题目:把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。输入一个排好序的数组的一个旋转,输出旋转数组的最小元素。例如数组{3, 4, 5, 1, 2}为{1, 2, 3, 4, 5}的一个旋转,该数组的最小值为1。解答:#!/usr/bin/python#coding=gbk'''Created on 2013-03-25@author: songjian'''def get_min(test_arr): low_index = 0 high_index = len(test_arr) - 1 mid_index = low_in 阅读全文
posted @ 2013-03-27 16:22 jiyiyouxin 阅读(202) 评论(0) 推荐(0)