This is the exercises from LAD module 2 (from the book: data structures & algorithms in JAVA - Michael T. Goodrich & Roberto Tamassia):
C-3.6
Describe a fast recursive algorithm or reversing a singly linked list L, so that the nodes becomes opposite of what it was before.
C-3.7
Describe a godd algorithm for concatenating two singly linked list L and M, with header sentinels, into a single linked list L' that contains all the nodes of L followed by all the nodes of M.
C-3.8
Give a fast algorithm for concatenating two singly linked lists L and M, with a header and trailer sentinel nodes, into a singly list L'
C-3.9
Describe in detail how to swap two nodes x and y (and not just their contents) in a singly linked list L given references only to X and Y.Repeat this exercise for the case when L is a doubly linked list. Which algorithm takes more time?
R-3.7
Describe a method for inserting an element at the beginning of a singly linked list. Assume that the list does not have a sentinel header node, and instead uses a variable head to reference the first node in the list.
Jan 28, 2008
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment