AKB Forums

Go Back   AKB Forums > Technical sections > Algorithms
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Algorithms The source of algorithms for your project

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Aug 27, 2002, 01:25   #1
Moderator
 
Mono's Avatar
 
Join Date: Oct 2001
Location: Yerevan
Posts: 5,390
Blog Entries: 1
Rep Power: 8
Reputation: 93
Post Duplicates

PPL-ner

Uremn ayspisi harc.

Yes unem mi inch vor list. Liste shat metz e. Mot mi 100000-ic minchev 1.000.000 elementner. Uremn uzum em __effektif___ algoritm vore kkaroghana ayd listic hani duplikatnere inchkan hnaravor e arag.

PS. I dep mi hat algoritm ei grel vorov uzeci 32000-anoc string listic duplicatnere hanel ( PERL-ov ) mot 15 rope tevec ed antere
__________________
---------------
Արատտայի ու Խալդեյի հովանավոր .
Mono is offline   Reply With Quote Quote selected
Old Aug 27, 2002, 04:06   #2
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: Jan 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,166
Rep Power: 7
Reputation: 34
Post

пока что такой (c - контейнер, содержащий элементы):
Code:
 
#include <algorithm>
using namespace std;

sort(c.begin(), c.end());
c.erase(unique(c.begin(), c.end()), c.end());
сложность - n * log n + n (т.е. фактически n * log n). но! результирующая последовательность будет отсортирована.
или:
Code:
 
#include <algorithm>
using namespace std;

for(C::iterator it = c.begin(), end = c.end(); it != end; ++it)
{
	end = remove(it + 1, end, *it);
}
c.erase(end, c.end());
сложность - n(n+1)/2, т.е. n^2. зато без сортировки.
сложность erase-а в обоих случаях не учитывалась, но она добавит всего лишь слагаемое n.
Aram Hambardzumyan is offline   Reply With Quote Quote selected
Old Aug 27, 2002, 17:59   #3
Moderator
 
Mono's Avatar
 
Join Date: Oct 2001
Location: Yerevan
Posts: 5,390
Blog Entries: 1
Rep Power: 8
Reputation: 93
Post

Spasibo Aram djan

Ya ispolzoval vtoroy varyant no vidimo problema medlennosti moyevo scripta ne iz za Algoritma a iz za PERL-a ili je iz za kompa
__________________
---------------
Արատտայի ու Խալդեյի հովանավոր .
Mono is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 21:51.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link