摘要:Question:Write an O(n)-time nonrecursive procedure that, given an n-node binary tree, prints out the key of each node in the tree. Use a stack as an auxiliary data structure. Answer:This isn't a d...
阅读全文
摘要:Question:Let X[1 .. n] and Y [1 .. n] be two arrays, each containing n numbers already in sorted order. Give an O(lg n)-time algorithm to find the median of all 2n elements in arrays X and Y.Answer:Wi...
阅读全文
摘要:I came across a question regarding c++, is it more efficient to use memcmp to determine equality of two objects of the same type.This is not a question regarding efficiency at all, it's about correctn...
阅读全文
摘要:While doing android programming, it's a common sense to use Activity to interact with users and use Service to perform time consuming tasks (actually, such tasks are usually performed on a new thread ...
阅读全文
摘要:There are times when I deployed an application on a box different from the developing box, the application failed to start with following message:"This application has failed to start because the appl...
阅读全文
摘要:Question: Suppose that you want to output 0 with probability 1/2 and 1 with probability 1/2. At your disposal is a procedure BIASED-RANDOM, that outputs either 0 or 1. It outputs 1 with some probabili...
阅读全文
摘要:In android sdk document, it's mentioned that all components(Activity, Service, etc) run on the main thread. The main thread is the thread where our code works on.Conventionally, when talk about a Serv...
阅读全文
摘要:A friend asked my idea about the exercise 5.1-2 of introduction to algorithms. Here is the original question:Question:Describe an implementation of the procedure RANDOM(a, b) that only makes calls to ...
阅读全文