2.5 Given a circular linked list, implement an algorithm which returns node at the beginning of the loop. DEFINITION Circular linked list: A (corrupt) linked list in which a node’s next pointer p            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                            精选
                                                        
                            2014-11-24 08:37:36
                            
                                433阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            See 1.2 Write code to reverse a C-Style String. (C-String means that “abcd” is represented as five characters, including the null character.)I am not familiar with "C-Style String". Where is            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-11-23 03:20:46
                            
                                399阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            1.3 Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer. NOTE: One or two additional variables are fine. An extra copy of the arr            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-11-23 03:34:05
                            
                                319阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            1.5 Write a method to replace all spaces in a string with ‘%20’.string.replace(" ", "%20"); ??
// Manipulating chars.
String replaceSpaces(String s)
{
 &n            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-11-23 03:59:00
                            
                                330阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            1.8 Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isS            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-11-23 04:59:21
                            
                                281阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            2.3 Implement an algorithm to delete a node in the middle of a single linked list, given only access to that node. EXAMPLE Input: the node ‘c’ from the linked list a->b->c->d->e Resul            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                            精选
                                                        
                            2014-11-24 07:26:14
                            
                                363阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            3.5 Implement a MyQueue class which implements a queue using two stacks.interface Queue<T>
{
  enqueue(T t);
  T dequeue();
}
class MyQueue<T>            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                            精选
                                                        
                            2014-11-27 05:34:47
                            
                                418阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            3.6 Write a program to sort a stack in ascending order. You should not make any assumptions about how the stack is implemented. The following are the only functions that should be used to write t            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                            精选
                                                        
                            2014-11-27 05:43:16
                            
                                435阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            4.5 Write an algorithm to find the ‘next’ node (i.e., in-order successor) of a given node in a binary search tree where each node has a link to its parent.// BST.
class Node
{
 &n            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                            精选
                                                        
                            2014-11-27 06:51:59
                            
                                372阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            8.5 Implement an algorithm to print all valid (e.g., properly opened and closed) combinations of n-pairs of parentheses. EXAMPLE: input: 3 (e.g., 3 pairs of parentheses) output: ()()(), ()(()), (            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-12-02 10:14:18
                            
                                351阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            9.4 If you have a 2 GB file with one string per line, which sorting algorithm would you use to sort the file and why?What are the common sorting algorithms?http://en.wikipedia.org/wiki/Sorting_al            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-12-05 09:43:05
                            
                                375阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            9.5 Given a sorted array of strings which is interspersed with empty strings, write a method to find the location of a given string. Example: find “ball” in [“at”, “”, “”, “”, “ball”, “”, “”, “ca            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-12-05 09:51:34
                            
                                370阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            // See http://www.hawstein.com/posts/19.1.html
// 19.1 Write a function to swap a number in place without temporary variables            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-12-10 13:14:30
                            
                                281阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            19.5 The Game of Master Mind is played as follows:The computer has four slots containing balls that are red , yellow (Y), green (G) or blue (B). For example, the computer might have RGGB (e.g., S            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-12-10 14:12:10
                            
                                330阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            19.8 Design a method to find the frequency of occurrences of any given word in a book.How big the book is?
split words into different smaller files:
            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-12-10 14:27:54
                            
                                394阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            19.10 Write a method to generate a random number between 1 and 7, given a method that generates a random number between 1 and 5 (i.e., implement rand7() using rand5()). // Like a&n            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-12-10 14:30:38
                            
                                360阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            19.11 Design an algorithm to find all pairs of integers within an array which sum to a specified value.
// Assume a is not null.
//
// a is not sorted            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-12-11 03:04:33
                            
                                351阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            20.3 Write a method to randomly generate a set of m integers from an array of size n. Each element must have equal probability of being chosen.// Similar to 20.2
// This             
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-12-11 03:57:36
                            
                                263阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            20.4 Write a method to count the number of 2s between 0 and n.// What this mean?
// Given a n.
// for (int i = 0 -> n)
//             
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-12-11 09:24:57
                            
                                321阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            20.9 Numbers are randomly generated and passed to a method. Write a program to find and maintain the median value as new values are generated.class MedianNum
{
  // O(n)
&nbs            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2014-12-12 16:17:58
                            
                                383阅读