我试图在二叉树(不是二叉搜索树)中跟踪节点的路径.给定一个节点,我试图从根打印路径的值.

我写了以下程序.
package dsa.tree;
import java.util.Stack;
public class TracePath {
private Node n1;
public static void main(String args[]){
TracePath nodeFinder = new TracePath();
nodeFinder.find();
}
public void find(){
Tree t = getSampleTree();
tracePath(t,n1);
}
private Tree getSampleTree() {
Tree bsTree = new BinarySearchTree();
int randomData[] = {43,887,11,3,8,33,6,0,46,32,78,76,334,45};
for(int i=0;i<randomData.length;i++){
bsTree.add(randomData[i]);
}
n1 = bsTree.search(76);
return bsTree;
}
public void tracePath(Tree t, Node node){
trace(t,node);
}
Stack<Node> mainStack = new Stack<Node>();
public void trace(Tree t, Node node){
trace(t.getRoot(),node);
}
private void …Run Code Online (Sandbox Code Playgroud) 我正在使用SSIS从excel到OLEDB SQL进行数据转换.我在一个文件夹中有一组工作表,我必须循环,并将每个工作表中的数据插入到表中.我有一个场景,我必须通过一组具有不同列结构的Excel工作表循环.我可以通过foreach循环枚举器循环遍历每个工作表找到文件名并将它们传递给Excel源.
我想知道是否有办法在目标组件中转义这个列映射,在我的情况下它将是一个OLEDB SQL表.因为这些映射对于每个文件都不同.有没有办法动态地这样做?
我在rails中的一个测试文件中看到以下行.它有一个名为as的方法any_instance.有什么用?有人可以解释一下
http = Net::HTTP.new(Person.site.host, Person.site.port)
ActiveResource::Connection.any_instance.expects(:http).returns(http)
http.expects(:request).returns(ActiveResource::Response.new(""))
Run Code Online (Sandbox Code Playgroud)
谢谢
我来自很长的Java背景,对C#来说很新.我试图从Windows手机运行一个入门套件应用程序,我收到此错误.
A first chance exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.WindowsPhone.dll
Run Code Online (Sandbox Code Playgroud)
我发现很难调试这个,因为我直接引用了References指向Newtonsoft.Json.WindowsPhone的dll文件.在Java中,我会搜索库并下载源以在调试期间进入确切的位置.
如果可能,我将如何在C#中执行此操作(如何在运行时引用我的项目的库源代码)?我使用Visual Studio 2010 Express Edition作为IDE.
我想对我的主动管理启用的rails应用程序进行一些分析.对于这一点,我需要粘贴一些<script>与<noscript>刚刚之前的代码</body>在我的布局文件的标签.不幸的是,我无法做到这一点,因为application.html布局文件似乎无效,因为ActiveAdmin呈现了自己的布局文件.
是否有一个钩子/地方,我可以插入自定义的HTML代码?
我的按钮中有.jpg图像.我还想在图像上放置一些文字.我使用以下语法:
JButton btn = new JButton(label,icon);
Run Code Online (Sandbox Code Playgroud)
但我没有看到按钮中的文字(只有图像).我究竟做错了什么?
不知道这是否重复,但这是一个问我的面试问题.给定一个随机数组和-1放在其间,我必须压缩数组意味着要替换所有-1s,最终输出应该是最后一个有新数组的有效索引.例如.
Input:
3 4 -1 -1 -1 5 8 -1 8
Output:
3 4 5 8 8 5 8 -1 8 and last valid index is 4
Input:
-1 -1 -1 -1 -1 2
Output:
2 -1 -1 -1 -1 2 and last valid index is 0
Input:
-1 -1 -1 3 3 3
Output:
3 3 3 3 3 3 and last valid index is 2
Run Code Online (Sandbox Code Playgroud)
您不应该交换值只是最后一个有效索引以及数组足以解密非-1值.
我在ActiveRecord中使用一个简单的查询,它做了类似的事情.
MyTable.find(:all, :conditions => {:start_date => format_time(params[:date]) })
Run Code Online (Sandbox Code Playgroud)
我想获得在后台执行的等效查询,可能使用puts语句或类似的语句.MySQL是我的数据库.
我需要您查看我的单一链接列表(SLL)的实现.实现应该使用泛型并且能够使用增强的for.
问题是,当我for (Number n : list)是list一个MyLinkedList<Integer>或者MyLinkedList<Double>,我得到的错误:"类型不匹配:不能从元素类型的对象转换为数字".
这就是我所拥有的.我不太确定的部分是泛型和迭代器.
提前致谢.
import java.util.Iterator;
public class MyLinkedList<T> implements Iterable<Object>
{
private Node head;
public MyLinkedList ()
{
head = null;
}
public void add (Node n)
{
if (head == null)
{
head = n;
}
else
{
Node node = head;
while (node.next != null)
{
node = node.next;
}
node = n;
}
}
public Iterator iterator()
{
return new MyLinkedListIterator (head);
}
public …Run Code Online (Sandbox Code Playgroud) 我试图在Linux(Ubuntu)中用C编译一组源文件.当我尝试运行以下命令时,我收到一个错误,告诉"ruby.h"找不到.
gcc custom_ext.c
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误消息.
custom_ext.h:10: fatal error: ruby.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
所以我下载了整个Ruby源代码并将其放在虚拟目录中/home/braga/ruby_source/ruby_1_8_7.我知道我需要在路径中包含这个目录,以便GCC能够识别并获取ruby.h,但我不知道如何做到这一点.请帮忙!!!