理解节点和链表概念的问题

理解节点和链表概念的问题

本文介绍了理解节点和链表概念的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的数据结构和Algorithim,我有一些麻烦围绕着链表的整个主题以及如何连接到节点。令我困惑的问题是指针和他们指向的内容



这是教科书的一个示例问题

 (i)当将对象obj添加到空的链表中时,指针头会发生什么变化? 
head1 = new listNode(obj,head);
(ii)写一个构造函数来表示(i)

溢出是获得一些帮助的地方,我需要一些即时的帮助,所有的想法将深受赞赏。感谢提前

解决方案

在java 引用中,作为指向内存中的对象的指针,内部可以指向另一个对象



我们试着明白

在下面的快照 head 是指向内存中第一个对象的引用,第一个对象包含指向第二个对象的另一个引用 next on ...







提示:(如上图所示)


  1. 创建一个新节点

  2. 新节点的下一个
  3. 到新节点


i am new to Data Structures and Algorithim and i am having some troubles getting around the whole topic of linked list and how its connected to nodes. The problem that is confusing me is with pointers and what they point to

This is a sample question off a textbook

(i) "What happens to the pointer head when the object obj is added to an empty linked list?"
 head1 = new listNode(obj, head);
(ii) Write A Constructor to represent (i)

I've seen that stack overflow is the place to get some help, and i need some immediate help, all thoughts will be deeply appreciated. Thanks in Advance

解决方案

In java reference works as pointer to an object in memory that internally can point to another one in the same way.

Let's try to understand it visually:

In below snapshot head is a reference that point to first object in the memory and first object contains another reference next that points to second object and so on...

I think that you can do it as your homework.

Hint: (As shown in above snapshot as well)

  1. create a new node
  2. point next of new node to next of head
  3. point head to new node

这篇关于理解节点和链表概念的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 18:40