Solution for exercise 1.2-3 in Introduction to Algorithms
2006-03-21 15:14
471 查看
Consider the problem of determining whether an arbitrary sequence (x1, x2, . . . , xn) of n numbers contains repeated occurrences of some number. Show that this can be done in θ(n lg n) time, where lg n stands for log2n.
Solution 1: Any sorting algorithms having log2n complexity will be a capable to solve it in θ(n lg n) time.
Solution 2: If the domain of the sequence is not big, this problem can be solved in θ(n) time using the counting method, compute count[Xi] in the first loop, then find if there is any count[Xi] bigger than 1.
Solution 1: Any sorting algorithms having log2n complexity will be a capable to solve it in θ(n lg n) time.
Solution 2: If the domain of the sequence is not big, this problem can be solved in θ(n) time using the counting method, compute count[Xi] in the first loop, then find if there is any count[Xi] bigger than 1.
相关文章推荐
- Solution for exercise 1.2-1 in Introduction to Algorithms
- Solution for exercise 1.1-4 in Introduction to Algorithms
- Solution for exercise 1.3-5 in Introduction to Algorithms
- Solution for exercise 1.3-7 in Introduction to Algorithms
- Solution for Introduction to Algorithms (3rd Edition) Exercise 26.4-2
- Quick Introduction to Boosting Algorithms in Machine Learning
- Solution:Unable to install CSD for WebSphere® MQ v5.3. Files in use!
- Business Modules And Interfaces In The SCSF Smart Client Solution (Introduction To CAB/SCSF Part 19)
- Solution of Introduction to Algorithms
- An Introduction to Genetic Algorithms In Java @ JDJ
- Introduction to Algorithms:exercise2.1_4
- malloc: *** error for object 0x6080000bd200: Invalid pointer dequeued from free list *** set a breakpoint in malloc_error_break to debug
- Network Programming For Microsoft Windows Notes:Introduction to Winsock
- Introduction_to_Algorithms_chap4
- End-to-End Workload Monitor in SAP Solution Manager
- [MITOPENCOURSEWARE] 6.094 Introduction to Programming in MATLAB
- How to enable the Xdebug debugger in Zend Studio for Eclips
- 【CS231n_2017】1-Introduction to CNN for Visual Recognition
- how to config the tftpd-hpa server in the ubuntu using for remote tftp client '-p' and '-r' command
- MSDN文档翻译 Learn to Program for Windows in C++ 001 前言