Displaying a linked list as an array?
조회 수: 1 (최근 30일)
이전 댓글 표시
How would I display a linked list as an array of the values of every node in the list, in the order of which the list traverses? Ok, so let's say I have list structure with list.root as the index of the first node in the list. Each node has a value and a next pointer, indicating the index of the next node in the list. How would I show every value within the list structure as a single array of values?
댓글 수: 1
Jan
2013년 3월 4일
There is a nearly infinite number of methods you could implement a linked list in Matlab. So how could we know the structure of your data? Please add any details by editing the question - not as answer or comment.
채택된 답변
Walter Roberson
2013년 3월 6일
Start an array with []. Start at list.root . Repeat {If the current list point is not the end of list, add list.value to the end of the array, and make list.next the current list point.}
댓글 수: 3
Walter Roberson
2013년 3월 8일
end-of-list marker rather than the last node, because you need to include the information from the last node.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!