Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

用二叉查找树统计逆序数

Posted by wgc6523872 at 2009-04-01 12:48:44 on Problem 1007
1、先将数据输入到一个数组中
2、从数组末尾将数输出构造二叉查找数,每个节点存储2个数据 一个是数据值一个是比其小的数的个数 N,在构造过程中,遇到比其其大的节点,大节点的N值+1,遇到比其小的节点,其N 值 += 小节点的N值,当该节点找到位置时,总逆序数NIXU += N。   整棵树构造完成时,NIXU就是逆序数,  时间: N(LOGN)

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator