Insert into a Cyclic Sorted List
来源:互联网 发布:爱编程 编辑:程序博客网 时间:2024/05/28 22:09
Question:
Given a node from a cyclic linked list which has been sorted, write a function to insert a value into the list such that it remains a cyclic sorted list. The given node can be any single node in the list.
public static void insertCyclicList(Node head, int data) {Node node = new Node(data);if (head == null) {node.next = node;}Node current = head;Node prev = null;do {prev = current;current = current.next;if (data <= current.val && data >= prev.val) break;if (prev.val > current.val && (prev.val < data || current.val > data)) break;} while (head != current);prev.next = node;node.next = current;}
http://blog.csdn.net/beiyetengqing
- Insert into a Cyclic Sorted List
- Insert into a Cyclic Sorted List
- Insert into a Cyclic Sorted List
- Insert into a Cyclic Sorted List
- Insert into a Cyclic Sorted List
- 【Hackerrank】Insert a node into a sorted doubly linked list
- Insert in a sorted list
- Insert into a sorted circular linked list 环状链表 插入节点
- Python pandas insert list into a cell
- demo for insert values into sorted single list
- Insert Data into Sorted Table
- Insert Data into Sorted Table
- Insert a node in a sorted linked list.
- P21 (*) Insert an element at a given position into a list.
- P20 (*) P21 (*)Remove the Kth element from a list;Insert an element at a given position into a list.
- jquery insert a table into div
- 代码面试题:Insert Sorted Linked List
- Sorted insert for circular linked list
- Cocos2d官方入门指导
- 申请注册码免费激活visual studio 2010 express的方法(以vc++为例)
- Core Data
- 画图是对一块内存填充数据
- model实体类中hibernate注解
- Insert into a Cyclic Sorted List
- [数组公式] 浅谈引用、数组、内存数组
- Android开发之旅:环境搭建及HelloWorld
- 怎么修改MTU值
- wtl notes
- MFC编程 小说分割器
- [数组公式] 创建第一个自己的数组公式
- POJ 1125 Floyd
- Android执行shell命令