所以我正在学习C语言中的数据结构,而二元搜索树给我带来了困难,我已经运行gdb来查看seg故障在哪一行以及它在第77行(在代码中标记)。我似乎并不明白为什么会发生这种情况,这是我的代码并提前感谢:
@Bean
public ResourceHttpRequestHandler resourceHttpRequestHandler() {
ResourceHttpRequestHandler requestHandler = new CustomResourceHandler();
requestHandler.setLocations(Arrays.<Resource>asList(applicationContext.getResource("/")));
return requestHandler;
}
@Bean
public SimpleUrlHandlerMapping sampleServletMapping(){
SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
mapping.setOrder(Integer.MAX_VALUE - 2);
Properties urlProperties = new Properties();
urlProperties.put("/**", "resourceHttpRequestHandler");
mapping.setMappings(urlProperties);
return mapping;
}
@Autowired
ApplicationContext applicationContext;
答案 0 :(得分:0)
您正在获取分段错误,因为您没有分配root 主
中树根的地址
node* root=0;
for(int i=1;i<15;i++){
random = rand();
root=insert(root, random);//assigning root the starting address of root of tree
printf("%d\n", random);
}