sundeepblue

Computer Graphics, CAGD, Demoscene, intro [crack each line of code, cram each bit of byte, create each idea of mind]

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2007年10月7日

摘要: Manipulating Strings -------------------------------------------------------------- size_t strlen(char *str) --------------------------------------------------------------- 阅读全文
posted @ 2007-10-07 03:31 sundeepblue 阅读(461) 评论(0) 推荐(0) 编辑

摘要: A Tree Manipulation Library Whenever you implement a new data type, it is usually a good idea to provide functions for manipulating it. There is a general concept in computer science referred to as the black box principle. It is the idea that the user of a data type should not need to be aware of how it is implemented because a library of functions is provided to interact with. This library separates the user from the implementation. This is a good idea because it allows you the progra 阅读全文
posted @ 2007-10-07 02:07 sundeepblue 阅读(282) 评论(0) 推荐(0) 编辑

摘要: What is Recursion? http://www.sparknotes.com/cs/recursion/whatisrecursion/section1.html An Introductory Example Imagine the following scenario. You're a talented programmer at Robot Works, Inc. One day, a valuable customer of yours, Gene Roddenberry (of Star Trek fame), comes to you with a problem. He is creating a new TV show called "Star Trek: The Next Generation" and one of his characters in the show, Data, is an android. At the last minute, the actor who was supposed 阅读全文
posted @ 2007-10-07 01:47 sundeepblue 阅读(474) 评论(0) 推荐(0) 编辑

摘要: Iteration Vs. Recursion If a recursive method is called with a base case, the method returns a result. If a method is called with a more complex problem, the method divides the problem into two or more conceptual pieces: a piece that the method knows how to do and a slightly smaller version of the original problem. Because this new problem looks like the original problem, the method launches a recursive call to work on the smaller problem. For recursion to terminate, each time the 阅读全文
posted @ 2007-10-07 01:43 sundeepblue 阅读(636) 评论(0) 推荐(0) 编辑

摘要: Recursion, as a construct, is quite beautiful. It offers an elegant means of acheiving an algorithmic goal and is used in everything from mathematics to text processing and data structure manipulation. The problem is, using it in practice through today’s popular languages (such as my favorite, C#) can prove to be a disaster. At a minimum, standard recursion proves to be inefficient. Worst case scenario, it’ll consume all of your available memory. So how can you reap the benefits of recursive ele 阅读全文
posted @ 2007-10-07 01:29 sundeepblue 阅读(636) 评论(0) 推荐(0) 编辑

摘要: A recursive power function 1#include 2 3double power(double x, int n); 4 5int main() { 6 double x = 0.0; 7 int n = 0; 8 for(x = 2.0 ; x 9 for(n = 0 ; n10 printf("%.2lf raised to the power %d = %.2lf\n", x, n, power(x,n)); 11} 12 13/**//* Function to raise x to the power n.*/ 14double power(double x, int n) { 15 if(n == 0) 16 return 1.0; 17 else 18 return 阅读全文
posted @ 2007-10-07 00:59 sundeepblue 阅读(897) 评论(0) 推荐(0) 编辑