1052. Linked List Sorting
来源:互联网 发布:apache artemis 编辑:程序博客网 时间:2024/05/19 17:56
A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now given a linked list, you are supposed to sort the structures according to their key values in increasing order.
Input Specification:
Each input file contains one test case. For each case, the first line contains a positive N (< 105) and an address of the head node, where N is the total number of nodes in memory and the address of a node is a 5-digit positive integer. NULL is represented by -1.
Then N lines follow, each describes a node in the format:
Address Key Next
where Address is the address of the node in memory, Key is an integer in [-105, 105], and Next is the address of the next node. It is guaranteed that all the keys are distinct and there is no cycle in the linked list starting from the head node.
Output Specification:
For each test case, the output format is the same as that of the input, where N is the total number of nodes in the list and all the nodes must be sorted order.
Sample Input:5 0000111111 100 -100001 0 2222233333 100000 1111112345 -1 3333322222 1000 12345Sample Output:
12345 -1 00001
00001 0 11111
11111 100 22222
22222 1000 33333
33333 100000 -1
- 1052. Linked List Sorting
- 1052. Linked List Sorting
- 1052. Linked List Sorting
- 1052.Linked List Sorting
- 1052. Linked List Sorting
- 1052. Linked List Sorting
- 1052. Linked List Sorting
- 1052. Linked List Sorting
- 1052. Linked List Sorting
- 1052. Linked List Sorting (25)
- 1052. Linked List Sorting (25)
- 1052. Linked List Sorting (25)
- 1052. Linked List Sorting (25)
- PAT 1052. Linked List Sorting
- 1052. Linked List Sorting (25)
- 1052. Linked List Sorting (25)
- 1052. Linked List Sorting (25)
- 1052. Linked List Sorting (25)
- Linux网络编程之Socket编程
- PHP单双引号的区别
- sql server cmd工具
- 新人报道
- git管理代码时,不显示直接拖进去的工程
- 1052. Linked List Sorting
- Linux find命令用法小结
- 谈谈关于内存对齐与补齐
- 【Linux】线程基本知识概述
- SolrCloud的搭建过程
- 开放才能进步!Angular和Wijmo一起走过的日子
- Mysql-win系统密码破解之方法
- 1054. The Dominant Color
- 数据处理函数