• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 14:58
CEST 20:58
KST 03: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
[ASL22] Ro24 Preview: Siren's Call7[ASL22] Ro24 Preview: Summer's End9Serral wins HomeStory Cup 2915Serral wins Maestros of the Game 244ByuL, and the Limitations of Standard Play3
Community News
New 3v3 BGH Ladder (and more) on ShieldBattery!21Weekly Cups (August 17-23): Zerg dominate the week2Weekly Cups (August 10-16): SHIN doubles2GSTL Returns in 2026!45Weekly Cups (Aug 3-9): Protoss get shut out7
StarCraft 2
General
SC4ALL II: SC2 Player Announcement 6/8 - Maru How would you feel about frequent/monthly balance patches for SC2? Weekly Cups (August 17-23): Zerg dominate the week PhD study /w SC2 - help with a survey! Geoff 'iNcontroL' Robinson has passed away
Tourneys
2026 GSTL Announcement IntoTheTV X SOOP SC2 League : Weekly & Monthly PIG STY FESTIVAL 8.0! (13 - 23 August) Sparkling Tuna Cup - Weekly Open Tournament WORTEX 2026 - Hungarian SC2 Finals Budapest
Strategy
[G] Having the right mentality to improve
Custom Maps
Nexus Wars 2021 GUIDE [M] (2) Industrial Park
External Content
Mutation # 540 Dodge This The PondCast: SC2 News & Results Mutation # 539 Thunder Dome Mutation # 538 Media Blackout
Brood War
General
New 3v3 BGH Ladder (and more) on ShieldBattery! 25 Years Since Brood War Patch 1.08 BW General Discussion Looking 4 Yaroslav: Enemy, Korchagin, WCG, Ukraine Pros React To: First 'Fastest' Map in ASL History
Tourneys
[ASL22] Ro24 Group E Escore Tournament - Season 3 [ASL22] Ro24 Group D [ASL22] Ro24 Group B
Strategy
Replay Review Process - What do you do? Odyssey Mineral Stack Saturation Fighting Spirit mining rates Any training maps people recommend?
Other Games
General Games
Nintendo Switch Thread General RTS Discussion Thread Anyone here play Quakeworld back in the day? Stormgate/Frost Giant Megathread EVE Corporation
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
[TL LoL EUW IHs] Teemo shall perish TSM pausing esports and CLG Dead
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank TL Mafia Community Thread NeO.D_StephenKing vs This Guy From 1 Million Dance
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Artificial Intelligence Thread Canadian Politics Mega-thread Dating: How's your luck?
Fan Clubs
The Creator Fan Club MarineLorD Fan Club The ShoWTimE Fan Club
Media & Entertainment
Movie Discussion! Anime Discussion Thread
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023 NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Northern Ireland Global Starcraft
Blogs
Young Players Exit Esports E…
TrAiDoS
LOCKPICKING NOOB
LUCKY_NOOB
Cathedral Of CS And NY pizza a…
FuDDx
Please support my new stand…
Peanutsc
Hello guys!
LIN1s
Customize Sidebar...

Website Feedback

Closed Threads



Active: 3337 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 5h 2m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
MindelVK 36
CosmosSc2 16
ProTech1
StarCraft: Brood War
Dewaltoss 124
Hyun 59
910 32
Rock 22
soO 18
Counter-Strike
edward65
Super Smash Bros
Mew2King80
PPMD9
Other Games
Grubby2490
Liquid`RaSZi2208
fl0m1384
ceh9557
B2W.Neo324
XBOCT258
Liquid`Hasu238
C9.Mang0110
Livibee75
Trikslyr71
QueenE53
Organizations
StarCraft 2
WardiTV1120
[ Show 15 non-featured ]
StarCraft 2
• Reevou 3
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• blackmanpl 29
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV958
• masondota2875
League of Legends
• TFBlade970
Other Games
• imaqtpie1291
• Shiphtur364
Upcoming Events
PiGosaur Cup
5h 2m
Afreeca Starleague
15h 2m
Mini vs Calm
Queen vs EffOrt
Patches Events
21h 2m
Replay Cast
1d 5h
The PondCast
1d 15h
Replay Cast
2 days
Escore
2 days
IntoTheTV X SOOP
2 days
Korean StarCraft League
3 days
GSL
3 days
[ Show More ]
Replay Cast
4 days
Sparkling Tuna Cup
4 days
WardiTV Weekly
4 days
GSL
6 days
Liquipedia Results

Completed

CSL Season 22: Qualifier 1
PiG Sty Festival 8.0
META DYMY #4

Ongoing

KCM Race Survival 2026 Season 3
K-JUNGMAN
ASL Season 22
Super Anchor Qualifying S3
CSL Season 22: Qualifier 2
RSL Revival: Season 6
Light Tournament 2026
Esports World Cup 2026
Esports World Cup 2026: LCQ
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026

Upcoming

BSL 2026 LAN: Kraków
CSL 2026 AUTUMN (S22)
Acropolis #5
Acropolis #5 - TRS
Blizzard Classic Cup 2026
Acropolis #5 - GSA
Acropolis #5 - GSB
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
Calamity Invitational
Big Dog Cup 2026 Div 1
IEM Beijing 2026
Stake Ranked Episode 5
PGL Masters Bucharest 2026
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 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.