Week 6 Office Hours - Post Your Questions here

6
2

Please post your questions for Week 6 office hours here. We'll record office hours on Friday.

asked 27 Mar '12, 12:43

UdacityDave's gravatar image

UdacityDave ♦♦
17.5k256483
accept rate: 455%

4

I've really enjoyed CS101, so thank you Dave & Peter.

I would like to take more level 1 courses, ideally prior to taking level 2 ones. Are there plans to offer more level 1 courses?

(28 Mar '12, 09:18) Sujata Krishna Sujata%20Krishna's gravatar image

I just have to say a Huge thanks to Professor Dave and Udacity CS101 team....!!!
Long live Udacity long live Udacians ...!!!:)

(29 Mar '12, 16:12) vipul divyanshu vipul%20divyanshu's gravatar image

We are about to start filming office hours.

(29 Mar '12, 17:46) PeterUdacity ♦♦ PeterUdacity's gravatar image

Work on your evil laugh, Peter!

(29 Mar '12, 17:48) Charles Lin Charles%20Lin's gravatar image

I just posted a question for the office hours, will it make it? I guess if not, then it will be responded here? Thanks.

(29 Mar '12, 19:17) María Mar%C3%ADa's gravatar image

proud to be Udacian..........

(30 Mar '12, 06:29) Adnan Masood Adnan%20Masood's gravatar image

52 Answers:

123456next »

  1. When to use recursive definition since it's bad performance compared with iteration?
  2. There is a memory cache quiz in last unit. Would it be used to cache the cache the result of recursive fibonacci? In this case, is performance of recursive definition better than iteration defination?
link

answered 27 Mar '12, 13:37

Wang%20Qunfeng's gravatar image

Wang Qunfeng
67541124

You got that right, if you cache your fibonacci procedure, the additional "cost" of recursion vs iteration is very low. Just the cost of the recursive function calls, and additional lookups in the dictionary (instead of swapping a couple of variables). So iteration is still slightly better in this case, but cached recursion would be far from timing out on fibonacci (36).

Generally, I find it more "natural" to use recursion, so for the sake of readability (understanding), and as long as bleeding-edge performance is of no concern, recursion does it for me.

(27 Mar '12, 13:44) SimStim SimStim's gravatar image

I've found that recursion is good for understanding and solving problems but generally do not use it in production code. The cost of recursion can be high as shown in the Fibonacci example and will tend to make your code more brittle. By brittle I mean that small changes to your code may cause unexpected results (e.g. due to a larger input loop value being passed to a recursive routine.) Of course YMMV.

(27 Mar '12, 15:17) Don-2 Don-2's gravatar image
1

That is a question, also, of readability vs. speed. Particularily when you get into tree structures and divide-and-conquer algorithms (Of wich quicksort is one), there are a lot of algorithms and ideas that are very naturally expressed as a recursive process, easily written and read that way. They can be converted to an iterative format, but that means you have to twist it a bit inside out. That makes for more complex and non-intuitive code - Bigger chance of bugs. In that case, the iterative code might reasonably be called more brittle :-)

But that is the eternal tradeoff - Readability vs Clever code, and also Time vs. Space, as we do in the memoize thingy. There, we win speed by sacrificing space (we build a honkin' great dictionary).

(28 Mar '12, 08:36) JohanG-Sweden JohanG-Sweden's gravatar image

Production code? That is a process - It would not be unheard of to write a working prototype in an as clear and straightforward style as possible, and then go rewriting particular functions that are deemed critical unteil the whole thing is good enough.

(28 Mar '12, 08:38) JohanG-Sweden JohanG-Sweden's gravatar image

We answered this question in office hours.

(29 Mar '12, 20:44) PeterUdacity ♦♦ PeterUdacity's gravatar image

Could we get to see a little more of the autograder, please? (old question)

link

answered 27 Mar '12, 13:30

Anton%20Golov's gravatar image

Anton Golov ♦
13.3k2174174

4

There are no plans to share the code externally. Homework 6 will tell you the input you failed on. Homework 6 Starred questions (which will be more visibly separate) will tell you how many test cases you pass. The plan is to eventually use the output format from the starred questions for every unit quiz/homework.

(27 Mar '12, 13:41) PeterUdacity ♦♦ PeterUdacity's gravatar image

Awesome upgrade! Will the result (how many/which test cases were passed/not passed) be immediate or only visible after due date? For multiple coice I understand it makes no sense to give away any clues. But for more and more complex code, it would be of great help to know right away, to fix code for those cases; I don't think that's giving too much away.

(27 Mar '12, 13:50) SimStim SimStim's gravatar image

Only after the due date. To do it before the due date requires a fundamental change in how all the backend elements communicate, i.e. a lot of work. This is something I've put together on my own without support from engineering.

(27 Mar '12, 14:00) PeterUdacity ♦♦ PeterUdacity's gravatar image

You're da man! It still helps, though. Good job.

(27 Mar '12, 14:02) SimStim SimStim's gravatar image

Dave mentioned "pythonic" in one of the instruction video. Would you please elaborate on this and how can we make our code more pythonic?

link

answered 28 Mar '12, 22:26

chainsawriot's gravatar image

chainsawriot
458414

More details on the final. Format and coverage (will it include info from Peter's homework answers or from Office Hours?)

link

answered 27 Mar '12, 14:06

MarkC's gravatar image

MarkC
2.0k1342

To add to this, also, will we be given more time than a week to complete the final exam? As, I guess many of us may be university and school students and might have their semester/final exams coming up during April!
It would be great if you could give us some more time to complete the final exam if possible! Thank You!

P.S.: I have 5 final exams in my university during the final week of this course! I have no idea how I will write the final exam of this course! Its close to impossible! :(

(29 Mar '12, 06:05) Abhishek Sar... Abhishek%20Saraf-3's gravatar image

What's the difference between python 2.x and 3.0? Are we learning an 'outdated' language by learning python 2.x?

link

answered 27 Mar '12, 13:03

Brian%20Yee's gravatar image

Brian Yee
2.4k21236

The way I see it, we're learning basics of computer science here, not fancy-pantsy aspects of a particular programming language. For those basics, differences in Python version shouldn't matter at all. Like, we're not going to build a search engine that can really compete with Google & co., but as a means to an end, it can help understand possible applications of the basics of CS. Else it would be too abstract for many, probably including myself! =)

(27 Mar '12, 13:07) SimStim SimStim's gravatar image
1

The differences aren't that big, but do break compatibility. What you learn applies very well to Python 3 and most other programming languages.

Probably the single biggest one is that many of the statements were turned into functions. So "print" isn't special anymore and you have to say print('hi') and not print 'hi'.

Going forward more and more people will use Python 3, but the fact of the matter is that most of industry uses Python 2.x and that will be true for a while.

(27 Mar '12, 13:47) PeterUdacity ♦♦ PeterUdacity's gravatar image

Guido Von Rossum (the creator of Python) said that Python 3 is the future, but he encourages to learn Python 2.x because, like Peter said, most of the industry uses it. One of the reasons of this, is that most libraries were written in Python 2.x; although they have a while now making the transition to Python 3.

(29 Mar '12, 16:19) Alan Avalos-4 Alan%20Avalos-4's gravatar image

How old is peterudacity? and is he an undergrad or a grad student??

link

answered 27 Mar '12, 13:09

stuky's gravatar image

stuky
50148

2

Almost 8: http://bit.ly/HhZzI1

Technically undergrad, but soon to be grad: http://www.cs.virginia.edu/~pmc8p/

(27 Mar '12, 13:37) PeterUdacity ♦♦ PeterUdacity's gravatar image

Yeah, and good luck with that!

(27 Mar '12, 13:40) SimStim SimStim's gravatar image

good luck... you look like a high school kid thats why was asking.. @peterudacity take that as a complement...:)

(27 Mar '12, 14:36) stuky stuky's gravatar image
2

It's probably part of his plans for world domination, to look..."innocent!" =)

(27 Mar '12, 14:41) SimStim SimStim's gravatar image

I'm used to it. During the grad school visits I got the high school confusion a couple times.

(27 Mar '12, 14:52) PeterUdacity ♦♦ PeterUdacity's gravatar image

Good job, Peter! Keep up the good work, man. Looks to me like you have a bright future.

(just don't let your changes to the autograder bork my HW ;)

(27 Mar '12, 15:22) Joe Balsamo Joe%20Balsamo's gravatar image

good job young man.. keep it it up.. I see you are already accomplished in your own rights...:)

(27 Mar '12, 16:19) stuky stuky's gravatar image

Back when it was still relevant, I'd always say, "It's not the years, but the miles..."

(27 Mar '12, 17:52) Treadwell Treadwell's gravatar image

In PageRank which we have learned in Unit 6, a page' rank is decided by all the ranks of pages linking to it.
Suppose we have a page with the highest rank in the website named Page A. If we search every single word exits in Page A, we will always get Page A.

So my question is:

In a real search engine like Google Search, is the rank of page related to words the page includes?

link

answered 28 Mar '12, 06:32

Huarong%20Huo's gravatar image

Huarong Huo
595326

We talked about this for a bit in office hours.

(29 Mar '12, 20:47) PeterUdacity ♦♦ PeterUdacity's gravatar image

Is there a way to see the code for python functions. For example, can we see how max(1,2,3) works, or any other function. I.e. how the in-built code is written. I searched the python documentation and the inspect function is suggested (inspect.getsource(object)) but that doesn't seem to work for in-built functions but only for user defined ones.

link

answered 27 Mar '12, 15:13

Hamid's gravatar image

Hamid
9517

Python is only partially programmed in Python itself. Many core functions are programmed in the "C" language, for matters of speed. Therefore an "inspect" for core functions would be very difficult to realise. And it would only help you if you also were fluent in C...

(27 Mar '12, 15:20) SimStim SimStim's gravatar image
1

You can view the disassembly of functions by importing dis and then calling dis.dis(funcname). However, the result isn't Python -- it's Python bytecode (and may very well consist of just a call to C). However, it's still fascinating to look at and you could learn to read it just like any other language.

(27 Mar '12, 15:26) Anton Golov ♦ Anton%20Golov's gravatar image

At the Python website you can download the source code for Python. It's a bit difficult to look through but it's doable. I've done it for a few quizzes and homeworks to adapt some more complex code for the grading.

(27 Mar '12, 17:29) PeterUdacity ♦♦ PeterUdacity's gravatar image

Peter, that is hardcore. I bow.

(28 Mar '12, 08:41) JohanG-Sweden JohanG-Sweden's gravatar image

Whilst debugging some Python (using the interpreter's debugger) a while back I accidentally 'entered' a random.randint call and found myself inside the 'random' library, looking at the code for randint, choice, etc. Felt weird, like I'd seen the Wizard of Oz behind the curtain, but kinda powerful too!

(14 Apr '12, 07:40) johnmkershaw johnmkershaw's gravatar image

Can you give us a model of our examination in 7th week ?

link

answered 27 Mar '12, 17:46

Adnan%20Masood's gravatar image

Adnan Masood
6303828

We talked about this in office hours.

(29 Mar '12, 20:47) PeterUdacity ♦♦ PeterUdacity's gravatar image

I'm trying to figure out what kind of new features could improve a new search engine.
What are the current issues or problems that major search engines are trying to sort?

link

answered 27 Mar '12, 18:53

Santiago-1's gravatar image

Santiago-1
7714

We answered this in office hours.

(29 Mar '12, 20:46) PeterUdacity ♦♦ PeterUdacity's gravatar image
Your answer
Question text:

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×15,242
×141
×110
×15
×13

Asked: 27 Mar '12, 12:43

Seen: 1,356 times

Last updated: 14 Apr '12, 09:40