Docsity

Final Exam - Introduction to Computing | CS 1301, Exams of Computer Science

Toggle sidebar
bg1
Your Name: _______________________________________________________________ 1 / 5
CS 1301 with Robots Fall 2007 โ€“ Final Exam
1. Vocabulary Matching:
Write the number from the correct definition in the blank next to each term on the
left:
____ Syntax error 1. The term describing a list that is an element of another list.
____ Runtime error 2. A name which refers to a value.
____ Semantic error 3. The term for when a function calls itself.
____ Linear search 4. A programming error which occurs when program is executed.
____ Element 5. The type of search which starts at the median of a sorted list and
disregards half of the list with each search to find a certain number.
____ Mutable 6. The type of sort where the new array is built one element at a time
and has O(n2) time.
____ Variable 7. The type of search which looks at every element in a list until a
certain number is found.
____ Merge sort 8. The term for a value in a list (or another type of sequence).
____ Nested list 9. A programming error which makes the program do something other
than the programmer intended.
____ Recursion 10. The sort where a list is split in half; each sublist is recursively split.
Lists with one element are sorted into a new list in O(n log n) time.
____ Insertion sort 11. A programming error which occurs when Python finds an error
with the basic structure of code.
____ Binary search 12. The term describing compound data types which allow the
programmer assign new values to elements.
Your Name: _______________________________________________________________ 2 / 5
2. Write Code:
Write a function printToNumber5 that uses a for loop to print numbers 1-5 on the screen.
pf3
pf4
pf5

Partial preview of the text

Download Final Exam - Introduction to Computing | CS 1301 and more Exams Computer Science in PDF only on Docsity!

Your Name: _______________________________________________________________ 1 / 5

CS 1301 with Robots Fall 2007 โ€“ Final Exam

1. Vocabulary Matching:

Write the number from the correct definition in the blank next to each term on the

left:

____ Syntax error 1. The term describing a list that is an element of another list. ____ Runtime error 2. A name which refers to a value. ____ Semantic error 3. The term for when a function calls itself. ____ Linear search 4. A programming error which occurs when program is executed. ____ Element 5. The type of search which starts at the median of a sorted list and disregards half of the list with each search to find a certain number. ____ Mutable 6. The type of sort where the new array is built one element at a time and has O(n^2 ) time. ____ Variable 7. The type of search which looks at every element in a list until a certain number is found. ____ Merge sort 8. The term for a value in a list (or another type of sequence). ____ Nested list 9. A programming error which makes the program do something other than the programmer intended. ____ Recursion 10. The sort where a list is split in half; each sublist is recursively split. Lists with one element are sorted into a new list in O(n log n) time. ____ Insertion sort 11. A programming error which occurs when Python finds an error with the basic structure of code. ____ Binary search 12. The term describing compound data types which allow the programmer assign new values to elements. Your Name: _______________________________________________________________ 2 / 5

  1. Write Code: Write a function printToNumber5 that uses a for loop to print numbers 1-5 on the screen.
  1. Write Code: Rewrite the function printToNumber5 from part 2 so that the function uses a while loop to print numbers 1-5 on the screen.
  2. Write Code: Write a function printToNumber with parameter (aNumber) that takes user input and print numbers 1 to aNumber on the screen. Assume the user gives a positive integer (although remember user input may get converted to a string). Your Name: _______________________________________________________________ 3 / 5
  3. Sort list: Simulating a merge sort, divide and sort the following list showing all steps:

Write a program to create ascii art (looking at the green value of each pixel and determining whether to change to a โ€œ. โ€, a โ€œ- โ€, a โ€œx โ€ or an โ€œX โ€ by darkness). Write to a new file called โ€œpic.txtโ€. Your Name: _______________________________________________________________ 5 / 5

  1. Write Code:

Write a function taking no parameters that could theoretically run forever. Extra Credit:

  1. What is the name of your robot?______________________
  2. Convert 31 to binary._____________________
  3. Convert 10010 to decimal._____________________
  4. What is your favorite command using the robot?__________________
  5. What is your section number?_____________________