小编kri*_*hna的帖子

使用Stack的二叉搜索树的Inorder Tree Traversal算法

我的输入结果24, 4, 2, 3, 9, 10, 32,我得到了以下结果2, 3, 4, 24.

我正在使用堆栈.当我手动检查这个程序时else if,即使有正确的子树,节点也不会在堆栈上的4处进行.

public void inorderNonRcursive(Node root){

    Stack s = new Stack();
    Node node = root;
    Node k;
    int c=0;

    if(node != null) {
        s.push(node);    
    }

    while(!s.stack.isEmpty()) {   

        //node=(Node) s.stack.get(s.stack.size()-1);
        System.out.println("first condition" + (node.getleft() != null && (node.getVisited() == false)) + "second condi" + (node.getRight() != null));

        if(node.getleft() != null && (node.getVisited() == false)) {
            node = node.getleft();
            s.push(node);
            System.out.println("   from 1           "+(++c)); …
Run Code Online (Sandbox Code Playgroud)

java stack inorder binary-search-tree

1
推荐指数
1
解决办法
4775
查看次数

我在托管bean中使用session ejb时得到nullpointer异常

my  sessionfacade class

         package com.entity;

         import javax.ejb.Stateless;
         import javax.persistence.EntityManager;
         import javax.persistence.PersistenceContext;

         @Stateless
         public class UsersFacade extends AbstractFacade<Users> implements UsersFacadeLocal 
         {
         @PersistenceContext(unitName = "My_communityPU")
         private EntityManager em;

         @Override
         protected EntityManager getEntityManager() {
         return em;
         }

         public UsersFacade() {
         super(Users.class);
         }

         }



my managed bean class

        package com.jsf;

        import com.entity.Users;
        import com.entity.UsersFacadeLocal;
        import javax.inject.Named;
        import javax.enterprise.context.SessionScoped;
        import java.io.Serializable;
        import java.util.List;
        import java.util.Map;
        import javax.annotation.ManagedBean;
        import javax.ejb.EJB;
        import javax.faces.context.ExternalContext;
        import javax.faces.context.FacesContext;

        @Named(value = "loginMB")
        @ManagedBean
        @SessionScoped
        public class LoginMB implements Serializable {
        @EJB …
Run Code Online (Sandbox Code Playgroud)

jsf jpa nullpointerexception

0
推荐指数
1
解决办法
1312
查看次数