
Algorithm
文章平均质量分 91
yexianyi
Software Architect @ Siemens
Email: yexianyi@hotmail.com
Linkedin: http://cn.linkedin.com/in/yexianyi/
Github: https://github.com/yexianyi/
展开
-
Algorithm: The implementation of Trie Tree (C++)
Question:There is a text file which includes many lines. And each line has only one word or phrase. Now, please implement a program to get the prefix of each word. (Please print each of prefix word原创 2010-05-10 12:26:00 · 7441 阅读 · 0 评论 -
String Matching: The Simple way to implement String Matching
public static int match(String source, String pattern) { char[] sourceArray = source.toCharArray() ; char[] patternArray = pattern.toCharArray() ; int source_length = source原创 2012-05-10 14:49:23 · 1123 阅读 · 0 评论 -
Algorithm: Climb Stairs
Qestion:If you are only able to climb some stairs with 1,2 or 3 steps in each time, how many possibilities you have when you climb 10 stairs? Please display all the possibilities.Codes:package com.test; public class ClimbStairs { static int count =原创 2010-11-17 23:32:00 · 1169 阅读 · 0 评论 -
Algorithm: String Full Permutation
Suppose that we are going to display Permutation for ‘A’,’B’,’C’,’D’. So there should be have 4!=24 combinations. Following is one algorithm to calculate these combinations. 1. Doing exchange the first character with each of rest characters. We can get原创 2010-10-03 22:40:00 · 1338 阅读 · 1 评论 -
Algorithm: Detailded CyclicShift Solution One of Programming Pearls (2nd)
This artical will show you the detailed implementation of Cyclic Shift which is mentioned in Programming Pearls (2nd). In that book on Page 11, Column2.1, Question B, Rotate a one-dimensional vector of n elements left by i positions. For instance, with n=原创 2010-10-04 12:04:00 · 966 阅读 · 0 评论 -
Algorithm: 算法题摘录
算法题摘录 1.链表和数组的区别在哪里? ANSWER 主要在基本概念上的理解。但是最好能考虑的全面一点,现在公司招人的竞争可能就在细节上产生,谁比较仔细,谁获胜的机会就大。 1)数组在内存中是逐个存放的,也就是说倘若数组的第一个元素在地址A,则数组第二个元素就在地址A+1。而链表则不是,链表每个节点没有相对固定的位置关系。某个节点在地址A其后的节点不一定是A+1,而在内存的其他空闲区域,呈现一种随机的状态。 2)数组一旦显式的被申明后,其大小就固定了,不能动态进行扩充。而链表则可以,可以动态生成原创 2010-08-07 20:09:00 · 692 阅读 · 1 评论 -
Algorithm: Reverse a Integer to an array with recursion
Question: Please reverse a Integer to an array with recursion. For example, there is a integer is 1234567890. After reverse, the integer should change to be 0987654321 . Code: // ConvertInteger.cpp : Defines the entry point for the console application.原创 2010-08-07 11:34:00 · 680 阅读 · 0 评论 -
Algorithm: Make all the odd numbers precede all the even numbers in an array.
Question: Code a program that make all the odd numbers precede all the even numbers in an array.原创 2010-08-01 18:58:00 · 758 阅读 · 0 评论 -
Algorithm: Program ABCDE*4 = EDCBA
Question : Please develop a program to figure out the value of ABCDE which meet the condidition ABCDE*4=EDCBA. (A,B,C,D and E won’t be reduplicative.) Solution1: #include using namespace std ; int main(int argc, char* argv[]) { for(int原创 2010-06-02 14:48:00 · 1027 阅读 · 0 评论 -
Common Bit Tasks
1) If you XOR a bit with its own negated value, you will always get 1. Therefore the solution to a ^ (~a) will be the sequence of 1s. consider a is of data-type byte. example: a = 00000001 ~a =转载 2013-09-18 13:23:44 · 1035 阅读 · 0 评论