26 questions to answer written algorithm
Advertisements
Note: Some slight changes
Quote
To an integer into an array after reverse (required recursion)
package org.stack_queue;
public class Algorithm {
// Will a integer reverse in an array ( Requires recursive implementation )
public void reverse(StringBuffer result, int num) {
if (num != 0) {
result.append(num % 10);
reverse(result, num / 10);
}
}
public static void main(String[] args) {
StringBuffer result = new StringBuffer();
new Algorithm().reverse(result, 1024);
System.out.println(result);
}
}
Quote
] Recursive palindrome judgments (such as: abcdedbca is palindromic, the interviewer to judge a simple understanding of the recursive procedure)
package org.stack_queue;
public class Algorithm {
/**
* Recursive implementation Palindrome judgment ( If :abcdedbca It is a Palindrome, interviewer on recursive understand the simple program )
*
* @param str
* To determine whether the string
* @param begin
* 0
* @param end
* The length of a string
* @return
*/
public static boolean isPalindrome(char[] str, int begin, int end) {
if (end <= 1)
return true;
if (str[begin] == str[end]) {
return isPalindrome(str, begin + 1, end - 1);
} else
return false;
}
public static void main(String[] args) {
char[] str = new String("abcdedbca").toCharArray();
System.out.println(Algorithm.isPalindrome(str, 0, str.length - 1));
char[] str2 = new String("acbca").toCharArray();
System.out.println(Algorithm.isPalindrome(str2, 0, str2.length - 1));
}
}
Related Posts of 26 questions to answer written algorithm
-
Javascript Object Model
Javascript Object Model
-
Hibernate II Study Notes
11. Many-to-many Of many that can be converted to two one-to-many <set name="students" table="teacher_student"> <key column="techer_id"/> <many-to-many column="student_id"/> </set> many-to-many data only from one end of the mainten
-
A common JavaScript page
1.JavaScript code 2.CSS code 3. The use of examples
-
hibernate (jpa) composite primary key annotation statement Ways
In the design of the database tables are designed with a composite primary key of the table, that table's record by more than one field joint identification, such as: Table CREATE TABLE TB_HOUR_DATA ( STAT_DATE DATE NOT NULL, PATH_ID NUMBER(20) NOT NULL,
-
log4j easy application in java
JAVA development, frequently used the log output, in a so-called most of the software company will have its own set of configuration style, re-read the configuration file to initialize property of the log, it will be good, but sometimes may not need to fu
-
jboss ejb3 Message Driven Bean
Super Medium ejb hate. . . . . . . . . . . . . . . . . . . ================================================ To configure a Message Driven Bean in a different application server parameters are not the same. Currently only passed the test jboss. Message Dri
-
Oracle instant clent for ruby / rails on cygwin
Environment: XP: oracle full client, ruby, rails, gem cygwin: ruby rails, gem (the version with the XP version) Needs: for cygwin is installed under the rails platform support oci Steps: <1> download oracle instant client (10.2.0.3 Instant Client Pa
-
hibernate generic generic DAO
package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *
-
First Hibernate Example
Curd a simple example. Source does not contain the dependent libraries, or playing too much of the package. PO object Note: One must have the default constructor 2 non-final modified. Otherwise useless lazy loading. UserDAOImpl category code, and other co
-
Great collection of java interview topics
1, object-oriented features of what has 1. Abstract: Abstract is that it has overlooked a subject has nothing to do with the current goal of those aspects in order to more fully with the current objectives of the attention-related aspects. Abstract does n












