자료구조 해석좀 부탁드립니다.. (Reversing a node list)
소심한여자
2023.04.01
Give a nonrecursive algorithm for reversing a node list represented with a doubly linked list using a single through the list
Algorithm reverseDLL ( Double Linked List )
Input : A doubly linked List (DLL)Output : reversed All
DoublyLinkedNoed pre = dll.header, cur = pre.next; nxt = cur.next;while( cur != trailer ) {cur.previous = nxt ;cur.next = pre ;pre = cur;cur = nxt ;nxt = nxt . next ;}swap ( dll.header , dll.trailer )
간단한것 같은데 ..nxt 랑 pre 랑 cur이 어떤순서로 움직이는지 모르겠습니다..말로 설명해주시면 이해될거같은데..설명좀 자세히 부탁드립니다 ㅠㅠ!!!