Author: Stan Eisenstat
Subject: Re: [CS223] t12 question [too slow to pass]
Date: Monday, 24 Feb 2020, 18:38:09
> ... I have passed all the tests except t12. I got the same answer as > the staff solution, and Valgrind passed with no error: > > > ==11194== definitely lost: 0 bytes in 0 blocks > > ==11194== indirectly lost: 0 bytes in 0 blocks > > ==11194== possibly lost: 0 bytes in 0 blocks > > ==11194== still reachable: 120 bytes in 1 blocks > > ==11194== suppressed: 0 bytes in 0 blocks > > total heap usage: 1,189 allocs, 1,188 frees, 1,886,327 bytes allocated > > However, it took too long to run t12 and was killed. I used 1 malloc per > substitution in my code, to create an intermediate array to store the > substituted string. I went for the office hour just now and ULA suggested > that I should email you. I have uploaded my latest source file onto the > zoo (bin/submit). Hint: How does the run-time of the loop char copy[strlen(line)]; for (int i = 0; i < strlen(line); i++) copy[i] = line[i]; depend on strlen(line). Linearly or quadratically? Why is this important when the intermediate results are very long as in Test #12? --Stan-PREV INDEX NEXT