weidagang2046的專欄

          物格而后知致
          隨筆 - 8, 文章 - 409, 評論 - 101, 引用 - 0
          數據加載中……

          Partially Revert Linked List

          Partially Revert Linked List

          Problem: partially revert a linked list

          Given a HEAD pointer to a linked list and an OFFSET pointer pointing to a node in the linked list. You are asked to write a C/C++ subroutine to revert the part of the list from HEAD to OFFSET:

           

          You are NOT allowed to use recursion. Please follow the definition of the type and function as shown below:

           

          typedef struct _Node

          ...{

              int value;

              struct _Node* next;

          }Node;

           

          Node* Revert(Node* head, Node* offset)

          ...{

              //Your code here. Return the head of new linked list.

          }

           

          Exchange Nodes

          Problem: Exchange the odd and even nodes in a linked list.

           

          Given a "head" pointer to a linked list. You are asked to write a C/C++ function to exchange the odd and even nodes in the linked list. For example:

          Please follow the type and function definitions below:

           

          typedef struct _Node

          ...{

              int value;

              struct _Node* next;

          }Node;

           

          void ExchangeNodes(Node** phead) //note: phead is of Node** type

          ...{

              //your code here.

          }

          posted on 2005-10-27 21:04 weidagang2046 閱讀(306) 評論(0)  編輯  收藏 所屬分類: Others

          主站蜘蛛池模板: 合川市| 都安| 广东省| 贵阳市| 新津县| 广德县| 望奎县| 济源市| 壤塘县| 盐源县| 普洱| 宁蒗| 平山县| 碌曲县| 东至县| 道真| 贵州省| 青州市| 车致| 水城县| 方正县| 金阳县| 牡丹江市| 鄂伦春自治旗| 泗阳县| 炉霍县| 额尔古纳市| 平安县| 来安县| 天水市| 邹城市| 偏关县| 南安市| 巫溪县| 宁陕县| 察哈| 邮箱| 维西| 同心县| 新宾| 米脂县|