• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 09:41
CEST 15:41
KST 22:41
  • 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 Energy18ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book20
Community News
$5,000 WardiTV TLMC tournament - Presented by Monster Energy2GSL CK: More events planned pending crowdfunding3Weekly Cups (May 30-Apr 5): herO, Clem, SHIN win0[BSL22] RO32 Group Stage4Weekly Cups (March 23-29): herO takes triple6
StarCraft 2
General
Quebec Clan still alive ? BGE Stara Zagora 2026 cancelled Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Weekly Cups (May 30-Apr 5): herO, Clem, SHIN win Rongyi Cup S3 - Preview & Info
Tourneys
Sea Duckling Open (Global, Bronze-Diamond) Sparkling Tuna Cup - Weekly Open Tournament GSL CK: More events planned pending crowdfunding $5,000 WardiTV TLMC tournament - Presented by Monster Energy RSL Season 4 announced for March-April
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
The PondCast: SC2 News & Results Mutation # 520 Moving Fees Mutation # 519 Inner Power Mutation # 518 Radiation Zone
Brood War
General
BW General Discussion ASL21 General Discussion so ive been playing broodwar for a week straight. Gypsy to Korea Pros React To: JaeDong vs Queen
Tourneys
Escore Tournament StarCraft Season 2 [Megathread] Daily Proleagues [ASL21] Ro24 Group F [BSL22] RO32 Group B - Sunday 21:00 CEST
Strategy
Fighting Spirit mining rates Muta micro map competition What's the deal with APM & what's its true value Simple Questions, Simple Answers
Other Games
General Games
Stormgate/Frost Giant Megathread General RTS Discussion Thread Starcraft Tabletop Miniature Game Nintendo Switch 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
Vanilla Mini 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 The China Politics Thread European Politico-economics QA Mega-thread Trading/Investing Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion Cricket [SPORT] Tokyo Olympics 2021 Thread
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
How Streamers Inspire Gamers…
TrAiDoS
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
ASL S21 English Commentary…
namkraft
StarCraft improvement
iopq
Electronics
mantequilla
Customize Sidebar...

Website Feedback

Closed Threads



Active: 3293 users

The Big Programming Thread - Page 855

Forum Index > General Forum
Post a Reply
Prev 1 853 854 855 856 857 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.
slmw
Profile Blog Joined October 2010
Finland233 Posts
March 01 2017 09:00 GMT
#17081
On March 01 2017 11:40 travis wrote:
Would it be possible for anyone to explain what is going on in this practice question for me?

Question:
The prototype of a function is

int *select(void *data);


Define a function pointer variable named fptr that can be assigned the function fptr = select

Answer:

+ Show Spoiler +

int *(*fptr)(void *);


So I have no idea wtf is going on here. Like, absolutely no idea. I also didn't even understand the question.

so our function pointer is int because the function type was in?
And the (void *) in the function pointer means what exactly? Does it have to do with the void pointer parameter in the function?


When in doubt, cdecl.org.
Khalum
Profile Joined September 2010
Austria831 Posts
Last Edited: 2017-03-01 09:20:32
March 01 2017 09:19 GMT
#17082
On March 01 2017 13:01 tofucake wrote:
Show nested quote +
On March 01 2017 11:50 Blisse wrote:
also another thing I grumble about, putting a space between the type and the pointer asterisk. Keep them together! It's type information >_>

int* (*fptr)(void*);


I disagree. The asterisk goes with the specific variable because it only applies to one, e.g.:
int *a, b;

int* a, b;


both are the same semantically

the first line makes it clear that only a is a pointer, whereas the second line implies that both a and b are pointers while only a is


Even if this is just a theoretical example, you should never declare variables like that.

[edit] Oh, that was being commented on already.. yeah. What Blisse said.
Acrofales
Profile Joined August 2010
Spain18258 Posts
March 01 2017 09:44 GMT
#17083
On March 01 2017 17:58 Nesserev wrote:
Show nested quote +
On March 01 2017 11:40 travis wrote:
Would it be possible for anyone to explain what is going on in this practice question for me?

Question:
The prototype of a function is

int *select(void *data);


Define a function pointer variable named fptr that can be assigned the function fptr = select

Answer:

+ Show Spoiler +

int *(*fptr)(void *);


So I have no idea wtf is going on here. Like, absolutely no idea. I also didn't even understand the question.

so our function pointer is int because the function type was in?
And the (void *) in the function pointer means what exactly? Does it have to do with the void pointer parameter in the function?

Here's a trick when determining the type of a function pointer, just:
- replace the name in the function declaration with (* fp)
- omit the parameter names.

int * king_of_swag(void * data, int * pizza)
becomes
int * (* fp)(void *, int *)


And then add extra spaces on both sides of * for improved ambiguity?
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
March 01 2017 10:43 GMT
#17084
--- Nuked ---
Manit0u
Profile Blog Joined August 2004
Poland17719 Posts
March 01 2017 11:10 GMT
#17085
http://stackoverflow.com/questions/11626786/what-does-void-mean-and-how-to-use-it

Void pointers are evil...
Time is precious. Waste it wisely.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
March 01 2017 18:48 GMT
#17086
I don't want the answer but could someone explain how to get started on this?

http://imgur.com/a/R9iEj

I don't really understand. What do a_1, a_2 etc represent? These values can just be anything in Q? How can I possibly solve that?
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
March 01 2017 18:53 GMT
#17087
You know how to solve a system of n equations and n variables?
If you have a good reason to disagree with the above, please tell me. Thank you.
bangsholt
Profile Joined June 2011
Denmark138 Posts
March 01 2017 18:59 GMT
#17088
On March 01 2017 20:10 Manit0u wrote:
http://stackoverflow.com/questions/11626786/what-does-void-mean-and-how-to-use-it

Void pointers are evil...


Nah, it's just hardmode generics ;o)
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-03-01 19:54:28
March 01 2017 19:38 GMT
#17089
On March 02 2017 03:53 spinesheath wrote:
You know how to solve a system of n equations and n variables?


I guess but that method seems far outside the scope of this class.

edit: well i solved it with a matrix. I am sure there could have been some tricks to make it easier. But I still don't even think this is how I was supposed to solve it.

(ah, seems there was some trick in the lecture slides)
Hanh
Profile Joined June 2016
146 Posts
March 02 2017 00:45 GMT
#17090
On March 02 2017 04:38 travis wrote:
Show nested quote +
On March 02 2017 03:53 spinesheath wrote:
You know how to solve a system of n equations and n variables?


I guess but that method seems far outside the scope of this class.

edit: well i solved it with a matrix. I am sure there could have been some tricks to make it easier. But I still don't even think this is how I was supposed to solve it.

(ah, seems there was some trick in the lecture slides)


The first term of sum 0..n i^p is 1/(p+1). No need to solve the rest if you only want that one.

+ Show Spoiler +

P(n, p) = sum 0..n i^p

P(n-1, p) = P(n, p) - n^p
= sum 1..(n-1) i^p (because the first term is 0)
= sum 0..n (i-1)^p (by transposing the index: i => i-1)
= sum 0..n [i^p - p.i^(p-1) + ...] (other terms are polynomial of power below)
= P(n, p) - p.P(n, p-1) + ... (by linearity of the sum)

Using the first and last line together,
- n^p = - p.P(n, p-1) + ...

P(n, p) = n^(p+1) / (p+1) + O(n^p)
slmw
Profile Blog Joined October 2010
Finland233 Posts
March 02 2017 12:43 GMT
#17091
On March 02 2017 09:45 Hanh wrote:
Show nested quote +
On March 02 2017 04:38 travis wrote:
On March 02 2017 03:53 spinesheath wrote:
You know how to solve a system of n equations and n variables?


I guess but that method seems far outside the scope of this class.

edit: well i solved it with a matrix. I am sure there could have been some tricks to make it easier. But I still don't even think this is how I was supposed to solve it.

(ah, seems there was some trick in the lecture slides)


The first term of sum 0..n i^p is 1/(p+1). No need to solve the rest if you only want that one.

+ Show Spoiler +

P(n, p) = sum 0..n i^p

P(n-1, p) = P(n, p) - n^p
= sum 1..(n-1) i^p (because the first term is 0)
= sum 0..n (i-1)^p (by transposing the index: i => i-1)
= sum 0..n [i^p - p.i^(p-1) + ...] (other terms are polynomial of power below)
= P(n, p) - p.P(n, p-1) + ... (by linearity of the sum)

Using the first and last line together,
- n^p = - p.P(n, p-1) + ...

P(n, p) = n^(p+1) / (p+1) + O(n^p)


Clever! Any easier ways to solve this? I solved the whole sum 0..n i^4 but that's a whole lot of effort, and even gaussian might be faster.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-03-02 22:25:59
March 02 2017 22:10 GMT
#17092
On March 02 2017 21:43 slmw wrote:
Show nested quote +
On March 02 2017 09:45 Hanh wrote:
On March 02 2017 04:38 travis wrote:
On March 02 2017 03:53 spinesheath wrote:
You know how to solve a system of n equations and n variables?


I guess but that method seems far outside the scope of this class.

edit: well i solved it with a matrix. I am sure there could have been some tricks to make it easier. But I still don't even think this is how I was supposed to solve it.

(ah, seems there was some trick in the lecture slides)


The first term of sum 0..n i^p is 1/(p+1). No need to solve the rest if you only want that one.

+ Show Spoiler +

P(n, p) = sum 0..n i^p

P(n-1, p) = P(n, p) - n^p
= sum 1..(n-1) i^p (because the first term is 0)
= sum 0..n (i-1)^p (by transposing the index: i => i-1)
= sum 0..n [i^p - p.i^(p-1) + ...] (other terms are polynomial of power below)
= P(n, p) - p.P(n, p-1) + ... (by linearity of the sum)

Using the first and last line together,
- n^p = - p.P(n, p-1) + ...

P(n, p) = n^(p+1) / (p+1) + O(n^p)


Clever! Any easier ways to solve this? I solved the whole sum 0..n i^4 but that's a whole lot of effort, and even gaussian might be faster.


I didn't even understand what he wrote, LOL
I need to write it out on paper instead of just staring at my monitor I guess

ok after staring it for even longer it looks like you are doing weak induction but you are not doing it like we were taught. you replaced n with n-1 instead of n+1
Hanh
Profile Joined June 2016
146 Posts
March 03 2017 00:56 GMT
#17093
It's a variable substitution. By the way, what was the trick from the lecture?
slmw
Profile Blog Joined October 2010
Finland233 Posts
March 03 2017 01:28 GMT
#17094
On March 03 2017 07:10 travis wrote:
Show nested quote +
On March 02 2017 21:43 slmw wrote:
On March 02 2017 09:45 Hanh wrote:
On March 02 2017 04:38 travis wrote:
On March 02 2017 03:53 spinesheath wrote:
You know how to solve a system of n equations and n variables?


I guess but that method seems far outside the scope of this class.

edit: well i solved it with a matrix. I am sure there could have been some tricks to make it easier. But I still don't even think this is how I was supposed to solve it.

(ah, seems there was some trick in the lecture slides)


The first term of sum 0..n i^p is 1/(p+1). No need to solve the rest if you only want that one.

+ Show Spoiler +

P(n, p) = sum 0..n i^p

P(n-1, p) = P(n, p) - n^p
= sum 1..(n-1) i^p (because the first term is 0)
= sum 0..n (i-1)^p (by transposing the index: i => i-1)
= sum 0..n [i^p - p.i^(p-1) + ...] (other terms are polynomial of power below)
= P(n, p) - p.P(n, p-1) + ... (by linearity of the sum)

Using the first and last line together,
- n^p = - p.P(n, p-1) + ...

P(n, p) = n^(p+1) / (p+1) + O(n^p)


Clever! Any easier ways to solve this? I solved the whole sum 0..n i^4 but that's a whole lot of effort, and even gaussian might be faster.


I didn't even understand what he wrote, LOL
I need to write it out on paper instead of just staring at my monitor I guess

ok after staring it for even longer it looks like you are doing weak induction but you are not doing it like we were taught. you replaced n with n-1 instead of n+1


Not induction. He's using the fact that he can rearrange [sum 0..p i^4] to be of the form[ x * n^5 + O(n^4)], which makes solving x easier since he can ignore any O(n^4) terms. The rest is just set-up for this. Plaintext math is awful to read though.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-03-03 03:16:36
March 03 2017 01:32 GMT
#17095
there was no proof, but the trick is that the leading term of the sum of form:

series from i = 1 to n (i^d) where d >= 1

can be approximated with the integral from 1 to n of x^d

which gives a coefficient of 1/(d+1)
slmw
Profile Blog Joined October 2010
Finland233 Posts
March 03 2017 01:50 GMT
#17096
Ah. Seems rather obvious with lim_(n->inf) but writing a full proof might be tougher.
Hanh
Profile Joined June 2016
146 Posts
Last Edited: 2017-03-03 04:24:04
March 03 2017 04:21 GMT
#17097
On March 03 2017 10:50 slmw wrote:
Ah. Seems rather obvious with lim_(n->inf) but writing a full proof might be tougher.


You have to prove that the residual is O(n^p) - which isn't easy to do for me.
meatpudding
Profile Joined March 2011
Australia520 Posts
March 03 2017 10:40 GMT
#17098
On March 01 2017 18:19 Khalum wrote:
Show nested quote +
On March 01 2017 13:01 tofucake wrote:
On March 01 2017 11:50 Blisse wrote:
also another thing I grumble about, putting a space between the type and the pointer asterisk. Keep them together! It's type information >_>

int* (*fptr)(void*);


I disagree. The asterisk goes with the specific variable because it only applies to one, e.g.:
int *a, b;

int* a, b;


both are the same semantically

the first line makes it clear that only a is a pointer, whereas the second line implies that both a and b are pointers while only a is


Even if this is just a theoretical example, you should never declare variables like that.

[edit] Oh, that was being commented on already.. yeah. What Blisse said.


I always use
int* a

It helps me think of a as a type of "int pointer" even though you need to know the rules of declaration. If you try and declare two pointers on the same line you are going to be disappointed. Especially in this case since your compiler might be able to cast an int* to an int.

I would rarely declare two vars on the same line due to convention. The spacing of the star is also a matter of convention, and mostly in practice I have seen it attached to the type name.

Another convention that helps reduce confusion is initialising pointers will nullptr instead of 0. Also I am very wary of declaring vars without initial values. The amount of hours I've spent debugging uninitialised variables as a rookie, oh geez.
Be excellent to each other.
Manit0u
Profile Blog Joined August 2004
Poland17719 Posts
March 03 2017 12:55 GMT
#17099
https://bugs.ruby-lang.org/issues/12142

It's surprising how much you can learn just from reading discussion on an issue.
Time is precious. Waste it wisely.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
March 03 2017 13:36 GMT
#17100
hanh or slmw or acrofales or anyone else, could you check over this? (really, I just want one step explained in it. anyone who is good at algebra could explain it)

the problem is to prove this sequence with strong induction

sequence:


a_0 = 12
a_1 = 20
(for all n >= 2)[a_n = 2a_(n-1) + 3a_(n-2)


Show that for all n, a_n <= 12*3^n


so my proof was to first show the base cases.

12 <= 12 * 1
20 <= 12*3

Now make inductive hypothesis.

For some k>= a_1, and for every i: 0 <= i <= k, assume that P(i) holds.
Therefore a_i = 12*3^i

Now do the inductive step by proving P(K+1):


a_(k+1) = 12 * 3^(k+1)

= 2a_k + 3a_(k-1)
= 2(12*3^k)+3(12*3^(k-1))
= 12 * (2*3^k + 3*3^k-1)


and here is where I don't know algebraically what to do next.
I mean obviously, (2*3^k + 3*3^(k-1)) = 3^(k+1)
But what steps are used to prove that?
Prev 1 853 854 855 856 857 1032 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Team League
11:00
Playoffs Day 2
WardiTV831
ComeBackTV 592
IndyStarCraft 143
Rex106
3DClanTV 58
Liquipedia
CranKy Ducklings
10:00
Sea Duckling Open #144
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
IndyStarCraft 143
Rex 106
trigger 59
StarCraft: Brood War
Britney 60500
Sea 6488
Jaedong 1603
EffOrt 1027
Shuttle 613
Hyuk 549
Mini 547
Light 384
firebathero 352
ggaemo 241
[ Show more ]
Zeus 187
hero 149
Last 129
PianO 92
Shinee 69
Pusan 51
[sc1f]eonzerg 48
ToSsGirL 44
Hm[arnc] 40
Sexy 31
Shine 27
HiyA 27
Movie 25
scan(afreeca) 24
910 21
Noble 18
Barracks 18
yabsab 17
Sacsri 17
Terrorterran 13
Rock 13
GoRush 9
Icarus 6
Dota 2
Gorgc8633
qojqva1448
syndereN243
Counter-Strike
kennyS1775
Heroes of the Storm
Khaldor152
Other Games
singsing1981
B2W.Neo1157
Lowko387
XaKoH 230
DeMusliM201
RotterdaM122
Hui .113
QueenE65
Organizations
Counter-Strike
PGL14815
Other Games
BasetradeTV1285
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
CasterMuse 0
sctven
[ Show 14 non-featured ]
StarCraft 2
• StrangeGG 58
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Michael_bg 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1911
• TFBlade1637
Upcoming Events
uThermal 2v2 Circuit
1h 19m
IPSL
2h 19m
Hawk vs TBD
StRyKeR vs TBD
BSL
5h 19m
n0maD vs perroflaco
TerrOr vs ZZZero
MadiNho vs WolFix
DragOn vs LancerX
Sparkling Tuna Cup
20h 19m
WardiTV Team League
21h 19m
OSC
23h 19m
BSL
1d 5h
Sterling vs Azhi_Dahaki
Napoleon vs Mazur
Jimin vs Nesh
spx vs Strudel
IPSL
1d 5h
Artosis vs TBD
Napoleon vs TBD
Replay Cast
1d 19h
Wardi Open
1d 20h
[ Show More ]
Afreeca Starleague
1d 20h
Soma vs YSC
Sharp vs sSak
Monday Night Weeklies
2 days
Afreeca Starleague
2 days
Snow vs PianO
hero vs Rain
GSL
2 days
Replay Cast
3 days
Kung Fu Cup
3 days
The PondCast
4 days
Escore
5 days
Korean StarCraft League
6 days
CranKy Ducklings
6 days
Liquipedia Results

Completed

Escore Tournament S2: W2
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
StarCraft2 Community Team League 2026 Spring
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

Upcoming

Escore Tournament S2: W3
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
RSL Revival: Season 5
WardiTV TLMC #16
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.