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

          主站蜘蛛池模板: 得荣县| 中西区| 图木舒克市| 牡丹江市| 讷河市| 井陉县| 西畴县| 上犹县| 眉山市| 乐安县| 金堂县| 文安县| 庆安县| 顺昌县| 江山市| 微山县| 得荣县| 宣恩县| 滕州市| 阿巴嘎旗| 松原市| 抚松县| 台东县| 汶川县| 铜陵市| 沂源县| 汉阴县| 冷水江市| 阿拉善盟| 崇州市| 苏尼特左旗| 平南县| 瓦房店市| 沧州市| 肇东市| 得荣县| 大理市| 桓仁| 海淀区| 双城市| 东乌珠穆沁旗|