• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:51
CEST 12:51
KST 19:51
  • 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
[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy17ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book20
Community News
Weekly Cups (March 23-29): herO takes triple6Aligulac acquired by REPLAYMAN.com/Stego Research8Weekly Cups (March 16-22): herO doubles, Cure surprises3Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool51Weekly Cups (March 9-15): herO, Clem, ByuN win4
StarCraft 2
General
Team Liquid Map Contest #22 - Presented by Monster Energy Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool What mix of new & old maps do you want in the next ladder pool? (SC2) Aligulac acquired by REPLAYMAN.com/Stego Research Weekly Cups (March 23-29): herO takes triple
Tourneys
RSL Season 4 announced for March-April Sparkling Tuna Cup - Weekly Open Tournament StarCraft Evolution League (SC Evo Biweekly) WardiTV Mondays World University TeamLeague (500$+) | Signups Open
Strategy
Custom Maps
[M] (2) Frigid Storage Publishing has been re-enabled! [Feb 24th 2026]
External Content
Mutation # 519 Inner Power The PondCast: SC2 News & Results Mutation # 518 Radiation Zone Mutation # 517 Distant Threat
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Pros React To: JaeDong vs Queen [ASL21] Ro24 Preview Pt2: News Flash Gypsy to Korea How Can I Add Timer & APM Count?
Tourneys
[ASL21] Ro24 Group E [Megathread] Daily Proleagues [ASL21] Ro24 Group F Azhi's Colosseum - Foreign KCM
Strategy
Fighting Spirit mining rates What's the deal with APM & what's its true value Simple Questions, Simple Answers
Other Games
General Games
Starcraft Tabletop Miniature Game Nintendo Switch Thread Stormgate/Frost Giant Megathread General RTS Discussion Thread Darkest Dungeon
Dota 2
The Story of Wings Gaming Official 'what is Dota anymore' discussion
League of Legends
G2 just beat GenG in First stand
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 TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread NASA and the Private Sector Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion Cricket [SPORT] Tokyo Olympics 2021 Thread General nutrition recommendations
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
China Uses Video Games to Sh…
TrAiDoS
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
ASL S21 English Commentary…
namkraft
Electronics
mantequilla
Customize Sidebar...

Website Feedback

Closed Threads



Active: 15878 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
RSL Revival
07:00
Season 4: Playoffs Day 7
MaxPax vs RogueLIVE!
Tasteless2241
ComeBackTV 599
CranKy Ducklings132
Rex119
3DClanTV 85
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Tasteless 2241
LamboSC2 177
ProTech140
Rex 119
MindelVK 40
Codebar 20
StarCraft: Brood War
Larva 478
Mini 242
Soulkey 210
hero 170
Pusan 162
Last 142
Hyun 119
Dewaltoss 106
Hm[arnc] 94
sorry 92
[ Show more ]
Light 92
Shinee 87
NaDa 47
Sharp 44
sSak 38
Free 38
zelot 30
Sacsri 26
Movie 14
HiyA 14
Dota 2
XaKoH 892
XcaliburYe431
canceldota68
Counter-Strike
edward80
byalli56
Heroes of the Storm
Khaldor159
Other Games
singsing2026
Organizations
Counter-Strike
PGL10929
Other Games
BasetradeTV212
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• LUISG 24
• CranKy Ducklings SOOP2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1608
• Stunt468
Upcoming Events
uThermal 2v2 Circuit
3h 9m
BSL
8h 9m
Afreeca Starleague
23h 9m
Wardi Open
23h 9m
Replay Cast
1d 13h
Sparkling Tuna Cup
1d 23h
Kung Fu Cup
3 days
The PondCast
3 days
Replay Cast
4 days
Replay Cast
5 days
[ Show More ]
CranKy Ducklings
5 days
BSL
6 days
Replay Cast
6 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

Escore Tournament S2: W1
WardiTV Winter 2026
NationLESS Cup

Ongoing

BSL Season 22
CSL Elite League 2026
ASL Season 21
CSL Season 20: Qualifier 2
StarCraft2 Community Team League 2026 Spring
RSL Revival: Season 4
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026

Upcoming

CSL 2026 SPRING (S20)
IPSL Spring 2026
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
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 © 2026 TLnet. All Rights Reserved.