• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 04:58
CET 10:58
KST 18:58
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
Weekly Cups (Dec 15-21): Classic wins big, MaxPax & Clem take weeklies3ComeBackTV's documentary on Byun's Career !10Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win4Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump1Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2
StarCraft 2
General
What's the best tug of war? The Grack before Christmas Weekly Cups (Dec 15-21): Classic wins big, MaxPax & Clem take weeklies ComeBackTV's documentary on Byun's Career ! Micro Lags When Playing SC2?
Tourneys
$5,000+ WardiTV 2025 Championship $100 Prize Pool - Winter Warp Gate Masters Showdow Sparkling Tuna Cup - Weekly Open Tournament Winter Warp Gate Amateur Showdown #1 RSL Offline Finals Info - Dec 13 and 14!
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 505 Rise From Ashes Mutation # 504 Retribution Mutation # 503 Fowl Play Mutation # 502 Negative Reinforcement
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Recommended FPV games (post-KeSPA) BW General Discussion FlaSh on: Biggest Problem With SnOw's Playstyle soO on: FanTaSy's Potential Return to StarCraft
Tourneys
Small VOD Thread 2.0 [Megathread] Daily Proleagues [BSL21] LB QuarterFinals - Sunday 21:00 CET [BSL21] WB SEMIFINALS - Saturday 21:00 CET
Strategy
Simple Questions, Simple Answers Game Theory for Starcraft Current Meta Fighting Spirit mining rates
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Beyond All Reason Path of Exile General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread The Games Industry And ATVI Russo-Ukrainian War Thread How Does UI/UX Design Influence User Trust? Things Aren’t Peaceful in Palestine
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced Where to ask questions and add stream?
Blogs
The (Hidden) Drug Problem in…
TrAiDoS
I decided to write a webnov…
DjKniteX
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2073 users

The Big Programming Thread - Page 862

Forum Index > General Forum
Post a Reply
Prev 1 860 861 862 863 864 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
phar
Profile Joined August 2011
United States1080 Posts
March 18 2017 09:15 GMT
#17221
On March 18 2017 08:26 WarSame wrote:
Does anyone know where to find longer video footage of autonomous cars in service? I can only find promotional videos so far. I'm looking for an hour+ of straight driving to seoe what it is like. On a related note, where is the state of the tech at right now? Last I checked the consensus was that driving itself had been mostly figured out, but it still had problem with poor weather conditions, such as the Lidar not working. Is this still the case?

Anyone who knows where the cutting edge is at can't actually tell you (due to nda). You just kinda have to guess based on what waymo said last and extrapolate.
Who after all is today speaking about the destruction of the Armenians?
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
March 18 2017 15:48 GMT
#17222
On March 18 2017 18:15 phar wrote:
Show nested quote +
On March 18 2017 08:26 WarSame wrote:
Does anyone know where to find longer video footage of autonomous cars in service? I can only find promotional videos so far. I'm looking for an hour+ of straight driving to seoe what it is like. On a related note, where is the state of the tech at right now? Last I checked the consensus was that driving itself had been mostly figured out, but it still had problem with poor weather conditions, such as the Lidar not working. Is this still the case?

Anyone who knows where the cutting edge is at can't actually tell you (due to nda). You just kinda have to guess based on what waymo said last and extrapolate.

We don't even have access to, say, year old footage? I just wanted to get an idea of it :/
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Hanh
Profile Joined June 2016
146 Posts
March 18 2017 16:02 GMT
#17223
On March 15 2017 22:00 travis wrote:
lol ive spent an hour on it i cant figure it out and i refuse to look at meatpudding's solution

edit: i lie. i looked now. his solution makes sense :/ damn


Here's another solution:

+ Show Spoiler +


p*p - 24n - 1 = 0 is equivalent to

24 | A where A = (p-1)(p+1)

24 = 2 x 3 x 4

p is prime >= 5, so it is odd, which makes p-1 and p+1 even. We have 2x2 | A. Once we divide p-1 and p+1 by 2, we have
2 consecutive numbers. One of them has to be even, that's another factor of 2: 2x4 | A

(p-1), p, (p+1) are 3 consecutive numbers. One of them is a multiple of 3. It can't be p since p is prime. Therefore 3 | A

Since 3 and 8 are coprime, 8 | A and 3 | A implies 8x3 | A.

spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 19 2017 14:55 GMT
#17224
Can someone tell me how to get Github to let me attach a .zip to a release? When I try to attach my ~1MB .zip I get the following:

An attachment with that filename already exists. Try a different file. 
We don’t support that file type. Try zipping it.
Try another file. Yowza, that’s a big file. Try again with a file smaller than 2GB.
This file is empty. Try again with a file that’s not empty.
Something went really wrong, and we can’t process that file. Try another file.

That's 5 error messages. Including one telling me to try zipping my .zip. Also my file apparently is both too large and too small at the same time. Different filename doesn't change anything, and a random tiny .txt produces the same error. And for some reason I can't find a solution via google either.
If you have a good reason to disagree with the above, please tell me. Thank you.
Khalum
Profile Joined September 2010
Austria831 Posts
March 19 2017 15:13 GMT
#17225
Since you're getting all possible errors when doing anything the only logical course of action is obviously not uploading anything! The .zip file should magically appear at some point!
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 19 2017 15:40 GMT
#17226
Ok it worked on Internet Explorer. It didn't work on the latest version of Firefox, without any blocked scripts or anything for Github... I don't get it.
If you have a good reason to disagree with the above, please tell me. Thank you.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
March 19 2017 20:01 GMT
#17227
What are you using to make the zip file? I've never had that issue before using 7-zip or Linux's commandline.
There is no one like you in the universe.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 19 2017 22:05 GMT
#17228
On March 20 2017 05:01 Blisse wrote:
What are you using to make the zip file? I've never had that issue before using 7-zip or Linux's commandline.

Just right click -> send to -> compress in windows explorer. Usually good enough for tiny stuff like that one. The .zip wasn't the problem, anyways... probably. Especially considering a plain .txt wouldn't work either.
If you have a good reason to disagree with the above, please tell me. Thank you.
dsyxelic
Profile Joined May 2010
United States1417 Posts
March 21 2017 06:57 GMT
#17229
question:

should length of string matter when searching for a particular string in a list?

so basically I was asked for an example of an algorithm or method to find a string in a sorted list of strings and to describe time complexity in regards to size of list and length of the string we are searching for.

the example I gave was a binary search tree where the root node would be the index n/2 in the sorted array and then proceed down left or right depending on alphabetical value (ex. left if we're looking for 'hello' and root node is 'igloo').

time complexity O(m log n) where n is size of list and m is length of the string we are searching for.
log n for going down the tree, m for number of characters we could possibly compare to judge which is 'greater' alphabetically at each node.

is my line of thinking correct?

also I'm pretty sure this isn't the efficient way to match a string in a sorted list? but I was just asked for an example of a way so yea lol
TL/SKT
ddengster
Profile Blog Joined January 2009
Singapore129 Posts
Last Edited: 2017-03-21 07:54:21
March 21 2017 07:39 GMT
#17230
On March 21 2017 15:57 dsyxelic wrote:
question:

should length of string matter when searching for a particular string in a list?

so basically I was asked for an example of an algorithm or method to find a string in a sorted list of strings and to describe time complexity in regards to size of list and length of the string we are searching for.

the example I gave was a binary search tree where the root node would be the index n/2 in the sorted array and then proceed down left or right depending on alphabetical value (ex. left if we're looking for 'hello' and root node is 'igloo').

time complexity O(m log n) where n is size of list and m is length of the string we are searching for.
log n for going down the tree, m for number of characters we could possibly compare to judge which is 'greater' alphabetically at each node.

is my line of thinking correct?

also I'm pretty sure this isn't the efficient way to match a string in a sorted list? but I was just asked for an example of a way so yea lol


Usually, in tests big O questions simplify their keys before putting them into the data structure of choice, like collapsing strings to integers before inserting them to data structures. If you get such a question, your teachers must be pretty sadistic . Focusing on how to apply general algorithms is what's more important, and in the practical(real) world, big O notation will matter less and less as you optimize more for the cpu cache.

But to answer your question, it depends on the algorithm. If you precalculate sizes, it's O(log n). If your string searching uses something like strcmp, then you could argue for something else.
Edit: I'd still argue for O(log n) in the strcmp case.
Check out NEO Impossible Bosses, RTS-MOBA boss rush at http://neoimpossiblebosses.coder-ddeng.com
dsyxelic
Profile Joined May 2010
United States1417 Posts
Last Edited: 2017-03-21 08:52:34
March 21 2017 08:18 GMT
#17231
On March 21 2017 16:39 ddengster wrote:
Show nested quote +
On March 21 2017 15:57 dsyxelic wrote:
question:

should length of string matter when searching for a particular string in a list?

so basically I was asked for an example of an algorithm or method to find a string in a sorted list of strings and to describe time complexity in regards to size of list and length of the string we are searching for.

the example I gave was a binary search tree where the root node would be the index n/2 in the sorted array and then proceed down left or right depending on alphabetical value (ex. left if we're looking for 'hello' and root node is 'igloo').

time complexity O(m log n) where n is size of list and m is length of the string we are searching for.
log n for going down the tree, m for number of characters we could possibly compare to judge which is 'greater' alphabetically at each node.

is my line of thinking correct?

also I'm pretty sure this isn't the efficient way to match a string in a sorted list? but I was just asked for an example of a way so yea lol


Usually, in tests big O questions simplify their keys before putting them into the data structure of choice, like collapsing strings to integers before inserting them to data structures. If you get such a question, your teachers must be pretty sadistic . Focusing on how to apply general algorithms is what's more important, and in the practical(real) world, big O notation will matter less and less as you optimize more for the cpu cache.

But to answer your question, it depends on the algorithm. If you precalculate sizes, it's O(log n). If your string searching uses something like strcmp, then you could argue for something else.
Edit: I'd still argue for O(log n) in the strcmp case.


hm.. i didn't really get much details besides that we were to give time complexity in terms of length of say string s (string we search for) and n (size of list). So I understood that as wanting us to determine whether string length will matter in time complexity. I decided yes because I didn't get any details for how the strings would be compared and since they asked us about length I probably assume the answer is looking for us to include character comparison
TL/SKT
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2017-03-21 11:24:13
March 21 2017 11:23 GMT
#17232
--- Nuked ---
dsyxelic
Profile Joined May 2010
United States1417 Posts
Last Edited: 2017-03-21 20:01:12
March 21 2017 19:58 GMT
#17233
On March 21 2017 20:23 Nesserev wrote:
@dsyxelic

If you're looking for an example where the length of the string is the main factor of complexity, you should look into tries, which are great to store strings. (https://en.wikipedia.org/wiki/Trie)

Insert, delete and search are all O(m), where m is the length of the string.


tries do seem like a better example. next time I'd probably go with that one. I assume list length does not matter in complexity when using tries since we're just going down the tree until all characters are matched.

is my line of thinking with using a BST and its complexity in terms of string length and list length correct though?
TL/SKT
meadbert
Profile Blog Joined October 2010
United States681 Posts
March 21 2017 21:21 GMT
#17234
On March 21 2017 15:57 dsyxelic wrote:
question:

should length of string matter when searching for a particular string in a list?

so basically I was asked for an example of an algorithm or method to find a string in a sorted list of strings and to describe time complexity in regards to size of list and length of the string we are searching for.

the example I gave was a binary search tree where the root node would be the index n/2 in the sorted array and then proceed down left or right depending on alphabetical value (ex. left if we're looking for 'hello' and root node is 'igloo').

time complexity O(m log n) where n is size of list and m is length of the string we are searching for.
log n for going down the tree, m for number of characters we could possibly compare to judge which is 'greater' alphabetically at each node.

is my line of thinking correct?

also I'm pretty sure this isn't the efficient way to match a string in a sorted list? but I was just asked for an example of a way so yea lol

The length of the string you are searching for is irrelevant for Big O notation.
Basically the vast majority of string compares will results in discovering the strings are different after looking at the first character.
As you get to the bottom of the tree, then it is more likely you will get more matches, but even if your search string is super long it does not matter because there is no need to read past the length of the string you are comparing against. So if you are comparing foohksahfjhsfhlkshklsjhalkjslkjaksjdfalksjldfhf to foo everything after the first h is irrelevant. If the string you are searching for were a gigabyte it would be irrelevant to run time because every string compare will end by the time you read to the end of the string you are comparing it to.
dsyxelic
Profile Joined May 2010
United States1417 Posts
Last Edited: 2017-03-21 22:00:52
March 21 2017 21:59 GMT
#17235
wouldn't that still be compatible with the idea that you have to search through length of string s? because we are looking for worst case, the worst case would be length of string s. foohsdfsdf compared to foo would stop after the first h (far from worst case), but if it were reverse with foo being the search string, it would also stop after we finished comparing f,o,o. the number of comparisons equaling length of string s (worst case for that length of string).

so i'm not quite understanding why string length wouldn't be relevant there
TL/SKT
meadbert
Profile Blog Joined October 2010
United States681 Posts
March 22 2017 00:06 GMT
#17236
On March 22 2017 06:59 dsyxelic wrote:
wouldn't that still be compatible with the idea that you have to search through length of string s? because we are looking for worst case, the worst case would be length of string s. foohsdfsdf compared to foo would stop after the first h (far from worst case), but if it were reverse with foo being the search string, it would also stop after we finished comparing f,o,o. the number of comparisons equaling length of string s (worst case for that length of string).

so i'm not quite understanding why string length wouldn't be relevant there

My answer about it being irrelevant is in the case where the string is not in the tree. The question was phrased in a way such that N is the size of the string you are searching for, but the list of strings is held constant. As N is increased it eventually outpaces all the strings in your tree and is by definition not in your tree so the length is irrelevant. If the size of the strings in the tree is simultaneously increased and they all start with the same characters as yours then it would be O (N), but that is not how the question was phrased.
Obviously if you find your string in order to prove they are in fact the same you would have to read both strings in their entirety and thus we are back to O (N).

TLDR:
Worst case is O (N) until your string is longer than any in tree at which point it is O (1).
dsyxelic
Profile Joined May 2010
United States1417 Posts
Last Edited: 2017-03-22 03:43:11
March 22 2017 02:13 GMT
#17237
well its asking for time complexity based on the size of the list so i dont think we can expect the size of the list to be constant. the question paraphrased is : 'describe an algorithm that searches for a string s in a sorted list size n. what is the time complexity of the algorithm in terms of the length of string s and size of list n'.

since I chose a BST, I said O(m log n) with m = length of s .

edit:
also even if the string we're searching for outpaced the size of the strings in the list, wouldn't that still be O(string length) for the search operation anyways because it's not worst case?


edit2:

to expand on the trie example, it would be O(m) where m is the length of string s for matching.
however if we care about inserting the list of strings into the trie it would be O(mn)? where again m is length of string s and n is size of list.

O(m) for insertion into trie and it would be n number of insertions.

I think this is correct line of thinking? anyone please correct me if I'm wrong
TL/SKT
slmw
Profile Blog Joined October 2010
Finland233 Posts
March 22 2017 07:59 GMT
#17238
There's no reason to construct a BST or a Trie since it's clearly just a one time search algorithm and not a data structure question. If you construct a BST or Trie you do indeed spend extra O(N*M) on inserting every string in the list like you said (when the strings in the list are each of length M). If the "list" is an array you can do O(|S| * log N) without any additional data structures.

(In case the "list" is a linked list you can simply compare every string in O(N*|S|).
dsyxelic
Profile Joined May 2010
United States1417 Posts
Last Edited: 2017-03-22 10:14:41
March 22 2017 10:03 GMT
#17239
oh then i misinterpreted the question :/ they didnt specify what kind of list it was so I guess we can assume it's either an array implementation or a list by pointers

I went with array cause that seemed simpler

k then thinking of it now with some code

def match(list, s):
start = -1
end = len(list)
while end-start>1:
p = (start+end)/2
if list[p] == s:
return True
if list[p] > s:
end=p
else:
start=p
return False


though of course the comparisons would only work if I had a some other function to compare the characters of the string or the value of the string for alphabetical comparison.

this function would run in O(log n)
total O(m log n), m = size of string s for character comparison

or O(|S| log n) with the way you expressed it
TL/SKT
meadbert
Profile Blog Joined October 2010
United States681 Posts
March 22 2017 17:41 GMT
#17240
On March 22 2017 19:03 dsyxelic wrote:
oh then i misinterpreted the question :/ they didnt specify what kind of list it was so I guess we can assume it's either an array implementation or a list by pointers

I went with array cause that seemed simpler

k then thinking of it now with some code

def match(list, s):
start = -1
end = len(list)
while end-start>1:
p = (start+end)/2
if list[p] == s:
return True
if list[p] > s:
end=p
else:
start=p
return False


though of course the comparisons would only work if I had a some other function to compare the characters of the string or the value of the string for alphabetical comparison.

this function would run in O(log n)
total O(m log n), m = size of string s for character comparison

or O(|S| log n) with the way you expressed it

Note that if the strings are random then average case remains O(log(n)) because string compares are constant with random strings.

If the strings are worst case, but your location in the array is random then you can improve to:
O(m + log(n)^2).

You can keep track of the right most string you compared against to the left of you and the left most string you compared against to the right of you and how many characters they have in common up front. All strings in between them also have those characters in common so you can skip those characters when doing comparisons.

While this improves average case assuming a random location, it does not improve the worst case since you might never traverse both left and right so you cannot take advantage of that trick. Basically if your string is first or last in the array that would be a worst case scenario.

There are some other tricks you can do to improve that case such as walking up from the bottom left corner of the tree, but even in that case if you walk half way up a tree of depth 30 you have walked a distance of O(log(n)) and you only removed ~32k out of one billion possibilities so that has a bad worst case.

Has anyone thought of a way to do it faster than O(m*log(n)) in the worst case?
Prev 1 860 861 862 863 864 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 7h 2m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 183
StarCraft: Brood War
Britney 32903
Rain 1885
GuemChi 883
firebathero 443
Horang2 404
BeSt 294
Mong 233
Leta 230
Soma 203
Rush 98
[ Show more ]
PianO 89
Barracks 65
Sharp 51
ggaemo 51
sorry 46
EffOrt 45
Shine 40
Mind 36
NotJumperer 33
yabsab 32
ZerO 28
Shinee 11
Movie 11
SilentControl 10
Bale 9
League of Legends
JimRising 533
C9.Mang0427
Counter-Strike
olofmeister1637
Heroes of the Storm
Khaldor10
Other Games
summit1g5880
XaKoH 295
singsing143
ZerO(Twitch)4
Organizations
Other Games
BasetradeTV68
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• LUISG 33
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• HappyZerGling94
Upcoming Events
Big Brain Bouts
7h 2m
Elazer vs Nicoract
Reynor vs Scarlett
Replay Cast
14h 2m
Sparkling Tuna Cup
2 days
Krystianer vs TBD
TriGGeR vs SKillous
Percival vs TBD
ByuN vs Nicoract
Replay Cast
2 days
Wardi Open
3 days
Liquipedia Results

Completed

KCM Race Survival 2025 Season 4
WardiTV 2025
META Madness #9

Ongoing

C-Race Season 1
IPSL Winter 2025-26
BSL Season 21
Slon Tour Season 2
CSL Season 19: Qualifier 2
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025

Upcoming

CSL 2025 WINTER (S19)
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Big Gabe Cup #3
OSC Championship Season 13
Nations Cup 2026
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.